Example #1
0
        public virtual async Task <InventoryStockItemListResponse> GetStockItemsAsync(List <string> skusOrIds, IEnumerable <int> scopes, Mark mark = null)
        {
            try
            {
                var skusArray = skusOrIds.ToArray();

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

                var res           = new catalogInventoryStockItemListResponse();
                var privateClient = this._clientFactory.GetClient();

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

                    privateClient = this._clientFactory.RefreshClient(privateClient);
                    var sessionId = await this.GetSessionId().ConfigureAwait(false);

                    using (var stateTimer = new Timer(tcb, privateClient, 1000, delayBeforeCheck))
                        res = await privateClient.catalogInventoryStockItemListAsync(sessionId.SessionId, skusArray).ConfigureAwait(false);
                }).ConfigureAwait(false);

                return(new InventoryStockItemListResponse(res));
            }
            catch (Exception exc)
            {
                var productsBriefInfo = string.Join("|", skusOrIds);
                throw new MagentoSoapException($"An error occured during GetStockItemsAsync({productsBriefInfo})", exc);
            }
        }
Example #2
0
        public virtual async Task <InventoryStockItemListResponse> GetStockItemsAsync(List <string> skusOrIds)
        {
            try
            {
                var skusArray = skusOrIds.ToArray();

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

                var res           = new catalogInventoryStockItemListResponse();
                var privateClient = this.CreateMagentoServiceClient(this.BaseMagentoUrl);

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

                    privateClient = this.RecreateMagentoServiceClientIfItNeed(privateClient);

                    var sessionId = await this.GetSessionId().ConfigureAwait(false);

                    using (var stateTimer = new Timer(tcb, privateClient, 1000, delayBeforeCheck))
                        res = await privateClient.catalogInventoryStockItemListAsync(sessionId.SessionId, skusArray).ConfigureAwait(false);
                }).ConfigureAwait(false);

                return(new InventoryStockItemListResponse(res));
            }
            catch (Exception exc)
            {
                var productsBriefInfo = string.Join("|", skusOrIds);
                throw new MagentoSoapException(string.Format("An error occured during GetStockItemsAsync({0})", productsBriefInfo), exc);
            }
        }
Example #3
0
 public InventoryStockItemListResponse(catalogInventoryStockItemListResponse res)
 {
     this.InventoryStockItems = res.result.Select(x => new InventoryStockItem(x));
 }