Example #1
0
        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);
        }
Example #2
0
        public List <Customer> GetCustomers()
        {
            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"];
            //OData URI creation
            string serviceUri = string.Format(serviceODataURL + "/Company('{0}')", Company);

            List <Customer> custListB2B = new List <Customer>();

            try
            {
                DataServiceContext context = new DataServiceContext(new Uri(serviceUri));
                //Web service initialization
                NAV_ODATA.NAV theNav = new NAV_ODATA.NAV(new Uri(serviceUri));
                //User impersonation
                theNav.Credentials = new System.Net.NetworkCredential(WS_User, WS_Pwd, WS_Domain);
                //Calls the OData WS (NAV Query)
                DataServiceQuery <NAV_ODATA.B2BClientiWeb> q = theNav.CreateQuery <NAV_ODATA.B2BClientiWeb>("B2BClientiWeb");

                List <NAV_ODATA.B2BClientiWeb> custList = q.Execute().ToList();

                foreach (NAV_ODATA.B2BClientiWeb cust in custList)
                {
                    Customer c = new Customer();
                    c.No             = cust.No;
                    c.Name           = cust.Name;
                    c.Address        = cust.Address;
                    c.City           = cust.City;
                    c.CAP            = cust.Post_Code;
                    c.Country        = cust.Country_Region_Code;
                    c.County         = cust.County;
                    c.FiscalCode     = cust.Fiscal_Code;
                    c.VATNo          = cust.VAT_Registration_No;
                    c.EmailEcommerce = cust.Email_Ecommerce;
                    c.Active         = cust.ActivadoWeb;
                    custListB2B.Add(c);
                }
            }
            catch (Exception)
            {
            }

            return(custListB2B);
        }
Example #3
0
        public List <ShipmentAddress> GetShipmentAddresses()
        {
            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 <ShipmentAddress> indListB2B = new List <ShipmentAddress>();

            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.B2BShipAddress> q = theNav.CreateQuery <NAV_ODATA.B2BShipAddress>("B2BShipAddress");

                List <NAV_ODATA.B2BShipAddress> addrList = q.Execute().ToList();

                foreach (NAV_ODATA.B2BShipAddress addr in addrList)
                {
                    ShipmentAddress ind = new ShipmentAddress();
                    ind.CustomerNo = addr.Customer_No;
                    ind.Code       = addr.Code;
                    ind.Name       = addr.Name;
                    ind.Address    = addr.Address;
                    ind.City       = addr.City;
                    ind.County     = addr.County;
                    ind.Country    = addr.Country_Region_Code;
                    ind.Default    = addr.Default_Shipment;

                    indListB2B.Add(ind);
                }
            }
            catch (Exception)
            {
            }

            return(indListB2B);
        }