Building ERP Solutions with Microsoft Dynamics NAV by Stefano Demiliani
Author:Stefano Demiliani [Demiliani, Stefano]
Language: eng
Format: azw3
Publisher: Packt Publishing
Published: 2017-03-22T04:00:00+00:00
DALItems
This implements a GetItems method. It reads the web.config file for retrieving the NAV web service URL and all the NAV parameters for authentication (user's impersonation). Then, it creates an instance of the NAV ODATA web service (Query object), passes credentials to the instance, executes the NAV Query object (Query ID 50000), and reads the results.
Here is the C# code:
public List<Item> GetItems(string ModifiedDate) { string serviceODataURL = ConfigurationManager.AppSettings["NAVODATAUrl"]; string WS_User = ConfigurationManager.AppSettings["NAV_User"]; string WS_Pwd = ConfigurationManager.AppSettings["NAV_Pwd"]; string WS_Domain = ConfigurationManager.AppSettings["NAV_Domain"]; string Company = ConfigurationManager.AppSettings["Company"]; string serviceUri = string.Format(serviceODataURL + "/Company('{0}')", Company); List<Item> itemListB2B = new List<Item>(); try { DataServiceContext context = new DataServiceContext(new Uri(serviceUri)); NAV_ODATA.NAV theNav = new NAV_ODATA.NAV(new Uri(serviceUri)); theNav.Credentials = new System.Net.NetworkCredential(WS_User, WS_Pwd, WS_Domain); DataServiceQuery<NAV_ODATA.B2BArticoliWeb> q = theNav.CreateQuery<NAV_ODATA.B2BArticoliWeb> ("B2BArticoliWeb"); if (ModifiedDate.Length > 0) { //OData Filter Expression ge = greater than or equal to string FilterValue = string.Format("Last_Date_Modified ge datetime'{0}' or Last_Movement_Date ge datetime'{0}'", ModifiedDate); q = q.AddQueryOption("$filter", FilterValue); } List<NAV_ODATA.B2BArticoliWeb> itemList = q.Execute().ToList(); foreach (NAV_ODATA.B2BArticoliWeb item in itemList) { Item a = new Item(); a.No = item.No; a.Description1 = item.Description; a.Description2 = item.Description_2; a.Inventory = item.Inventory; a.Lot = item.Quantità_Lotto; a.UnitOfMeasure = item.Base_Unit_of_Measure; a.ItemType = item.Linea; a.ItemBrand= item.Dimension_Value_Code; a.BrandDescription = item.Name; itemListB2B.Add(a); } } catch (Exception ex) { string exmsg = ex.Message; } return itemListB2B; }
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Implementing Enterprise Observability for Success by Manisha Agrawal and Karun Krishnannair(7414)
Supercharging Productivity with Trello by Brittany Joiner(6673)
Mastering Tableau 2023 - Fourth Edition by Marleen Meier(6443)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6424)
Inkscape by Example by István Szép(6292)
Visualize Complex Processes with Microsoft Visio by David J Parker & Šenaj Lelić(5987)
Build Stunning Real-time VFX with Unreal Engine 5 by Hrishikesh Andurlekar(4990)
Design Made Easy with Inkscape by Christopher Rogers(4643)
Customizing Microsoft Teams by Gopi Kondameda(4181)
Linux Device Driver Development Cookbook by Rodolfo Giometti(3939)
Extending Microsoft Power Apps with Power Apps Component Framework by Danish Naglekar(3770)
Business Intelligence Career Master Plan by Eduardo Chavez & Danny Moncada(3769)
Salesforce Platform Enterprise Architecture - Fourth Edition by Andrew Fawcett(3648)
Pandas Cookbook by Theodore Petrou(3624)
The Tableau Workshop by Sumit Gupta Sylvester Pinto Shweta Sankhe-Savale JC Gillet and Kenneth Michael Cherven(3423)
TCP IP by Todd Lammle(2994)
Drawing Shortcuts: Developing Quick Drawing Skills Using Today's Technology by Leggitt Jim(2924)
Exploring Microsoft Excel's Hidden Treasures by David Ringstrom(2893)
Applied Predictive Modeling by Max Kuhn & Kjell Johnson(2884)
