Example #1
0
 /// <summary>
 /// Update variant (price)
 /// </summary>
 static public void UpdateVariantThread()
 {
     while (!AllGetQueueFilled || variantUpdateQueue.Count > 0)
     {
         ProductVariant p = null;
         // SQLDone can become true whithout adding anything to Queue
         if (variantUpdateQueue.TryDequeue(out p))
         {
             try
             {
                 if (p.Id == null)
                 {
                     NotFoundIdVariantUpdateQueue.Enqueue(p);
                 }
                 else
                 {
                     //var result = Task.Run(() => { return updateVariantService.UpdateAsync((long)p.Id, p); }).Result;
                 }
             }
             catch
             {
                 GeneralAdapter.OutputString($"This product was sent to check its Id {p.SKU}");
                 NotFoundIdVariantUpdateQueue.Enqueue(p);
             }
         }
     }
     variantUpdateDone = true;
     GeneralAdapter.OutputString("VariantUpdate Done.");
 }
Example #2
0
        /// <summary>
        /// Update variant (price)
        /// </summary>
        static public async Task UpdateVariantAsync()
        {
            while (!AllGetQueueFilled || variantUpdateQueue.Count > 0)
            {
                if (variantUpdateQueue.Count == 0)
                {
                    await Task.Delay(500);
                }

                ProductVariant p = null;
                // SQLDone can become true whithout adding anything to Queue
                if (variantUpdateQueue.TryDequeue(out p))
                {
                    try
                    {
                        if (p.Id == null)
                        {
                            NotFoundIdVariantUpdateQueue.Enqueue(p);
                        }
                        else
                        {
                            //var result = await updateVariantService.UpdateAsync((long)p.Id, p));
                            GeneralAdapter.OutputString(p.SKU + " Prix: " + p.Price + " Compare Var (rouge): " + p.CompareAtPrice);
                        }
                    }
                    catch
                    {
                        GeneralAdapter.OutputString($"This product was sent to check its Id {p.SKU}");
                        NotFoundIdVariantUpdateQueue.Enqueue(p);
                    }
                }
            }
            variantUpdateDone = true;
            GeneralAdapter.OutputString("VariantUpdate Done.");
        }
Example #3
0
 /// <summary>
 /// Update variant (price) and check Ids (update them in SAP). Use checkIdInventoryUpdateQueue, should check <see cref=ProductExport.variantDone></cref> before running
 /// </summary>
 static public void CheckIdInventoryUpdateThread()
 {
     while (!inventoryUpdateDone || NotFoundIdInventoryUpdateQueue.Count > 0)
     {
         InventoryLevel p = null;
         // SQLDone can become true whithout adding anything to Queue
         if (NotFoundIdInventoryUpdateQueue.TryDequeue(out p))
         {
             try
             {
                 if (GeneralAdapter.FindIdFromSku(p))
                 {
                     var result = Task.Run(() => { return(updateInventoryService.SetAsync(p)); }).Result;
                 }
                 else
                 {
                     GeneralAdapter.OutputString($"Couldn't find the SKU: {p.SKU}");
                 }
             }
             catch
             {
                 GeneralAdapter.OutputErrorString($"Couldn't resolve the inventory {p.Id} SKU: {p.SKU}");
             }
         }
     }
     checkIdInventoryDone = true;
     GeneralAdapter.OutputString("checkIdInventoryDone Done.");
 }
Example #4
0
 static public async Task NotFoundIdInventoryUpdateAsync()
 {
     while (!inventoryUpdateDone || NotFoundIdInventoryUpdateQueue.Count > 0)
     {
         if (NotFoundIdVariantUpdateQueue.Count == 0)
         {
             await Task.Delay(500);
         }
         InventoryLevel p = null;
         // SQLDone can become true whithout adding anything to Queue
         if (NotFoundIdInventoryUpdateQueue.TryDequeue(out p))
         {
             try
             {
                 if (GeneralAdapter.FindIdFromSku(p))
                 {
                     await updateInventoryService.SetAsync(p);
                 }
                 else
                 {
                     GeneralAdapter.OutputString($"Couldn't find the SKU: {p.SKU}");
                 }
             }
             catch
             {
                 GeneralAdapter.OutputString($"Couldn't resolve the inventory {p.Id} SKU: {p.SKU}");
             }
         }
     }
     checkIdInventoryDone = true;
     GeneralAdapter.OutputString("checkIdInventoryDone Done.");
 }
Example #5
0
 /// <summary>
 /// Update variant (price) and check Ids (update them in SAP). Use checkIdInventoryUpdateQueue, should check <see cref=ProductExport.variantDone></cref> before running
 /// </summary>
 static public void CheckIdUpdateVariantThread()
 {
     while (!variantUpdateDone || NotFoundIdVariantUpdateQueue.Count > 0)
     {
         ProductVariant p = null;
         // SQLDone can become true whithout adding anything to Queue
         if (NotFoundIdVariantUpdateQueue.TryDequeue(out p))
         {
             try
             {
                 if (GeneralAdapter.FindIdFromSku(p))
                 {
                     //TODO DI API
                     //var result = Task.Run(() => { return updateVariantService.UpdateAsync((long)p.Id, p); }).Result;
                 }
                 else
                 {
                     GeneralAdapter.OutputString($"Couldn't find the SKU: {p.SKU}");
                 }
             }
             catch
             {
                 GeneralAdapter.OutputErrorString($"Couldn't resolve the variant {p.Id} SKU: {p.SKU}");
             }
         }
     }
     checkIdVariantDone = true;
     GeneralAdapter.OutputString("checkIdVariantDone Done.");
 }
Example #6
0
 static public async Task NotFoundIdUpdateVariantAsync()
 {
     while (!variantUpdateDone || NotFoundIdVariantUpdateQueue.Count > 0)
     {
         if (NotFoundIdVariantUpdateQueue.Count == 0)
         {
             await Task.Delay(500);
         }
         ProductVariant p = null;
         // SQLDone can become true whithout adding anything to Queue
         if (NotFoundIdVariantUpdateQueue.TryDequeue(out p))
         {
             try
             {
                 if (GeneralAdapter.FindIdFromSku(p))
                 {
                     //TODO DI API
                     //await updateVariantService.UpdateAsync((long)p.Id, p);
                 }
                 else
                 {
                     GeneralAdapter.OutputString($"Couldn't find the SKU: {p.SKU}");
                 }
             }
             catch
             {
                 GeneralAdapter.OutputErrorString($"Couldn't resolve the variant {p.Id} SKU: {p.SKU}");
             }
         }
     }
     checkIdVariantDone = true;
     GeneralAdapter.OutputString("checkIdVariantDone Done.");
 }
Example #7
0
 static public void UpdateInventoryThread()
 {
     while (!AllGetQueueFilled || inventoryUpdateQueue.Count > 0)
     {
         InventoryLevel p;
         if (inventoryUpdateQueue.TryDequeue(out p))
         {
             try
             {
                 if (p.InventoryItemId == null)
                 {
                     NotFoundIdInventoryUpdateQueue.Enqueue(p);
                 }
                 else
                 {
                     var result = Task.Run(() => { return(updateInventoryService.SetAsync(p)); }).Result;
                 }
             }
             catch
             {
                 GeneralAdapter.OutputString($"This product was sent to check its Id {p.SKU}");
                 NotFoundIdInventoryUpdateQueue.Enqueue(p);
             }
         }
     }
     inventoryUpdateDone = true;
     GeneralAdapter.OutputString("inventoryUpdate Done.");
 }
Example #8
0
 static public async Task UpdateInventoryAsync()
 {
     while (!AllGetQueueFilled || inventoryUpdateQueue.Count > 0)
     {
         if (inventoryUpdateQueue.Count == 0)
         {
             await Task.Delay(500);
         }
         InventoryLevel p;
         if (inventoryUpdateQueue.TryDequeue(out p))
         {
             try
             {
                 if (p.InventoryItemId == null)
                 {
                     NotFoundIdInventoryUpdateQueue.Enqueue(p);
                 }
                 else
                 {
                     var result = await updateInventoryService.SetAsync(p);
                 }
             }
             catch
             {
                 GeneralAdapter.OutputString($"This product was sent to check its Id {p.SKU}");
                 NotFoundIdInventoryUpdateQueue.Enqueue(p);
             }
         }
     }
     inventoryUpdateDone = true;
     GeneralAdapter.OutputString("inventoryUpdate Done.");
 }
Example #9
0
        /// <summary>
        /// Thread versuib of Get product. Get ll products in Shopify
        /// </summary>
        public static void GetProductThread()
        {
            int           total = Task.Run(() => { return(getProductService.CountAsync()); }).Result;
            int           pages = (int)Math.Ceiling(total / (decimal)limit);
            ProductFilter pf    = new ProductFilter()
            {
                Limit = limit
            };

            for (int i = 1; i <= pages; i++)
            {
                pf.Page = i;
                productQueue.AddRange(Task.Run(() => { return(getProductService.ListAsync(pf)); }).Result);
            }
            productDone = true;
            GeneralAdapter.OutputString("GetProductThread done.");
        }
Example #10
0
        static public async Task UpdateMetafieldsAsync()
        {
            while (!AllGetQueueFilled || metafieldUpdateQueue.Count > 0)
            {
                if (metafieldUpdateQueue.Count == 0)
                {
                    await Task.Delay(500);
                }

                MetaField p = null;
                // SQLDone can become true whithout adding anything to Queue
                if (metafieldUpdateQueue.TryDequeue(out p))
                {
                    try
                    {
                        //var result = await updateMetafieldService.UpdateAsync((long)p.OwnerId, p);
                        var result = await updateMetafieldService.CreateAsync(p);

                        //GeneralAdapter.OutputString(result.ToString());
                    }
                    catch (Exception e)
                    {
                        /*
                         * try
                         * {*/
                        GeneralAdapter.OutputString($"{e.Message}");

                        /*
                         * var result = await updateMetafieldService.CreateAsync(p);
                         * GeneralAdapter.OutputString(result.ToString());*/
                        /*
                         * }
                         * catch (Exception e2)
                         * {
                         * GeneralAdapter.OutputString(e2.Message);
                         * }*/
                    }
                }
            }
            metafieldUpdateDone = true;
            GeneralAdapter.OutputString("metafieldUpdate Done.");
        }
Example #11
0
        /// <summary>
        /// Async Version of GetProduct. Get all products in Shopify
        /// </summary>
        public static async Task GetProductAsync()
        {
            int total = await getProductService.CountAsync();

            int           pages = (int)Math.Ceiling(total / (decimal)limit);
            ProductFilter pf    = new ProductFilter()
            {
                Limit = limit
            };

            for (int i = 1; i <= pages; i++)
            {
                pf.Page = i;
                var result = await getProductService.ListAsync(pf);

                productQueue.AddRange(result);
            }
            productDone = true;
            GeneralAdapter.OutputString("GetProductThread done.");
        }
Example #12
0
        /// <summary>
        /// Get Variants from productQueue
        /// </summary>
        public static void GetVariantThread()
        {
            variantList = new List <ProductVariant>();
            int iter = 0;

            while (!productDone || productQueue.Count > 0)
            {
                Product p = null;
                if (productQueue.TryDequeue(out p))
                {
                    if (p != null)
                    {
                        iter++;
                        variantList.AddRange(Task.Run(() => { return(getVariantService.ListAsync((long)p.Id)); }).Result);
                    }
                }
            }
            variantDone = true;
            GeneralAdapter.OutputString("GetVariantThread Done.");
        }
Example #13
0
        /// <summary>
        /// Get Variants from productQueue
        /// </summary>
        public static async Task GetVariantAsync()
        {
            variantList = new List <ProductVariant>();

            while (!productDone || productQueue.Count > 0)
            {
                if (productQueue.Count == 0)
                {
                    await Task.Delay(500);
                }
                Product p = null;
                if (productQueue.TryDequeue(out p))
                {
                    if (p != null)
                    {
                        variantList.AddRange(await getVariantService.ListAsync((long)p.Id));
                    }
                }
            }
            variantDone = true;
            GeneralAdapter.OutputString("GetVariantThread Done.");
        }