public static List <CustomerModel> CustomerListExport(IEnumerable <int> zipCodes, string site, bool isProduction)
        {
            BusinessFlowContext.SetContext(site, isProduction);
            var customerList   = new List <CustomerModel>();
            var customerSearch = new CustomerSearchRequest();
            var stateCriterion = new AdditionalCriterion();

            stateCriterion.CriterionID   = "customer_postal_code";
            stateCriterion.CriterionType = AdditionalCriterionType.Database;


            customerSearch.MaxRows = 20000;
            customerSearch.Filter  = CustomerSearchFilter.Active;
            customerSearch.AddCriterion(stateCriterion);
            customerSearch.AddCriterion("lu_dt", AdditionalColumnType.Database, DateTime.Today.AddYears(-4).ToShortDateString(), AdditionalCriterionCondition.GreaterThan);

            for (var i = 0; i < zipCodes.Count(); i += 10)
            {
                stateCriterion.Parameters = zipCodes.Skip(i).Take(10).Select(z => z.ToString()).ToArray();
                var customers = BusinessFlow.WebServices.Customer.Search(customerSearch);

                foreach (dsCustomerList.CustomersRow customer in customers.Customers)
                {
                    customerList.Add(SafeCreate(customer));
                }
            }

            return(customerList);
        }
        public static List <CustomerModel> CustomerListExport(string state, string site, bool isProduction)
        {
            BusinessFlowContext.SetContext(site, isProduction);
            var customerList   = new List <CustomerModel>();
            var customerSearch = new CustomerSearchRequest();
            var stateCriterion = new AdditionalCriterion();

            stateCriterion.CriterionID   = "customer_region_cd";
            stateCriterion.CriterionType = AdditionalCriterionType.Database;
            stateCriterion.Parameters    = new string[] { state };

            customerSearch.MaxRows = 50000;
            customerSearch.Filter  = CustomerSearchFilter.Active;
            customerSearch.AddCriterion(stateCriterion);
            customerSearch.AddCriterion("lu_dt", AdditionalColumnType.Database, DateTime.Today.AddYears(-3).ToShortDateString(), AdditionalCriterionCondition.GreaterThan);

            var customers = BusinessFlow.WebServices.Customer.Search(customerSearch);

            if (customers.Customers.Rows.Count == 50000)
            {
                throw new NotImplementedException(state + " is just TOO BIG!!");
            }

            foreach (dsCustomerList.CustomersRow customer in customers.Customers)
            {
                customerList.Add(SafeCreate(customer));
            }

            return(customerList);
        }
        public static List <CustomerModel> CustomerPointInTimeExport(DateTime since, string site, bool isProduction)
        {
            BusinessFlowContext.SetContext(site, isProduction);
            var customerList   = new List <CustomerModel>();
            var customerSearch = new CustomerSearchRequest();

            customerSearch.AddCriterion("customer_closed", AdditionalColumnType.Database, "0");
            customerSearch.AddCriterion("customer_suspended", AdditionalColumnType.Database, "0");
            customerSearch.AddCriterion("lu_dt", AdditionalColumnType.Database, since.ToShortDateString(), AdditionalCriterionCondition.GreaterThan);
            customerSearch.MaxRows = 10000;

            var customers = BusinessFlow.WebServices.Customer.Search(customerSearch);

            foreach (dsCustomerList.CustomersRow customer in customers.Customers)
            {
                customerList.Add(SafeCreate(customer));
            }

            return(customerList);
        }