public virtual async Task <InventoryStockItemListResponse> GetStockItemsWithoutSkuAsync(IEnumerable <string> skusOrIds, IEnumerable <int> scopes, Mark mark = null) { try { var pageSize = 500; var res = await this.GetStockItemsPageAsync(1, pageSize).ConfigureAwait(false); if (res.catalogInventoryStockRegistryV1GetLowStockItemsResponse.result.totalCount <= pageSize) { return(new InventoryStockItemListResponse(new[] { Tuple.Create(1, res.catalogInventoryStockRegistryV1GetLowStockItemsResponse.result) })); } var pagingModel = new PagingModel(pageSize, 0); var responses = await pagingModel.GetPages(res.catalogInventoryStockRegistryV1GetLowStockItemsResponse.result.totalCount).ProcessInBatchAsync(10, async x => { var pageResp = await this.GetStockItemsPageAsync(x, pageSize).ConfigureAwait(false); return(Tuple.Create(x, pageResp.catalogInventoryStockRegistryV1GetLowStockItemsResponse.result)); }).ConfigureAwait(false); var inventory = new InventoryStockItemListResponse(responses); return(inventory); } catch (Exception exc) { throw new MagentoSoapException(string.Format("An error occured during GetStockItemsWithoutSkuAsync({0})", ""), exc); } }
public async Task <InventoryStockItemListResponse> GetStockItemsWithoutSkuAsync(IEnumerable <string> skusOrIds, IEnumerable <int> scopes, Mark mark = null) { var pages = new PagingModel(1000, 0).GetPages(skusOrIds).ToList(); var pagesResult = await pages.ProcessInBatchAsync(4, async x => await this.GetStockItemsAsync( x, scopes ).ConfigureAwait(false)).ConfigureAwait(false); var result = new InventoryStockItemListResponse(pagesResult.SelectMany(x => x.InventoryStockItems).ToList()); return(result); }