Ejemplo n.º 1
0
        public Warehouse.Customer[] getCustomers(int page=1)
        {
            if (page <= 0) page = 1;
            List<Warehouse.Customer> customerList = new List<Warehouse.Customer>();
            CustomerAccount customers = new CustomerAccount();
            CustomerAccountCollection results = (CustomerAccountCollection) MZ.Request(customers, typeof(CustomerAccountCollection));
            if (results.Items != null) {
                foreach (CustomerAccount customer in results.Items) {
                    if (customer.AuditInfo == null) continue;
                    if (Utility.getDateTime(customer.AuditInfo.CreateDate) < new DateTime(2015, 5, 28)) continue;

                    Warehouse.Customer c = new Warehouse.Customer();
                    c.FirstName = customer.FirstName;
                    c.LastName = customer.LastName;
                    if (customer.Contacts != null && customer.Contacts.Count > 0) {
                        CustomerContact contact = customer.Contacts[0];
                        c.Address1 = contact.Address.Address1;
                        c.Address2 = contact.Address.Address2;
                        c.City = contact.Address.CityOrTown;
                        c.State = contact.Address.StateOrProvince;
                        c.ZipCode = contact.Address.PostalOrZipCode;
                        c.Country = contact.Address.CountryCode;
                        c.Phone = contact.PhoneNumbers.Home;
                    }
                    c.Email = customer.EmailAddress;
                    if (string.IsNullOrWhiteSpace(c.Email)) continue;

                    if (! string.IsNullOrWhiteSpace(c.Email)) {
                        if (customersAdded.Contains(c.Email)) continue;
                        customersAdded.Add(c.Email);
                    }

                    customerList.Add(c);
                }
            }

            return customerList.ToArray();
        }
Ejemplo n.º 2
0
 private void downloadCustomers()
 {
     CustomerAccount customers = new CustomerAccount();
     CustomerAccountCollection results = (CustomerAccountCollection) MZ.Request(customers, typeof(CustomerAccountCollection));
     if (results.Items != null) {
         foreach (CustomerAccount customer in results.Items) {
             //Warehouse.Warwick.Customer c = new Warehouse.Warwick.Customer();
             Warehouse.Customer c = new Warehouse.Customer();
             //c.customer.system = _system;
             c.FirstName = c.FirstName;
             c.MiddleName = c.MiddleName;
             c.LastName = c.LastName;
             c.Address1 = c.Address1;
             c.Address2 = c.Address2;
             c.City = c.City;
             c.State = c.State;
             c.ZipCode = c.ZipCode;
             c.Country = c.Country;
             c.Phone = c.Phone;
             c.PhoneExtension = c.PhoneExtension;
             c.Email = c.Email;
             c.Fax = c.Fax;
             c.Save();
         }
     }
 }