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, 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;
            }
        }