Beispiel #1
0
        public Warehouse.Order[] getOrders(int page=1, string orderNumber=null)
        {
            List<Warehouse.Order> orderList = new List<Warehouse.Order>();
            Order orders = new Order();
            //if (! string.IsNullOrWhiteSpace(orderNumber)) orders.OrderNumber = Utility.getInt(orderNumber);
            OrderCollection results = (OrderCollection) MZ.Request(orders, typeof(OrderCollection));
            if (results.Items != null) {
                foreach (Order o in results.Items) {
                    if (o.AuditInfo == null) continue;
                    if (Utility.getDateTime(o.AuditInfo.CreateDate) < new DateTime(2015, 5, 28)) continue;
                    if (! string.IsNullOrWhiteSpace(orderNumber) && o.OrderNumber.ToString() != orderNumber) continue;

                    Warehouse.Order order = new Warehouse.Order();
                    order.OrderNumber = o.OrderNumber.ToString();
                    order.OrderDate = Utility.getDateTime(o.SubmittedDate);

                    if (o.BillingInfo == null) continue;
                    order.BillTo = new Warehouse.Customer {
                        FirstName = o.BillingInfo.BillingContact.FirstName,
                        LastName = o.BillingInfo.BillingContact.LastNameOrSurname,
                        Address1 = o.BillingInfo.BillingContact.Address.Address1,
                        Address2 = o.BillingInfo.BillingContact.Address.Address2,
                        City = o.BillingInfo.BillingContact.Address.CityOrTown,
                        State = o.BillingInfo.BillingContact.Address.StateOrProvince,
                        ZipCode = o.BillingInfo.BillingContact.Address.PostalOrZipCode,
                        Country = o.BillingInfo.BillingContact.Address.CountryCode,
                        Phone = o.BillingInfo.BillingContact.PhoneNumbers.Home,
                        Email = o.BillingInfo.BillingContact.Email,
                    };
                    if (o.Shipments != null && o.Shipments.Count > 0) {
                        order.ShipTo = new Warehouse.Customer {
                            FirstName = o.Shipments[0].DestinationAddress.FirstName,
                            LastName = o.Shipments[0].DestinationAddress.LastNameOrSurname,
                            Address1 = o.Shipments[0].DestinationAddress.Address.Address1,
                            Address2 = o.Shipments[0].DestinationAddress.Address.Address2,
                            City = o.Shipments[0].DestinationAddress.Address.CityOrTown,
                            State = o.Shipments[0].DestinationAddress.Address.StateOrProvince,
                            ZipCode = o.Shipments[0].DestinationAddress.Address.PostalOrZipCode,
                            Country = o.Shipments[0].DestinationAddress.Address.CountryCode,
                            Phone = o.Shipments[0].DestinationAddress.PhoneNumbers.Home,
                            Email = o.Shipments[0].DestinationAddress.Email,
                        };
                    } else {
                        order.ShipTo = new Warehouse.Customer {
                            FirstName = o.FulfillmentInfo.FulfillmentContact.FirstName,
                            LastName = o.FulfillmentInfo.FulfillmentContact.LastNameOrSurname,
                            Address1 = o.FulfillmentInfo.FulfillmentContact.Address.Address1,
                            Address2 = o.FulfillmentInfo.FulfillmentContact.Address.Address2,
                            City = o.FulfillmentInfo.FulfillmentContact.Address.CityOrTown,
                            State = o.FulfillmentInfo.FulfillmentContact.Address.StateOrProvince,
                            ZipCode = o.FulfillmentInfo.FulfillmentContact.Address.PostalOrZipCode,
                            Country = o.FulfillmentInfo.FulfillmentContact.Address.CountryCode,
                            Phone = o.FulfillmentInfo.FulfillmentContact.PhoneNumbers.Home,
                            Email = o.FulfillmentInfo.FulfillmentContact.Email,
                        };
                    }

                    /** add the items */
                    List<Warehouse.Item> items = new List<Warehouse.Item>();
                    foreach (OrderItem item in o.Items) {
                        Warehouse.Item i = new Warehouse.Item();
                        i.SKU = item.Product.ProductCode;
                        i.Quantity = item.Quantity;
                        i.Price.Total = (double) item.Product.Price.Price;
                        if (i.Price.Total == 0) continue;
                        items.Add(i);
                    }
                    order.Items = items.ToArray();
                    if (order.Items.Length == 0) continue;

                    if (ordersAdded.Contains(order.OrderNumber)) continue;
                    ordersAdded.Add(order.OrderNumber);

                    orderList.Add(order);
                }
            }

            return orderList.ToArray();
        }
Beispiel #2
0
 private void downloadOrders()
 {
     Order orders = new Order();
     OrderCollection results = (OrderCollection) MZ.Request(orders, typeof(OrderCollection));
     if (results.Items != null) {
         foreach (Order o in results.Items) {
             //Warehouse.Warwick.Order order = new Warehouse.Warwick.Order();
             Warehouse.Order order = new Warehouse.Order();
             //order.order.system = _system;
             order.OrderNumber = o.OrderNumber.ToString();
             order.OrderDate = Utility.getDateTime(o.SubmittedDate);
             //order.BillTo = new Warehouse.Warwick.Customer {
             order.BillTo = new Warehouse.Customer {
                 FirstName = o.BillingInfo.BillingContact.FirstName,
                 LastName = o.BillingInfo.BillingContact.LastNameOrSurname,
                 Address1 = o.BillingInfo.BillingContact.Address.Address1,
                 Address2 = o.BillingInfo.BillingContact.Address.Address2,
                 City = o.BillingInfo.BillingContact.Address.CityOrTown,
                 State = o.BillingInfo.BillingContact.Address.StateOrProvince,
                 ZipCode = o.BillingInfo.BillingContact.Address.PostalOrZipCode,
                 Country = o.BillingInfo.BillingContact.Address.CountryCode,
                 Phone = o.BillingInfo.BillingContact.PhoneNumbers.Home,
                 Email = o.BillingInfo.BillingContact.Email,
             };
             /*order.ShipTo = new Warehouse.Warwick.Customer {
                 FirstName = o.Shipments[0].DestinationAddress.FirstName,
                 LastName = o.Shipments[0].DestinationAddress.LastNameOrSurname,
                 Address1 = o.Shipments[0].DestinationAddress.Address.Address1,
                 Address2 = o.Shipments[0].DestinationAddress.Address.Address2,
                 City = o.Shipments[0].DestinationAddress.Address.CityOrTown,
                 State = o.Shipments[0].DestinationAddress.Address.StateOrProvince,
                 ZipCode = o.Shipments[0].DestinationAddress.Address.PostalOrZipCode,
                 Country = o.Shipments[0].DestinationAddress.Address.CountryCode,
                 Phone = o.Shipments[0].DestinationAddress.PhoneNumbers.Home,
                 Email = o.Shipments[0].DestinationAddress.Email,
             };*/
             order.Save();
         }
     }
 }