public void GetEntity(DataGroup group, JObject entity)
        {
            switch (group)
            {
                case DataGroup.Catalog:
                case DataGroup.Inventory:
                    //{
                    //  "product": {
                    //    "id": 632910392,
                    //    "title": "IPod Nano - 8GB",
                    //    "body_html": "<p>It's the small iPod with one very big idea: Video. Now the world's most popular music player, available in 4GB and 8GB models, lets you enjoy TV shows, movies, video podcasts, and more. The larger, brighter display means amazing picture quality. In six eye-catching colors, iPod nano is stunning all around. And with models starting at just $149, little speaks volumes.<\/p>",
                    //    "vendor": "Apple",
                    //    "product_type": "Cult Products",
                    //    "created_at": "2015-09-02T14:50:32-04:00",
                    //    "handle": "ipod-nano",
                    //    "updated_at": "2015-09-02T14:50:32-04:00",
                    //    "published_at": "2007-12-31T19:00:00-05:00",
                    //    "template_suffix": null,
                    //    "published_scope": "web",
                    //    "tags": "Emotive, Flash Memory, MP3, Music",
                    //    "variants": [
                    //      {
                    //        "id": 808950810,
                    //        "product_id": 632910392,
                    //        "title": "Pink",
                    //        "sku": "IPOD2008PINK",
                    //        "position": 1,
                    //        "grams": 200,
                    //        "inventory_policy": "continue",
                    //        "fulfillment_service": "manual",
                    //        "inventory_management": "shopify",
                    //        "price": "199.00",
                    //        "compare_at_price": null,
                    //        "option1": "Pink",
                    //        "option2": null,
                    //        "option3": null,
                    //        "created_at": "2015-09-02T14:50:32-04:00",
                    //        "updated_at": "2015-09-02T14:50:32-04:00",
                    //        "taxable": true,
                    //        "requires_shipping": true,
                    //        "barcode": "1234_pink",
                    //        "inventory_quantity": 10,
                    //        "old_inventory_quantity": 10,
                    //        "image_id": 562641783,
                    //        "weight": 0.2,
                    //        "weight_unit": "kg"
                    //      }
                    //    ],
                    //    "options": [
                    //      {
                    //        "id": 594680422,
                    //        "product_id": 632910392,
                    //        "name": "Color",
                    //        "position": 1,
                    //        "values": [
                    //          "Pink",
                    //          "Red",
                    //          "Green",
                    //          "Black"
                    //        ]
                    //      }
                    //    ],
                    //    "images": [
                    //      {
                    //        "id": 850703190,
                    //        "product_id": 632910392,
                    //        "position": 1,
                    //        "created_at": "2015-09-02T14:50:32-04:00",
                    //        "updated_at": "2015-09-02T14:50:32-04:00",
                    //        "src": "https:\/\/cdn.shopify.com\/s\/files\/1\/0006\/9093\/3842\/products\/ipod-nano.png?v=1441219832",
                    //        "variant_ids": [
                    //        ]
                    //      },
                    //      {
                    //        "id": 562641783,
                    //        "product_id": 632910392,
                    //        "position": 2,
                    //        "created_at": "2015-09-02T14:50:32-04:00",
                    //        "updated_at": "2015-09-02T14:50:32-04:00",
                    //        "src": "https:\/\/cdn.shopify.com\/s\/files\/1\/0006\/9093\/3842\/products\/ipod-nano-2.png?v=1441219832",
                    //        "variant_ids": [
                    //          808950810
                    //        ]
                    //      }
                    //    ],
                    //    "image": {
                    //      "id": 850703190,
                    //      "product_id": 632910392,
                    //      "position": 1,
                    //      "created_at": "2015-09-02T14:50:32-04:00",
                    //      "updated_at": "2015-09-02T14:50:32-04:00",
                    //      "src": "https:\/\/cdn.shopify.com\/s\/files\/1\/0006\/9093\/3842\/products\/ipod-nano.png?v=1441219832",
                    //      "variant_ids": [
                    //      ]
                    //    }
                    //  }
                    //}
                    string _PIdName = extractor.Rules.Fields.GetName(FieldName.ProductId);
                    string _NameName = extractor.Rules.Fields.GetName(FieldName.Name);
                    string _Att1Name = extractor.Rules.UseDepartmentsAsCategories
                                                ? extractor.Rules.Fields.GetName(FieldName.Department)
                                                : extractor.Rules.Fields.GetName(FieldName.Att1Id);
                    string _Att2Name = extractor.Rules.Fields.GetName(FieldName.Att2Id);
                    string _PriceName = extractor.Rules.Fields.GetName(FieldName.Price);
                    string _SaleName = extractor.Rules.Fields.GetName(FieldName.SalePrice);
                    string _ListName = extractor.Rules.Fields.GetName(FieldName.ListPrice);
                    string _CostName = extractor.Rules.Fields.GetName(FieldName.Cost);
                    string _InvName = extractor.Rules.Fields.GetName(FieldName.Inventory);
                    string _VisName = extractor.Rules.Fields.GetName(FieldName.Visible);
                    string _LinkName = extractor.Rules.Fields.GetName(FieldName.Link);
                    string _ImagName = extractor.Rules.Fields.GetName(FieldName.ImageLink);
                    string _RateName = extractor.Rules.Fields.GetName(FieldName.Rating);
                    string _ParentIdName = extractor.Rules.Fields.GetName(FieldName.ParentId);
                    string _CodeName = extractor.Rules.Fields.GetName(FieldName.StandardCode);

                    Catalog.Entry entry = new Catalog.Entry();

                    try
                    {
                        // Standard Fields
                        entry.ProductID = entity.SelectToken(_PIdName).ToString();
                        entry.Name = entity.SelectToken(_NameName).ToString();
                        foreach (var collection in collections)
                        {
                            if (collection.ProductID.Equals(entry.ProductID))
                                entry.AddCategory(collection.CollectionID);
                        }
                        entry.ManufacturerID = entity.SelectToken(_Att2Name) == null ? "" : entity.SelectToken(_Att2Name).ToString();
                        entry.Visible = entity.SelectToken(_VisName) == null ? 0 : 1;
                        string plink = entity.SelectToken(_LinkName).ToString();
                        if (shopname.Contains(".myshopify.com"))
                            plink = "http://" + shopname + "/products/" + plink;
                        else
                            plink = "http://" + shopname + ".myshopify.com/products/" + plink;
                        entry.Link = plink.Replace(' ', '-');

                        if (entity.SelectToken("image") == null != null)
                            if (entity.SelectToken(_ImagName) != null)
                                entry.Imagelink = entity.SelectToken(_ImagName).ToString();

                        // Extra Fields
                        foreach (string extraFieldName in catalog.extraFieldNames)
                            if (extraFieldName != "")
                                entry.ExtraFields.Add(entity.SelectToken(extraFieldName) == null ? "" : entity.SelectToken(extraFieldName).ToString());
                    }
                    catch (RuntimeBinderException e)
                    {
                        //throw;
                    }

                    catalog.AddEntry(entry);

                    // Now get product options as children
                    JArray variants = (JArray)entity.SelectToken("variants");
                    foreach (JObject variant in variants)
                    {
                        try
                        {
                            Catalog.Entry childEntry = new Catalog.Entry();

                            // Standard Fields
                            childEntry.ProductID = variant.SelectToken(_PIdName).ToString();
                            childEntry.Price = variant.SelectToken(_PriceName).ToString();
                            childEntry.ParentProductID = entry.ProductID;
                            childEntry.StandardCode = variant.SelectToken(_CodeName).ToString();
                            childEntry.Inventory = variant.SelectToken(_InvName).ToString();
                            childEntry.ManufacturerID = variant.SelectToken(_Att2Name) == null ? "" : variant.SelectToken(_Att2Name).ToString();
                            childEntry.Visible = entry.Visible;
                            childEntry.Name = variant.SelectToken(_NameName) + " " + entry.Name;

                            // Extra Fields
                            foreach (string extraFieldName in catalog.extraFieldNames)
                                if (extraFieldName != "")
                                    entry.ExtraFields.Add("");

                            catalog.AddEntry(childEntry);
                        }
                        catch (RuntimeBinderException e)
                        {
                            //throw;
                        }
                    }
                    break;
                case DataGroup.Sales:
                    //{
                    //"id": 450789469,
                    //"email": "*****@*****.**",
                    //"closed_at": null,
                    //"created_at": "2008-01-10T11:00:00-05:00",
                    //"updated_at": "2008-01-10T11:00:00-05:00",
                    //"number": 1,
                    //"note": null,
                    //"token": "b1946ac92492d2347c6235b4d2611184",
                    //"gateway": "authorize_net",
                    //"test": false,
                    //"total_weight": 0,
                    //"taxes_included": false,
                    //"currency": "USD",
                    //"financial_status": "authorized",
                    //"confirmed": false,
                    //"cart_token": "68778783ad298f1c80c3bafcddeea02f",
                    //"buyer_accepts_marketing": false,
                    //"name": "#1001",
                    //"total_line_items_price": "398.00",
                    //"total_price": "409.94",
                    //"subtotal_price": "398.00",
                    //"total_tax": "11.94",
                    //"total_discounts": "0.00",
                    //"referring_site": "http:\/\/www.otherexample.com",
                    //"landing_site": "http:\/\/www.example.com?source=abc",
                    //"cancelled_at": null,
                    //"cancel_reason": null,
                    //"total_price_usd": "409.94",
                    //"checkout_token": null,
                    //"reference": "fhwdgads",
                    //"user_id": null,
                    //"location_id": null,
                    //"source_identifier": "fhwdgads",
                    //"source_url": null,
                    //"processed_at": "2008-01-10T11:00:00-05:00",
                    //"device_id": null,
                    //"browser_ip": null,
                    //"landing_site_ref": "abc",
                    //"order_number": 1001,
                    //"line_items": [
                    //  {
                    //    "id": 466157049,
                    //    "variant_id": 39072856,
                    //    "title": "IPod Nano - 8gb",
                    //    "quantity": 1,
                    //    "grams": 200,
                    //    "sku": "IPOD2008GREEN",
                    //    "variant_title": "green",
                    //    "vendor": null,
                    //    "fulfillment_service": "manual",
                    //    "price": "199.00",
                    //    "product_id": 632910392,
                    //    "taxable": true,
                    //    "requires_shipping": true,
                    //    "gift_card": false,
                    //    "name": "IPod Nano - 8gb - green",
                    //    "variant_inventory_management": "shopify",
                    //    "properties": [
                    //      {
                    //        "name": "Custom Engraving Front",
                    //        "value": "Happy Birthday"
                    //      },
                    //      {
                    //        "name": "Custom Engraving Back",
                    //        "value": "Merry Christmas"
                    //      }
                    //    ],
                    //    "product_exists": true,
                    //    "fulfillable_quantity": 1,
                    //    "total_discount": "0.00",
                    //    "fulfillment_status": null,
                    //    "tax_lines": [
                    //    ]
                    //  },
                    //],
                    //"customer": {
                    //  "id": 207119551,
                    //  "email": "*****@*****.**",
                    //  "accepts_marketing": false,
                    //  "created_at": "2015-09-02T14:48:56-04:00",
                    //  "updated_at": "2015-09-02T14:48:56-04:00",
                    //  "first_name": "Bob",
                    //  "last_name": "Norman",
                    //  "orders_count": 1,
                    //  "state": "disabled",
                    //  "total_spent": "41.94",
                    //  "last_order_id": 450789469,
                    //  "note": null,
                    //  "verified_email": true,
                    //  "multipass_identifier": null,
                    //  "tax_exempt": false,
                    //  "tags": "",
                    //  "last_order_name": "#1001",
                    //  "default_address": {
                    //    "id": 207119551,
                    //    "first_name": null,
                    //    "last_name": null,
                    //    "company": null,
                    //    "address1": "Chestnut Street 92",
                    //    "address2": "",
                    //    "city": "Louisville",
                    //    "province": "Kentucky",
                    //    "country": "United States",
                    try
                    {
                        string orderId = entity.SelectToken(extractor.Rules.Fields.GetName(FieldName.OrderId)).ToString();
                        string customerId = entity.SelectToken(extractor.Rules.Fields.GetName(FieldName.OrderCustomerId)).ToString();
                        DateTime temp = Convert.ToDateTime(entity.SelectToken(extractor.Rules.Fields.GetName(FieldName.OrderDate)).ToString());
                        string _OrderProductIdName = extractor.Rules.Fields.GetName(FieldName.OrderProductId);
                        string _OrderQuantityName = extractor.Rules.Fields.GetName(FieldName.OrderQuantity);

                        JArray Products = JArray.Parse(entity.SelectToken("line_items").ToString());
                        foreach (JObject product in Products)
                        {
                            Sale s = new Sale();

                            s.ProductID = product.SelectToken(_OrderProductIdName).ToString();
                            s.Quantity = product.SelectToken(_OrderQuantityName).ToString();
                            s.OrderID = orderId;
                            s.CustomerID = customerId;
                            s.Date = temp.ToShortDateString();

                            sales.AddSale(s);
                        }
                    }
                    catch (RuntimeBinderException e)
                    {
                        //throw;
                    }
                    break;
                case DataGroup.Customers:
                    // {
                    //  "id": 207119551,
                    //  "email": "*****@*****.**",
                    //  "accepts_marketing": false,
                    //  "created_at": "2015-09-02T14:52:15-04:00",
                    //  "updated_at": "2015-09-02T14:52:15-04:00",
                    //  "first_name": "Bob",
                    //  "last_name": "Norman",
                    //  "orders_count": 1,
                    //  "state": "disabled",
                    //  "total_spent": "41.94",
                    //  "last_order_id": 450789469,
                    //  "note": null,
                    //  "verified_email": true,
                    //  "multipass_identifier": null,
                    //  "tax_exempt": false,
                    //  "tags": "",
                    //  "last_order_name": "#1001",
                    //  "default_address": {
                    //    "id": 207119551,
                    //    "first_name": null,
                    //    "last_name": null,
                    //    "company": null,
                    //    "address1": "Chestnut Street 92",
                    //    "address2": "",
                    //    "city": "Louisville",
                    //    "province": "Kentucky",
                    //    "country": "United States",
                    //    "zip": "40202",
                    //    "phone": "555-625-1199",
                    //    "name": "",
                    //    "province_code": "KY",
                    //    "country_code": "US",
                    //    "country_name": "United States",
                    //    "default": true
                    //  },
                    //  "addresses": [
                    //    {
                    //      "id": 207119551,
                    //      "first_name": null,
                    //      "last_name": null,
                    //      "company": null,
                    //      "address1": "Chestnut Street 92",
                    //      "address2": "",
                    //      "city": "Louisville",
                    //      "province": "Kentucky",
                    //      "country": "United States",
                    //      "zip": "40202",
                    //      "phone": "555-625-1199",
                    //      "name": "",
                    //      "province_code": "KY",
                    //      "country_code": "US",
                    //      "country_name": "United States",
                    //      "default": true
                    //    }
                    //  ]
                    //}
                    Customer c = new Customer();
                    try
                    {
                        c.CustomerID = entity.SelectToken(extractor.Rules.Fields.GetName(FieldName.CustomerId)).ToString();
                        c.Email = entity.SelectToken("email").ToString();
                        c.Name = entity.SelectToken("first_name").ToString() + " " + entity.SelectToken("last_name").ToString();
                        c.Address = entity.SelectToken("default_address.address1").ToString() + "\n" + entity.SelectToken("default_address.address2").ToString();
                        c.City = entity.SelectToken("default_address.city").ToString();
                        c.State = entity.SelectToken("default_address.province").ToString();
                        c.PostalCode = entity.SelectToken("default_address.zip").ToString();
                        c.Country = entity.SelectToken("default_address.country").ToString();
                        c.Phone = entity.SelectToken("default_address.phone").ToString();
                        c.Gender = "";
                        c.Birthday = "";
                        c.AgeRange = "";
                        c.AlternativeIDs = "";
                        c.DoNotTrack = "";
                    }
                    catch (RuntimeBinderException e)
                    {
                        //throw;
                    }
                    customers.AddCustomer(c);
                    break;
                case DataGroup.Custom:
                    // "collects": [
                    //  {
                    //    "id": 395646240,
                    //    "collection_id": 395646240,
                    //    "product_id": 632910392,
                    //    "featured": false,
                    //    "created_at": null,
                    //    "updated_at": null,
                    //    "position": 1,
                    //    "sort_value": "0000000001"
                    //  },
                    //]
                    try
                    {
                        collections.Add(new ColLink(entity.SelectToken("collection_id").ToString(), entity.SelectToken("product_id").ToString()));
                    }
                    catch (RuntimeBinderException e)
                    {
                        //throw;
                    }
                    break;
                case DataGroup.CategoryNames:
                case DataGroup.Options:
                    // "custom_collection": {
                    //  "id": 841564295,
                    //  "handle": "ipods",
                    //  "title": "IPods",
                    //  "updated_at": "2008-02-01T19:00:00-05:00",
                    //  "body_html": "<p>The best selling ipod ever<\/p>",
                    //  "published_at": "2008-02-01T19:00:00-05:00",
                    //  "sort_order": "manual",
                    //  "template_suffix": null,
                    //  "products_count": 1,
                    //  "published_scope": "global",
                    //  "image": {
                    //    "created_at": "2015-09-02T14:48:56-04:00",
                    //    "src": "https:\/\/cdn.shopify.com\/s\/files\/1\/0006\/9093\/3842\/collections\/ipod_nano_8gb.jpg?v=1441219736"
                    //  }
                    //}

                    //"smart_collections": [
                    //{
                    //  "id": 482865238,
                    //  "handle": "smart-ipods",
                    //  "title": "Smart iPods",
                    //  "updated_at": "2008-02-01T19:00:00-05:00",
                    //  "body_html": "<p>The best selling ipod ever<\/p>",
                    //  "published_at": "2008-02-01T19:00:00-05:00",
                    //  "sort_order": "manual",
                    //  "template_suffix": null,
                    //  "published_scope": "global",
                    //  "disjunctive": false,
                    //  "rules": [
                    //    {
                    //      "column": "type",
                    //      "relation": "equals",
                    //      "condition": "Cult Products"
                    //    }
                    //  ],
                    //  "image": {
                    //    "created_at": "2015-10-27T15:26:33-04:00",
                    //    "src": "https:\/\/cdn.shopify.com\/s\/files\/1\/0006\/9093\/3842\/collections\/ipod_nano_8gb.jpg?v=1445973993"
                    //  }
                    try
                    {
                        categories.AddCategory(entity.SelectToken(extractor.Rules.Fields.GetName(FieldName.Att1NameId)).ToString(), entity.SelectToken(extractor.Rules.Fields.GetName(FieldName.Att1NameName)).ToString());
                    }
                    catch (RuntimeBinderException e)
                    {
                        //throw;
                    }
                    break;
                case DataGroup.DepartmentNames:
                case DataGroup.All:
                    break;
                default:
                    throw new ArgumentOutOfRangeException("group");
            }
        }
        public void GetEntity(DataGroup group, JObject entity)
        {
            switch (group)
            {
                case DataGroup.Catalog:
                case DataGroup.Inventory:
                    //{
                    //  "id": 32,
                    //  "keyword_filter": null,
                    //  "name": "[Sample] Tomorrow is today, Red printed scarf",
                    //  "type": "physical",
                    //  "sku": "",
                    //  "description": "Densely pack your descriptions with useful information and watch products fly off the shelf.",
                    //  "search_keywords": null,
                    //  "availability_description": "",
                    //  "price": "89.0000",
                    //  "cost_price": "0.0000",
                    //  "retail_price": "0.0000",
                    //  "sale_price": "0.0000",
                    //  "calculated_price": "89.0000",
                    //  "sort_order": 0,
                    //  "is_visible": true,
                    //  "is_featured": true,
                    //  "related_products": "-1",
                    //  "inventory_level": 0,
                    //  "inventory_warning_level": 0,
                    //  "warranty": null,
                    //  "weight": "0.3000",
                    //  "width": "0.0000",
                    //  "height": "0.0000",
                    //  "depth": "0.0000",
                    //  "fixed_cost_shipping_price": "10.0000",
                    //  "is_free_shipping": false,
                    //  "inventory_tracking": "none",
                    //  "rating_total": 0,
                    //  "rating_count": 0,
                    //  "total_sold": 0,
                    //  "date_created": "Fri, 21 Sep 2012 02:31:01 +0000",
                    //  "brand_id": 17,
                    //  "view_count": 4,
                    //  "page_title": "",
                    //  "meta_keywords": null,
                    //  "meta_description": null,
                    //  "layout_file": "product.html",
                    //  "is_price_hidden": false,
                    //  "price_hidden_label": "",
                    //  "categories": [
                    //    14
                    //  ],
                    //  "date_modified": "Mon, 24 Sep 2012 01:34:57 +0000",
                    //  "event_date_field_name": "Delivery Date",
                    //  "event_date_type": "none",
                    //  "event_date_start": "",
                    //  "event_date_end": "",
                    //  "myob_asset_account": "",
                    //  "myob_income_account": "",
                    //  "myob_expense_account": "",
                    //  "peachtree_gl_account": "",
                    //  "condition": "New",
                    //  "is_condition_shown": false,
                    //  "preorder_release_date": "",
                    //  "is_preorder_only": false,
                    //  "preorder_message": "",
                    //  "order_quantity_minimum": 0,
                    //  "order_quantity_maximum": 0,
                    //  "open_graph_type": "product",
                    //  "open_graph_title": "",
                    //  "open_graph_description": null,
                    //  "is_open_graph_thumbnail": true,
                    //  "upc": null,
                    //  "avalara_product_tax_code": "",
                    //  "date_last_imported": "",
                    //  "option_set_id": null,
                    //  "tax_class_id": 0,
                    //  "option_set_display": "right",
                    //  "bin_picking_number": "",
                    //  "custom_url": "/tomorrow-is-today-red-printed-scarf/",
                    //  "primary_image": {
                    //    "id": 247,
                    //    "zoom_url": "https://cdn.url.path/bcapp/et7xe3pz/products/32/images/247/in_123__14581.1393831046.1280.1280.jpg?c=1",
                    //    "thumbnail_url": "https://cdn.url.path/bcapp/et7xe3pz/products/32/images/247/in_123__14581.1393831046.220.290.jpg?c=1",
                    //    "standard_url": "https://cdn.url.path/bcapp/et7xe3pz/products/32/images/247/in_123__14581.1393831046.386.513.jpg?c=1",
                    //    "tiny_url": "https://cdn.url.path/bcapp/et7xe3pz/products/32/images/247/in_123__14581.1393831046.44.58.jpg?c=1"
                    //  },
                    //  "availability": "available",
                    //  "brand": {
                    //    "url": "https://store-et7xe3pz.mybigcommerce.com/api/v2/brands/17.json",
                    //    "resource": "/brands/17"
                    //  },
                    //  "images": {
                    //    "url": "https://store-et7xe3pz.mybigcommerce.com/api/v2/products/32/images.json",
                    //    "resource": "/products/32/images"
                    //  },
                    //  "discount_rules": {
                    //    "url": "https://store-et7xe3pz.mybigcommerce.com/api/v2/products/32/discountrules.json",
                    //    "resource": "/products/32/discountrules"
                    //  },
                    //  "configurable_fields": {
                    //    "url": "https://store-et7xe3pz.mybigcommerce.com/api/v2/products/32/configurablefields.json",
                    //    "resource": "/products/32/configurablefields"
                    //  },
                    //  "custom_fields": {
                    //    "url": "https://store-et7xe3pz.mybigcommerce.com/api/v2/products/32/customfields.json",
                    //    "resource": "/products/32/customfields"
                    //  },
                    //  "videos": {
                    //    "url": "https://store-et7xe3pz.mybigcommerce.com/api/v2/products/32/videos.json",
                    //    "resource": "/products/32/videos"
                    //  },
                    //  "skus": {
                    //    "url": "https://store-et7xe3pz.mybigcommerce.com/api/v2/products/32/skus.json",
                    //    "resource": "/products/32/skus"
                    //  },
                    //  "rules": {
                    //    "url": "https://store-et7xe3pz.mybigcommerce.com/api/v2/products/32/rules.json",
                    //    "resource": "/products/32/rules"
                    //  },
                    //  "option_set": null,
                    //  "options": {
                    //    "url": "https://store-et7xe3pz.mybigcommerce.com/api/v2/products/32/options.json",
                    //    "resource": "/products/32/options"
                    //  },
                    //  "tax_class": {
                    //    "url": "https://store-et7xe3pz.mybigcommerce.com/api/v2/taxclasses/0.json",
                    //    "resource": "/taxclasses/0"
                    //  }
                    //}
                    string _PIdName = extractor.Rules.Fields.GetName(FieldName.ProductId);
                    string _NameName = extractor.Rules.Fields.GetName(FieldName.Name);
                    string _Att1Name = extractor.Rules.UseDepartmentsAsCategories
                                                ? extractor.Rules.Fields.GetName(FieldName.Department)
                                                : extractor.Rules.Fields.GetName(FieldName.Att1Id);
                    string _Att2Name = extractor.Rules.Fields.GetName(FieldName.Att2Id);
                    string _PriceName = extractor.Rules.Fields.GetName(FieldName.Price);
                    string _SaleName = extractor.Rules.Fields.GetName(FieldName.SalePrice);
                    string _ListName = extractor.Rules.Fields.GetName(FieldName.ListPrice);
                    string _CostName = extractor.Rules.Fields.GetName(FieldName.Cost);
                    string _InvName = extractor.Rules.Fields.GetName(FieldName.Inventory);
                    string _VisName = extractor.Rules.Fields.GetName(FieldName.Visible);
                    string _LinkName = extractor.Rules.Fields.GetName(FieldName.Link);
                    string _ImagName = extractor.Rules.Fields.GetName(FieldName.ImageLink);
                    string _RateName = extractor.Rules.Fields.GetName(FieldName.Rating);
                    string _ParentIdName = extractor.Rules.Fields.GetName(FieldName.ParentId);
                    string _CodeName = extractor.Rules.Fields.GetName(FieldName.StandardCode);

                    Catalog.Entry entry = new Catalog.Entry();

                    try
                    {
                        // Standard Fields
                        entry.ProductID = entity.SelectToken(_PIdName).ToString();
                        entry.Name = entity.SelectToken(_NameName).ToString();
                        JArray categoryIds = (JArray)entity.SelectToken(_Att1Name);
                        foreach (JValue categoryId in categoryIds)
                            entry.AddCategory(categoryId.ToString());
                        string brand = "";
                        if (brands != null && brands.d.TryGetValue(entity.SelectToken(_Att2Name).ToString(), out brand))
                            entry.ManufacturerID = brand;
                        entry.Visible = (int)entity.SelectToken(_VisName);
                        entry.Link = entity.SelectToken(_LinkName).ToString();
                        entry.Imagelink = entity.SelectToken(_ImagName).ToString();
                        entry.Price = entity.SelectToken(_PriceName).ToString();
                        entry.SalePrice = entity.SelectToken(_SaleName).ToString();
                        entry.ListPrice = entity.SelectToken(_ListName).ToString();
                        entry.Cost = entity.SelectToken(_CostName).ToString();
                        entry.Inventory = entity.SelectToken(_InvName).ToString();
                        entry.Rating = entity.SelectToken(_RateName).ToString();
                        entry.StandardCode = entity.SelectToken(_CodeName).ToString();

                        // Extra Fields
                        foreach (string extraFieldName in catalog.extraFieldNames)
                            if (extraFieldName != "")
                                entry.ExtraFields.Add(entity.SelectToken(extraFieldName) == null ? "" : entity.SelectToken(extraFieldName).ToString());

                        // Custom Fields
                        // walk the column names and for each determine whether the product at hand has one of these custom field, if so post it's value in the position corresponding to the index of name in customFieldNames
                        bool found = false;
                        foreach (string customFileName in catalog.customFieldNames)
                        {
                            found = false;
                            foreach (CustomField field in customfields.fields)
                            {
                                // see if there's a customfield for this product and it matches the custom field we're on
                                if (field.ProductID == entry.ProductID && field.Name == customFileName)
                                {
                                    found = true;
                                    entry.CustomFields.Add(field.Value);
                                    break;
                                }
                            }
                            if (found == false)
                                entry.CustomFields.Add("");
                        }
                    }
                    catch (RuntimeBinderException e)
                    {
                        //throw;
                    }

                    catalog.AddEntry(entry);

                    // Now get product options as children
                    List<Option> productOptions = options.GetProductOptions(entry.ProductID);
                    foreach (Option option in productOptions)
                    {
                        try
                        {
                            Catalog.Entry childEntry = new Catalog.Entry();

                            // Standard Fields
                            childEntry.ProductID = option.ChildID;
                            if (option.PriceType == "absolute")
                                childEntry.Price = option.Price;
                            else
                            {
                                Single ePrice = 0.0f;
                                Single oPrice = 0.0f;
                                if (!Single.TryParse(entry.Price, out ePrice))
                                    throw new FormatException("Number format not supported");
                                if (!Single.TryParse(option.Price, out oPrice))
                                    throw new FormatException("Number format not supported");
                                childEntry.Price = (ePrice + oPrice).ToString();
                            }
                            childEntry.ParentProductID = option.ProductID;

                            // Extra Fields
                            foreach (string extraFieldName in catalog.extraFieldNames)
                                if (extraFieldName != "")
                                    entry.ExtraFields.Add("");

                            // Custom Fields
                            // walk the column names and for each determine whether the product at hand has one of these custom field, if so post it's value in the position corresponding to the index of name in customFieldNames
                            foreach (string customFileName in catalog.customFieldNames)
                                entry.CustomFields.Add("");

                            catalog.AddEntry(childEntry);
                        }
                        catch (RuntimeBinderException e)
                        {
                            //throw;
                        }
                    }
                    break;
                case DataGroup.Sales:
                    //[
                    //  {
                    //    "id": 100,
                    //    "customer_id": 10,
                    //    "date_created": "Wed, 14 Nov 2012 19:26:23 +0000",
                    //    "date_modified": "Wed, 14 Nov 2012 19:26:23 +0000",
                    //    "date_shipped": "",
                    //    "status_id": 11,
                    //    "status": "Awaiting Fulfillment",
                    //    "subtotal_ex_tax": "79.0000",
                    //    "subtotal_inc_tax": "79.0000",
                    //    "subtotal_tax": "0.0000",
                    //    "base_shipping_cost": "0.0000",
                    //    "shipping_cost_ex_tax": "0.0000",
                    //    "shipping_cost_inc_tax": "0.0000",
                    //    "shipping_cost_tax": "0.0000",
                    //    "shipping_cost_tax_class_id": 2,
                    //    "base_handling_cost": "0.0000",
                    //    "handling_cost_ex_tax": "0.0000",
                    //    "handling_cost_inc_tax": "0.0000",
                    //    "handling_cost_tax": "0.0000",
                    //    "handling_cost_tax_class_id": 2,
                    //    "base_wrapping_cost": "0.0000",
                    //    "wrapping_cost_ex_tax": "0.0000",
                    //    "wrapping_cost_inc_tax": "0.0000",
                    //    "wrapping_cost_tax": "0.0000",
                    //    "wrapping_cost_tax_class_id": 3,
                    //    "total_ex_tax": "79.0000",
                    //    "total_inc_tax": "79.0000",
                    //    "total_tax": "0.0000",
                    //    "items_total": 1,
                    //    "items_shipped": 0,
                    //    "payment_method": "cash",
                    //    "payment_provider_id": null,
                    //    "payment_status": "",
                    //    "refunded_amount": "0.0000",
                    //    "order_is_digital": false,
                    //    "store_credit_amount": "0.0000",
                    //    "gift_certificate_amount": "0.0000",
                    //    "ip_address": "50.58.18.2",
                    //    "geoip_country": "",
                    //    "geoip_country_iso2": "",
                    //    "currency_id": 1,
                    //    "currency_code": "USD",
                    //    "currency_exchange_rate": "1.0000000000",
                    //    "default_currency_id": 1,
                    //    "default_currency_code": "USD",
                    //    "staff_notes": "",
                    //    "customer_message": "",
                    //    "discount_amount": "0.0000",
                    //    "coupon_discount": "0.0000",
                    //    "shipping_address_count": 1,
                    //    "is_deleted": false,
                    //    "billing_address": {
                    //      "first_name": "Trisha",
                    //      "last_name": "McLaughlin",
                    //      "company": "",
                    //      "street_1": "12345 W Anderson Ln",
                    //      "street_2": "",
                    //      "city": "Austin",
                    //      "state": "Texas",
                    //      "zip": "78757",
                    //      "country": "United States",
                    //      "country_iso2": "US",
                    //      "phone": "",
                    //      "email": "*****@*****.**"
                    //    },
                    //    "products": {
                    //      "url": "https://store-bwvr466.mybigcommerce.com/api/v2/orders/100/products.json",
                    //      "resource": "/orders/100/products"
                    //    },
                    //    "shipping_addresses": {
                    //      "url": "https://store-bwvr466.mybigcommerce.com/api/v2/orders/100/shippingaddresses.json",
                    //      "resource": "/orders/100/shippingaddresses"
                    //    },
                    //    "coupons": {
                    //      "url": "https://store-bwvr466.mybigcommerce.com/api/v2/orders/100/coupons.json",
                    //      "resource": "/orders/100/coupons"
                    //    }
                    //  }
                    //]

                    // get the order id first, then retrieve products for it, use e.g. https://store-bwvr466.mybigcommerce.com/api/v2/orders/100/products.json

                    //{
                    //  "id": 16,
                    //  "order_id": 115,
                    //  "product_id": 0,
                    //  "order_address_id": 16,
                    //  "name": "Cynthia Gilbert Signature Collection",
                    //  "sku": "",
                    //  "type": "physical",
                    //  "base_price": "93.1800",
                    //  "price_ex_tax": "93.1800",
                    //  "price_inc_tax": "93.1800",
                    //  "price_tax": "0.0000",
                    //  "base_total": "93.1800",
                    //  "total_ex_tax": "93.1800",
                    //  "total_inc_tax": "93.1800",
                    //  "total_tax": "0.0000",
                    //  "weight": "0",
                    //  "quantity": 1,
                    //  "base_cost_price": "0.0000",
                    //  "cost_price_inc_tax": "0.0000",
                    //  "cost_price_ex_tax": "0.0000",
                    //  "cost_price_tax": "0.0000",
                    //  "is_refunded": false,
                    //  "refund_amount": "0.0000",
                    //  "return_id": 0,
                    //  "wrapping_name": "",
                    //  "base_wrapping_cost": "0.0000",
                    //  "wrapping_cost_ex_tax": "0.0000",
                    //  "wrapping_cost_inc_tax": "0.0000",
                    //  "wrapping_cost_tax": "0.0000",
                    //  "wrapping_message": "",
                    //  "quantity_shipped": 0,
                    //  "event_name": null,
                    //  "event_date": "",
                    //  "fixed_shipping_cost": "0.0000",
                    //  "ebay_item_id": "",
                    //  "ebay_transaction_id": "",
                    //  "option_set_id": null,
                    //  "parent_order_product_id": null,
                    //  "is_bundled_product ": false,
                    //  "bin_picking_number": "",
                    //  "applied_discounts": [
                    //    {
                    //      "id": "coupon",
                    //      "amount": 4.66
                    //    }
                    //  ],
                    //  "product_options": [
                    //  ],
                    //  "configurable_fields": [
                    //  ]
                    //}
                    //response = client.GetAsync("orders/" + orderId + "/products.json").Result;
                    //result = response.Content.ReadAsStringAsync().Result;
                    try
                    {
                        string orderId = entity.SelectToken(extractor.Rules.Fields.GetName(FieldName.OrderId)).ToString();
                        string customerId = entity.SelectToken(extractor.Rules.Fields.GetName(FieldName.OrderCustomerId)).ToString();
                        DateTime temp = Convert.ToDateTime(entity.SelectToken(extractor.Rules.Fields.GetName(FieldName.OrderDate)).ToString());
                        string _OrderProductIdName = extractor.Rules.Fields.GetName(FieldName.OrderProductId);
                        string _OrderQuantityName = extractor.Rules.Fields.GetName(FieldName.OrderQuantity);

                        queryResult = extractor.GetQueryResponse(group, "orders/" + orderId + "/products.json");
                        JArray Products = JArray.Parse(queryResult);
                        foreach (JObject product in Products)
                        {
                            Sale s = new Sale();

                            s.ProductID = product.SelectToken(_OrderProductIdName).ToString();
                            s.Quantity = product.SelectToken(_OrderQuantityName).ToString();
                            s.OrderID = orderId;
                            s.CustomerID = customerId;
                            s.Date = temp.ToShortDateString();

                            sales.AddSale(s);
                        }
                    }
                    catch (RuntimeBinderException e)
                    {
                        //throw;
                    }
                    break;
                case DataGroup.Customers:
                    //{
                    //  "id": 1,
                    //  "company": "",
                    //  "first_name": "Random ",
                    //  "last_name": "Joe Bob",
                    //  "email": "*****@*****.**",
                    //  "phone": "252-101-2010",
                    //  "date_created": "Tue, 13 Nov 2012 21:16:41 +0000",
                    //  "date_modified": "Tue, 13 Nov 2012 21:16:41 +0000",
                    //  "store_credit": "0.0000",
                    //  "registration_ip_address": "50.58.18.2",
                    //  "customer_group_id": 0,
                    //  "notes": "",
                    //  "tax_exempt_category": "",
                    //  "addresses": {
                    //    "url": "https://store-bwvr466.mybigcommerce.com/api/v2/customers/1/addresses.json",
                    //    "resource": "/customers/1/addresses"
                    //  }
                    //},
                    Customer c = new Customer();
                    try
                    {
                        //  {
                        //  "id": 1,
                        //  "customer_id": 10,
                        //  "first_name": "Trisha",
                        //  "last_name": "McLaughlin",
                        //  "company": "",
                        //  "street_1": "12345 W Anderson Ln",
                        //  "street_2": "",
                        //  "city": "Austin",
                        //  "state": "Texas",
                        //  "zip": "78757",
                        //  "country": "United States",
                        //  "country_iso2": "US",
                        //  "phone": ""
                        //}
                        //response = client.GetAsync("customers/" + customerId + "/addresses.json").Result;
                        //result = response.Content.ReadAsStringAsync().Result;
                        c.CustomerID = entity.SelectToken(extractor.Rules.Fields.GetName(FieldName.CustomerId)).ToString();
                        c.Email = entity.SelectToken("email").ToString();
                        c.Name = entity.SelectToken("first_name").ToString() + " " + entity.SelectToken("last_name").ToString();
                        // retrieve addresses for this customer and use the first one
                        queryResult = extractor.GetQueryResponse(group, "customers/" + c.CustomerID + "/addresses.json");
                        if (queryResult != "")
                        {
                            JArray Addresses = JArray.Parse(queryResult);
                            JObject firstAddress = (JObject)Addresses[0];

                            c.Address = firstAddress.SelectToken("street_1").ToString() + "\n" + firstAddress.SelectToken("street_2").ToString();
                            c.City = firstAddress.SelectToken("city").ToString();
                            c.State = firstAddress.SelectToken("state").ToString();
                            c.PostalCode = firstAddress.SelectToken("zip").ToString();
                            c.Country = firstAddress.SelectToken("country").ToString();
                            c.Phone = firstAddress.SelectToken("phone").ToString();
                        }
                        c.Gender = "";
                        c.Birthday = "";
                        c.AgeRange = "";
                        c.AlternativeIDs = "";
                        c.DoNotTrack = "";
                    }
                    catch (RuntimeBinderException e)
                    {
                        //throw;
                    }
                    customers.AddCustomer(c);
                    break;
                case DataGroup.Custom:
                    //{
                    //  "id": 1,
                    //  "product_id": 30,
                    //  "name": "Toy manufactured in",
                    //  "text": "USA"
                    //}
                    try
                    {
                        customfields.AddCustomField(entity.SelectToken("product_id").ToString(), entity.SelectToken("name").ToString(), entity.SelectToken("text").ToString());
                    }
                    catch (RuntimeBinderException e)
                    {
                        //throw;
                    }
                    break;
                case DataGroup.Options:
                    //    "url": "https://store-bwvr466.mybigcommerce.com/api/v2/products/rules.json",
                    //{
                    //      "id":120,
                    //      "product_id":61
                    //      "price_adjuster":{"adjuster":"absolute","adjuster_value":13.99},"
                    //},
                    try
                    {
                        if (entity.SelectToken("price_adjuster").ToString() != "")
                            options.AddOption(entity.SelectToken("id").ToString(), entity.SelectToken("product_id").ToString(), entity.SelectToken("price_adjuster.adjuster_value").ToString(), entity.SelectToken("price_adjuster.adjuster").ToString());
                    }
                    catch (RuntimeBinderException e)
                    {
                        //throw;
                    }
                    break;
                case DataGroup.CategoryNames:
                    // {
                    //  "id": 1,
                    //  "parent_id": 0,
                    //  "name": "Shop Mac",
                    //  "description": "",
                    //  "sort_order": 0,
                    //  "page_title": "",
                    //  "meta_keywords": "",
                    //  "meta_description": "",
                    //  "layout_file": "category.html",
                    //  "parent_category_list": [
                    //    1
                    //  ],
                    //  "image_file": "",
                    //  "is_visible": true,
                    //  "search_keywords": "",
                    //  "url": "/shop-mac/"
                    //}
                    try
                    {
                        categories.AddCategory(entity.SelectToken(extractor.Rules.Fields.GetName(FieldName.Att1NameId)).ToString(), entity.SelectToken(extractor.Rules.Fields.GetName(FieldName.Att1NameName)).ToString());
                    }
                    catch (RuntimeBinderException e)
                    {
                        //throw;
                    }
                    break;
                case DataGroup.ManufacturerNames:
                    //{
                    //  "id": 1,
                    //  "name": "Apple",
                    //  "page_title": "",
                    //  "meta_keywords": "",
                    //  "meta_description": "",
                    //  "image_file": "",
                    //  "search_keywords": ""
                    //},
                    try
                    {
                        brands.AddBrand(entity.SelectToken(extractor.Rules.Fields.GetName(FieldName.Att2NameId)).ToString(), entity.SelectToken(extractor.Rules.Fields.GetName(FieldName.Att2NameName)).ToString());
                    }
                    catch (RuntimeBinderException e)
                    {
                        //throw;
                    }
                    break;
                case DataGroup.DepartmentNames:
                case DataGroup.All:
                    break;
                default:
                    throw new ArgumentOutOfRangeException("group");
            }
        }
 public void AddCustomer(Customer c)
 {
     List<string> customer = new List<string>();
     customer.Add(c.CustomerID);
     customer.Add(c.Email);
     customer.Add(c.Name);
     customer.Add(c.Address);
     customer.Add(c.City);
     customer.Add(c.State);
     customer.Add(c.PostalCode);
     customer.Add(c.Country);
     customer.Add(c.Phone);
     customer.Add(c.Gender);
     customer.Add(c.Birthday);
     customer.Add(c.AgeRange);
     customer.Add(c.AlternativeIDs);
     customer.Add(c.DoNotTrack);
     output.Add(customer);
 }