public virtual async Task <IEnumerable <RpcInvoker.RpcRequestResponse <PutStockItem, object> > > PutStockItemsAsync(List <PutStockItem> stockItems, Mark mark = null)
        {
            var methodParameters = stockItems.ToJson();

            try
            {
                const int maxCheckCount    = 2;
                const int delayBeforeCheck = 1800000;

                var magentoStockItemsResponse = await this.GetStockItemsOldAsync(stockItems.Select(item => item.Sku)).ConfigureAwait(false);

                var magentoStockItems = magentoStockItemsResponse.Responses.Select(item => item as CatalogInventoryDataStockItemInterface).Where(item => item != null);

                var privateClient = this._clientFactory.CreateMagentoCatalogInventoryStockServiceClient();

                var res = new ConcurrentQueue <RpcInvoker.RpcRequestResponse <PutStockItem, object> >();

                await stockItems.DoInBatchAsync(10, async x =>
                {
                    await ActionPolicies.GetAsync.Do(async() =>
                    {
                        var statusChecker = new StatusChecker(maxCheckCount);
                        TimerCallback tcb = statusChecker.CheckStatus;

                        privateClient = this._clientFactory.RefreshMagentoCatalogInventoryStockServiceClient(privateClient);

                        using (var stateTimer = new Timer(tcb, privateClient, 1000, delayBeforeCheck))
                        {
                            MagentoLogger.LogTraceStarted(this.CreateMethodCallInfo(methodParameters, mark: mark));

                            var productId = int.Parse(x.ProductId);
                            var catalogInventoryDataStockItemInterface = magentoStockItems.FirstOrDefault(i => i.productId == productId);
                            if (catalogInventoryDataStockItemInterface == null)
                            {
                                MagentoLogger.LogTrace($"PutStockItemsAsync. Can't find StockItem with ProductId={x.ProductId} (SKU={x.Sku}).", mark);
                                catalogInventoryDataStockItemInterface = new CatalogInventoryDataStockItemInterface
                                {
                                    productId                      = productId,
                                    productIdSpecified             = true,
                                    isInStock                      = false,
                                    isQtyDecimal                   = false,
                                    showDefaultNotificationMessage = false,
                                    useConfigMinQty                = true,
                                    minQty = 0,
                                    useConfigMinSaleQty     = 1,
                                    minSaleQty              = 1,
                                    useConfigMaxSaleQty     = true,
                                    maxSaleQty              = 10000,
                                    useConfigBackorders     = true,
                                    backorders              = 0,
                                    useConfigNotifyStockQty = true,
                                    notifyStockQty          = 1,
                                    useConfigQtyIncrements  = true,
                                    qtyIncrements           = 0,
                                    useConfigEnableQtyInc   = false,
                                    enableQtyIncrements     = false,
                                    useConfigManageStock    = true,
                                    manageStock             = true,
                                    //lowStockDate = "2016-02-29 20:48:26",
                                    isDecimalDivided       = false,
                                    stockStatusChangedAuto = 1
                                };
                            }
                            catalogInventoryDataStockItemInterface.qty        = x.Qty.ToString();
                            catalogInventoryDataStockItemInterface.isInStock |= x.Qty > 0;

                            var catalogInventoryStockRegistryV1UpdateStockItemBySkuRequest = new CatalogInventoryStockRegistryV1UpdateStockItemBySkuRequest()
                            {
                                productSku = x.Sku,
                                stockItem  = catalogInventoryDataStockItemInterface
                            };

                            RpcInvoker.IRpcResponse <object> response = await RpcInvoker.SuppressExceptions(async() => await privateClient.catalogInventoryStockRegistryV1UpdateStockItemBySkuAsync(catalogInventoryStockRegistryV1UpdateStockItemBySkuRequest).ConfigureAwait(false)).ConfigureAwait(false);
                            var reqResp = new RpcInvoker.RpcRequestResponse <PutStockItem, object>(x, response);
                            res.Enqueue(reqResp);
                        }
                    }).ConfigureAwait(false);
                }).ConfigureAwait(false);

                MagentoLogger.LogTraceEnded(this.CreateMethodCallInfo(methodParameters, mark: mark, methodResult: res.ToJson()));
                //return errors count instead of true false;
                return(res);
            }
            catch (Exception exc)
            {
                throw new MagentoSoapException($"An error occured during PutStockItemsAsync({methodParameters})", exc);
            }
        }
        public virtual async Task <bool> PutStockItemAsync(PutStockItem putStockItem, Mark markForLog)
        {
            var productsBriefInfo = new List <PutStockItem> {
                putStockItem
            }.ToJson();

            try
            {
                const int maxCheckCount    = 2;
                const int delayBeforeCheck = 120000;

                var res           = false;
                var privateClient = this._clientFactory.CreateMagentoCatalogInventoryStockServiceClient();

                await ActionPolicies.GetAsync.Do(async() =>
                {
                    var statusChecker = new StatusChecker(maxCheckCount);
                    TimerCallback tcb = statusChecker.CheckStatus;

                    privateClient = this._clientFactory.RefreshMagentoCatalogInventoryStockServiceClient(privateClient);

                    using (var stateTimer = new Timer(tcb, privateClient, 1000, delayBeforeCheck))
                    {
                        MagentoLogger.LogTraceStarted(this.CreateMethodCallInfo(productsBriefInfo, markForLog));

                        var catalogInventoryDataStockItemInterface = new CatalogInventoryDataStockItemInterface()
                        {
                            qty                            = putStockItem.Qty.ToString(),
                            productId                      = int.Parse(putStockItem.ProductId),
                            productIdSpecified             = true,
                            isInStock                      = putStockItem.Qty > 0,
                            isQtyDecimal                   = false,
                            showDefaultNotificationMessage = false,
                            useConfigMinQty                = true,
                            minQty                         = 0,
                            useConfigMinSaleQty            = 1,
                            minSaleQty                     = 1,
                            useConfigMaxSaleQty            = true,
                            maxSaleQty                     = 10000,
                            useConfigBackorders            = true,
                            backorders                     = 0,
                            useConfigNotifyStockQty        = true,
                            notifyStockQty                 = 1,
                            useConfigQtyIncrements         = true,
                            qtyIncrements                  = 0,
                            useConfigEnableQtyInc          = false,
                            enableQtyIncrements            = false,
                            useConfigManageStock           = true,
                            manageStock                    = true,
                            //lowStockDate = "2016-02-29 20:48:26",
                            isDecimalDivided       = false,
                            stockStatusChangedAuto = 1
                        };
                        var catalogInventoryStockRegistryV1UpdateStockItemBySkuRequest = new CatalogInventoryStockRegistryV1UpdateStockItemBySkuRequest()
                        {
                            //productSku = x.Sku,
                            stockItem = catalogInventoryDataStockItemInterface
                        };

                        var temp = await privateClient.catalogInventoryStockRegistryV1UpdateStockItemBySkuAsync(catalogInventoryStockRegistryV1UpdateStockItemBySkuRequest).ConfigureAwait(false);

                        res = temp.catalogInventoryStockRegistryV1UpdateStockItemBySkuResponse.result > 0;

                        var updateBriefInfo = string.Format("{{ErrorCode:{0}}}", res);
                        MagentoLogger.LogTraceEnded(this.CreateMethodCallInfo(productsBriefInfo, markForLog, methodResult: updateBriefInfo));
                    }
                }).ConfigureAwait(false);

                return(res);
            }
            catch (Exception exc)
            {
                throw new MagentoSoapException($"An error occured during PutStockItemsAsync({productsBriefInfo})", exc);
            }
        }