Пример #1
0
        static void SkusSync()
        {
            Console.WriteLine("--- Start to access Skus ---");

            List <Skus> dbSkus  = GetSkus();
            List <Skus> SkuList = new List <Skus>();
            List <Skus> Skus    = new List <Skus>();

            Company[] companyList = OS_sellerCloud.ListAllCompany(OS_authHeader, OS_options);
            foreach (Company company in companyList)
            {
                SkuList.AddRange(OCS_sellerCloud.Products_ListSKU(OCS_authHeader, company.ID).Select(s => new Skus()
                {
                    Sku = s
                }));
            }

            Console.WriteLine("--- Get <" + SkuList.Count() + "> skus from Sellercloud ---");
            Console.WriteLine("--- End to access Skus ---");

            IEnumerable <Skus> newSkus = SkuList.Except(dbSkus);
            int total = newSkus.Count();

            Console.WriteLine("--- There are <" + total + "> new skus ---");

            if (newSkus.Any())
            {
                int      start = 0, take = 100;
                string[] skuList = newSkus.Select(s => s.Sku).ToArray();
                do
                {
                    Console.WriteLine("--- Take new skus from " + (start + 1) + " to " + (start + take) + " ---");
                    Skus.AddRange(OS_sellerCloud.GetProductFullInfos(OS_authHeader, OS_options, skuList.Skip(start).Take(take).ToArray())
                                  .Select(p => DataProcess.SetSkuData(new Skus()
                    {
                        IsEnable = true, Sku = p.ID, Battery = false, ParentShadow = GetProductParent(p.ID)
                    }, p)));
                } while ((start += take) < total);

                DataProcess.BulkInsert(conn, "Skus", Skus);
            }
        }
Пример #2
0
 public ProductFullInfo[] Get_ProductFullInfos(string[] SKUs)
 {
     return(OS_SellerCloud.GetProductFullInfos(OS_AuthHeader, OS_Options, SKUs));
 }