Esempio n. 1
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.");
 }
Esempio n. 2
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.");
 }
Esempio n. 3
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.");
        }
Esempio n. 4
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.");
        }
Esempio n. 5
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.");
        }
Esempio n. 6
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.");
        }
Esempio n. 7
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.");
        }