private void FreeLocalStorage(bool final)
 {
     catalog = null;
     sales = null;
     customers = null;
     categories = null;
     brands = null;
     customfields = null;
     options = null;
     if (final == true)
     {
         // Keep these around in between calls to GetSales and GetCustomers
         orderproducts = null;
         customeraddresses = null;
     }
 }
        public void InitializeGroupData(DataGroup group, string extraFields)
        {
            catalog = null;
            sales = null;
            customers = null;
            categories = null;
            brands = null;
            customfields = null;
            options = null;

            switch (group)
            {
                case DataGroup.Catalog:
                    // Get customfields, categories and brands first to support catalog retrieval.
                    customfields = new CustomFields();
                    GetGroupData(DataGroup.Custom, "", "", "");
                    categories = new Categories(extractor.Rules);
                    GetGroupData(DataGroup.CategoryNames, "", "", "");
                    brands = new Brands(extractor.Rules);
                    GetGroupData(DataGroup.ManufacturerNames, "", "", "");
                    options = new Options();
                    GetGroupData(DataGroup.Options, "", "", "");
                    catalog = new Catalog(extractor.Rules, false);
                    catalog.SetHeader(extraFields.Split(',').ToList(), customfields.GetUniqueNames());
                    break;
                case DataGroup.Sales:
                    sales = new Sales(extractor.Rules);
                    break;
                case DataGroup.Customers:
                    customers = new Customers(extractor.Rules);
                    break;
                case DataGroup.CategoryNames:
                    categories = new Categories(extractor.Rules);
                    break;
                case DataGroup.ManufacturerNames:
                    brands = new Brands(extractor.Rules);
                    break;
                case DataGroup.Inventory:
                    customfields = new CustomFields();
                    GetGroupData(DataGroup.Custom, "", "", "");
                    catalog = new Catalog(extractor.Rules, true);
                    catalog.SetHeader(extraFields.Split(',').ToList(), customfields.GetUniqueNames());
                    break;
            }
        }
        public void InitializeGroupData(DataGroup group, string extraFields, string startdate, string enddate)
        {
            FreeLocalStorage(false);

            switch (group)
            {
                case DataGroup.Catalog:
                    // Get customfields, categories and brands first to support catalog retrieval.
                    customfields = new CustomFields();
                    GetGroupData(DataGroup.Custom, "", "", "");
                    brands = new Brands(Rules);
                    GetGroupData(DataGroup.ManufacturerNames, "", "", "");
                    options = new Options();
                    GetGroupData(DataGroup.Options, "", "", "");
                    catalog = new Catalog(Rules, false);
                    catalog.SetHeader(extraFields.Split(',').ToList(), customfields.GetUniqueNames());
                    break;
                case DataGroup.Sales:
                    if (orderproducts == null)
                    {
                        orderproducts = new OrderProducts();
                        GetGroupData(DataGroup.OrderProducts, "", "", "");
                    }
                    sales = new Sales(Rules);
                    break;
                case DataGroup.Customers:
                    if (customeraddresses == null)
                    {
                        customeraddresses = new CustomerAddresses();
                        GetGroupData(DataGroup.CustomerAddresses, "", "", "");
                    }
                    customers = new Customers(Rules);
                    break;
                case DataGroup.CategoryNames:
                    categories = new Categories(Rules);
                    break;
                case DataGroup.ManufacturerNames:
                    brands = new Brands(Rules);
                    break;
                case DataGroup.Inventory:
                    catalog = new Catalog(Rules, true);
                    catalog.SetHeader(null, null);
                    break;
            }
        }