示例#1
0
        public DistributionCenterResponse[] GetDistributionCenterList(Mark mark = null)
        {
            if (mark.IsBlank())
            {
                mark = Mark.CreateNew();
            }

            try
            {
                ChannelAdvisorLogger.LogStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo()));

                var distributionCenterResponses = AP.CreateQuery(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Get(() =>
                {
                    ChannelAdvisorLogger.LogTraceRetryStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo()));
                    var result = this._client.GetDistributionCenterList(this._credentials, this.AccountId);
                    this.CheckCaSuccess(result);
                    ChannelAdvisorLogger.LogTraceRetryEnd(this.CreateMethodCallInfo(mark: mark, methodResult: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : result.ToJson(), additionalInfo: this.AdditionalLogInfo()));
                    return(result.ResultData);
                });
                ChannelAdvisorLogger.LogEnd(this.CreateMethodCallInfo(mark: mark, methodResult: distributionCenterResponses.ToJson(), additionalInfo: this.AdditionalLogInfo()));
                return(distributionCenterResponses);
            }
            catch (Exception exception)
            {
                var channelAdvisorException = new ChannelAdvisorException(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo()), exception);
                ChannelAdvisorLogger.LogTraceException(channelAdvisorException);
                throw channelAdvisorException;
            }
        }
示例#2
0
        public async Task DeleteItemAsync(string sku, Mark mark = null)
        {
            if (mark.IsBlank())
            {
                mark = Mark.CreateNew();
            }

            try
            {
                ChannelAdvisorLogger.LogStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo(), methodParameters: sku));

                await AP.CreateSubmitAsync(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Do(async() =>
                {
                    ChannelAdvisorLogger.LogTraceRetryStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo(), methodParameters: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : sku));
                    var resultOfBoolean = await this._client.DeleteInventoryItemAsync(this._credentials, this.AccountId, sku).ConfigureAwait(false);
                    CheckCaSuccess(resultOfBoolean.DeleteInventoryItemResult);
                    ChannelAdvisorLogger.LogTraceRetryEnd(this.CreateMethodCallInfo(mark: mark, methodResult: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : resultOfBoolean.ToJson(), additionalInfo: this.AdditionalLogInfo(), methodParameters: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : sku));
                }).ConfigureAwait(false);

                ChannelAdvisorLogger.LogEnd(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo(), methodParameters: sku));
            }
            catch (Exception exception)
            {
                var channelAdvisorException = new ChannelAdvisorException(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo()), exception);
                ChannelAdvisorLogger.LogTraceException(channelAdvisorException);
                throw channelAdvisorException;
            }
        }
示例#3
0
        public async Task <ClassificationConfigurationInformation[]> GetClassificationConfigInfoAsync(Mark mark = null)
        {
            if (mark.IsBlank())
            {
                mark = Mark.CreateNew();
            }

            try
            {
                ChannelAdvisorLogger.LogStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo()));

                var classificationConfigurationInformations = await AP.CreateQueryAsync(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Get(async() =>
                {
                    ChannelAdvisorLogger.LogTraceRetryStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo()));
                    var result = await this._client.GetClassificationConfigurationInformationAsync(this._credentials, this.AccountId).ConfigureAwait(false);
                    CheckCaSuccess(result.GetClassificationConfigurationInformationResult);
                    ChannelAdvisorLogger.LogTraceRetryEnd(this.CreateMethodCallInfo(mark: mark, methodResult: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : result.ToJson(), additionalInfo: this.AdditionalLogInfo()));
                    return(result.GetClassificationConfigurationInformationResult.ResultData);
                }).ConfigureAwait(false);

                ChannelAdvisorLogger.LogEnd(this.CreateMethodCallInfo(mark: mark, methodResult: classificationConfigurationInformations.ToJson(), additionalInfo: this.AdditionalLogInfo()));
                return(classificationConfigurationInformations);
            }
            catch (Exception exception)
            {
                var channelAdvisorException = new ChannelAdvisorException(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo()), exception);
                ChannelAdvisorLogger.LogTraceException(channelAdvisorException);
                throw channelAdvisorException;
            }
        }
        public async Task SynchItemAsync(InventoryItemSubmit item, bool isCreateNew = false, Mark mark = null)
        {
            if (mark.IsBlank())
            {
                mark = Mark.CreateNew();
            }

            var parameters = new { item, isCreateNew };

            try
            {
                ChannelAdvisorLogger.LogStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo(), methodParameters: parameters.ToJson()));

                await AP.CreateSubmitAsync(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Do(async() =>
                {
                    ChannelAdvisorLogger.LogTraceRetryStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo(), methodParameters: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : parameters.ToJson()));
                    if (!isCreateNew && !(await this.DoesSkuExistAsync(item.Sku, mark).ConfigureAwait(false)))
                    {
                        return;
                    }

                    var resultOfBoolean = await this._client.SynchInventoryItemAsync(this._credentials, this.AccountId, item).ConfigureAwait(false);
                    CheckCaSuccess(resultOfBoolean.SynchInventoryItemResult);
                    ChannelAdvisorLogger.LogTraceRetryEnd(this.CreateMethodCallInfo(mark: mark, methodResult: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : resultOfBoolean.ToJson(), additionalInfo: this.AdditionalLogInfo(), methodParameters: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : parameters.ToJson()));
                }).ConfigureAwait(false);

                ChannelAdvisorLogger.LogEnd(this.CreateMethodCallInfo(mark: mark, methodResult: "void", additionalInfo: this.AdditionalLogInfo(), methodParameters: parameters.ToJson()));
            }
            catch (Exception exception)
            {
                var channelAdvisorException = new ChannelAdvisorException(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo()), exception);
                ChannelAdvisorLogger.LogTraceException(channelAdvisorException);
                throw channelAdvisorException;
            }
        }
        public async Task PingAsync(Mark mark = null)
        {
            if (mark.IsBlank())
            {
                mark = Mark.CreateNew();
            }

            try
            {
                ChannelAdvisorLogger.LogStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo()));
                await AP.CreateQueryAsync(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Do(async() =>
                {
                    ChannelAdvisorLogger.LogTraceRetryStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo()));
                    var result = await this._client.PingAsync(this._credentials).ConfigureAwait(false);
                    ChannelAdvisorLogger.LogTraceRetryEnd(this.CreateMethodCallInfo(mark: mark, methodResult: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : result.ToJson(), additionalInfo: this.AdditionalLogInfo()));
                    this.CheckCaSuccess(result.PingResult);
                }).ConfigureAwait(false);

                ChannelAdvisorLogger.LogEnd(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo()));
            }
            catch (Exception exception)
            {
                var channelAdvisorException = new ChannelAdvisorException(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo()), exception);
                ChannelAdvisorLogger.LogTraceException(channelAdvisorException);
                throw channelAdvisorException;
            }
        }
        public async Task AssignLabelListToItemListAsync(string[] labels, bool createLabelIfNotExist, IEnumerable <string> skus, string reason, Mark mark = null)
        {
            Condition.Requires(labels, "labels").IsShorterOrEqual(3, "Only up to 3 labels allowed.").IsNotNull();

            if (mark.IsBlank())
            {
                mark = Mark.CreateNew();
            }

            var parameters = new { labels, createLabelIfNotExist, skus, reason };

            try
            {
                ChannelAdvisorLogger.LogStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo(), methodParameters: parameters.ToJson()));

                await skus.DoWithPagesAsync(500, async s => await AP.CreateSubmitAsync( ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Do( async() =>
                {
                    ChannelAdvisorLogger.LogTraceRetryStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo(), methodParameters: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : s.ToJson()));
                    var resultOfBoolean = await this._client.AssignLabelListToInventoryItemListAsync(this._credentials, this.AccountId, labels, createLabelIfNotExist, s.ToArray(), reason).ConfigureAwait(false);
                    CheckCaSuccess(resultOfBoolean.AssignLabelListToInventoryItemListResult);
                    ChannelAdvisorLogger.LogTraceRetryEnd(this.CreateMethodCallInfo(mark: mark, methodResult: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : resultOfBoolean.ToJson(), additionalInfo: this.AdditionalLogInfo(), methodParameters: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : s.ToJson()));
                } ).ConfigureAwait(false)).ConfigureAwait(false);

                ChannelAdvisorLogger.LogEnd(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo(), methodParameters: parameters.ToJson()));
            }
            catch (Exception exception)
            {
                var channelAdvisorException = new ChannelAdvisorException(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo()), exception);
                ChannelAdvisorLogger.LogTraceException(channelAdvisorException);
                throw channelAdvisorException;
            }
        }
        public async Task UpdateQuantityAndPricesAsync(IEnumerable <InventoryItemQuantityAndPrice> itemQuantityAndPrices, Mark mark = null)
        {
            if (mark.IsBlank())
            {
                mark = Mark.CreateNew();
            }

            try
            {
                ChannelAdvisorLogger.LogStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo(), methodParameters: itemQuantityAndPrices.ToJson()));

                var itemQuantityAndPricesByPages = ToChunks(itemQuantityAndPrices, 800);
                await itemQuantityAndPricesByPages.DoInBatchAsync(3, async itemsPage =>
                {
                    await AP.CreateSubmitAsync(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Do(async() =>
                    {
                        ChannelAdvisorLogger.LogTraceRetryStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo(), methodParameters: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : itemsPage.ToJson()));
                        var result = await this._client.UpdateInventoryItemQuantityAndPriceListAsync(this._credentials, this.AccountId, itemsPage.ToArray()).ConfigureAwait(false);
                        CheckCaSuccess(result.UpdateInventoryItemQuantityAndPriceListResult);
                        ChannelAdvisorLogger.LogTraceRetryEnd(this.CreateMethodCallInfo(mark: mark, methodResult: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : result.ToJson(), additionalInfo: this.AdditionalLogInfo(), methodParameters: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : itemsPage.ToJson()));
                    }).ConfigureAwait(false);
                }).ConfigureAwait(false);
            }
            catch (Exception exception)
            {
                var channelAdvisorException = new ChannelAdvisorException(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo()), exception);
                ChannelAdvisorLogger.LogTraceException(channelAdvisorException);
                throw channelAdvisorException;
            }
        }
        public void UpdateQuantityAndPrices(IEnumerable <InventoryItemQuantityAndPrice> itemQuantityAndPrices, Mark mark = null)
        {
            if (mark.IsBlank())
            {
                mark = Mark.CreateNew();
            }

            try
            {
                ChannelAdvisorLogger.LogStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo(), methodParameters: itemQuantityAndPrices.ToJson()));

                var itemQuantityAndPricesByPages = ToChunks(itemQuantityAndPrices, 500);
                foreach (var itemsPage in itemQuantityAndPricesByPages)
                {
                    AP.CreateSubmit(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Do(() =>
                    {
                        ChannelAdvisorLogger.LogTraceRetryStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo(), methodParameters: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : itemsPage.ToJson()));
                        var resultOfBoolean = this._client.UpdateInventoryItemQuantityAndPriceList(this._credentials, this.AccountId, itemsPage.ToArray());
                        CheckCaSuccess(resultOfBoolean);
                        ChannelAdvisorLogger.LogTraceRetryEnd(this.CreateMethodCallInfo(mark: mark, methodResult: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : resultOfBoolean.ToJson(), additionalInfo: this.AdditionalLogInfo(), methodParameters: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : itemsPage.ToJson()));
                    });
                }

                ChannelAdvisorLogger.LogEnd(this.CreateMethodCallInfo(mark: mark, methodResult: "void", additionalInfo: this.AdditionalLogInfo(), methodParameters: itemQuantityAndPrices.ToJson()));
            }
            catch (Exception exception)
            {
                var channelAdvisorException = new ChannelAdvisorException(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo()), exception);
                ChannelAdvisorLogger.LogTraceException(channelAdvisorException);
                throw channelAdvisorException;
            }
        }
示例#9
0
        public async Task <IEnumerable <string> > GetFilteredSkusAsync(ItemsFilter filter, Mark mark = null)
        {
            if (mark.IsBlank())
            {
                mark = Mark.CreateNew();
            }

            try
            {
                ChannelAdvisorLogger.LogStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo(), methodParameters: filter.ToJson()));
                filter.Criteria.PageSize   = 100;
                filter.Criteria.PageNumber = 0;

                var skus = new List <string>();
                while (true)
                {
                    filter.Criteria.PageNumber += 1;
                    var itemResponse = await AP.CreateQueryAsync(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Get(async() =>
                    {
                        ChannelAdvisorLogger.LogTraceRetryStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo(), methodParameters: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : filter.ToJson()));
                        var getFilteredSkuListResponse = await this._client.GetFilteredSkuListAsync
                                                             (this._credentials, this.AccountId, filter.Criteria,
                                                             filter.SortField, filter.SortDirection).ConfigureAwait(false);
                        ChannelAdvisorLogger.LogTraceRetryEnd(this.CreateMethodCallInfo(mark: mark, methodResult: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : getFilteredSkuListResponse.ToJson(), additionalInfo: this.AdditionalLogInfo(), methodParameters: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : filter.ToJson()));
                        return(getFilteredSkuListResponse);
                    }).ConfigureAwait(false);

                    ChannelAdvisorLogger.LogTrace(this.CreateMethodCallInfo(mark: mark, methodResult: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndReturnsForTrace) ? null : itemResponse.ToJson(), additionalInfo: this.AdditionalLogInfo()));

                    if (!this.IsRequestSuccessful(itemResponse.GetFilteredSkuListResult))
                    {
                        continue;
                    }

                    var pageSkus = itemResponse.GetFilteredSkuListResult.ResultData;
                    if (pageSkus == null)
                    {
                        ChannelAdvisorLogger.LogEnd(this.CreateMethodCallInfo(mark: mark, methodResult: skus.ToJson(), additionalInfo: this.AdditionalLogInfo(), methodParameters: filter.ToJson()));
                        return(skus);
                    }

                    skus.AddRange(pageSkus);

                    if (pageSkus.Length == 0 || pageSkus.Length < filter.Criteria.PageSize)
                    {
                        ChannelAdvisorLogger.LogEnd(this.CreateMethodCallInfo(mark: mark, methodResult: skus.ToJson(), additionalInfo: this.AdditionalLogInfo(), methodParameters: filter.ToJson()));
                        return(skus);
                    }
                }
            }
            catch (Exception exception)
            {
                var channelAdvisorException = new ChannelAdvisorException(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo()), exception);
                ChannelAdvisorLogger.LogTraceException(channelAdvisorException);
                throw channelAdvisorException;
            }
        }
        public void SynchItems(IEnumerable <InventoryItemSubmit> items, bool isCreateNew = false, Mark mark = null)
        {
            if (mark.IsBlank())
            {
                mark = Mark.CreateNew();
            }

            var parameters = new { items, isCreateNew };

            try
            {
                ChannelAdvisorLogger.LogStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo(), methodParameters: parameters.ToJson()));

                if (!isCreateNew)
                {
                    var existSkus = this.DoSkusExist(items.Select(x => x.Sku), mark).Select(x => x.Sku);
                    items = items.Where(x => existSkus.Contains(x.Sku));
                }

                var itemsByPages = ToChunks(items, 100);
                foreach (var i in itemsByPages)
                {
                    AP.CreateSubmit(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Do(() =>
                    {
                        ChannelAdvisorLogger.LogTraceRetryStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo(), methodParameters: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : i.ToJson()));
                        var resultOfBoolean = this._client.SynchInventoryItemList(this._credentials, this.AccountId, i.ToArray());
                        CheckCaSuccess(resultOfBoolean);
                        ChannelAdvisorLogger.LogTraceRetryEnd(this.CreateMethodCallInfo(mark: mark, methodResult: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : resultOfBoolean.ToJson(), additionalInfo: this.AdditionalLogInfo(), methodParameters: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : i.ToJson()));
                    });
                }
                ChannelAdvisorLogger.LogEnd(this.CreateMethodCallInfo(mark: mark, methodResult: "void", additionalInfo: this.AdditionalLogInfo(), methodParameters: parameters.ToJson()));
            }
            catch (Exception exception)
            {
                var channelAdvisorException = new ChannelAdvisorException(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo()), exception);
                ChannelAdvisorLogger.LogTraceException(channelAdvisorException);
                throw channelAdvisorException;
            }
        }
        public void RemoveLabelListFromItemList(string[] labels, IEnumerable <string> skus, string reason, Mark mark = null)
        {
            Condition.Requires(labels, "labels").IsShorterOrEqual(3, "Only up to 3 labels allowed.").IsNotNull();

            if (mark.IsBlank())
            {
                mark = Mark.CreateNew();
            }

            var parameters = new { labels, skus, reason };

            try
            {
                ChannelAdvisorLogger.LogStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo(), methodParameters: parameters.ToJson()));

                var skusByPages = ToChunks(skus, 500);
                foreach (var s in skusByPages)
                {
                    AP.CreateSubmit(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Do(() =>
                    {
                        ChannelAdvisorLogger.LogTraceRetryStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo(), methodParameters: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : s.ToJson()));
                        var resultOfBoolean = this._client.RemoveLabelListFromInventoryItemList(this._credentials, this.AccountId, labels, s.ToArray(), reason);
                        CheckCaSuccess(resultOfBoolean);
                        ChannelAdvisorLogger.LogTraceRetryEnd(this.CreateMethodCallInfo(mark: mark, methodResult: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : resultOfBoolean.ToJson(), additionalInfo: this.AdditionalLogInfo(), methodParameters: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : s.ToJson()));
                    });
                }

                ChannelAdvisorLogger.LogEnd(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo(), methodParameters: parameters.ToJson()));
            }
            catch (Exception exception)
            {
                var channelAdvisorException = new ChannelAdvisorException(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo()), exception);
                ChannelAdvisorLogger.LogTraceException(channelAdvisorException);
                throw channelAdvisorException;
            }
        }
示例#12
0
        public IEnumerable <string> GetFilteredSkus(ItemsFilter filter, Mark mark = null)
        {
            if (mark.IsBlank())
            {
                mark = Mark.CreateNew();
            }

            try
            {
                ChannelAdvisorLogger.LogStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo(), methodParameters: filter.ToJson()));

                filter.Criteria.PageSize   = 100;
                filter.Criteria.PageNumber = 0;

                filter.DetailLevel.IncludeClassificationInfo = true;
                filter.DetailLevel.IncludePriceInfo          = true;
                filter.DetailLevel.IncludeQuantityInfo       = true;

                var filteredSkus = new List <string>();
                while (true)
                {
                    filter.Criteria.PageNumber += 1;
                    var itemResponse = AP.CreateQuery(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Get(
                        () =>
                    {
                        ChannelAdvisorLogger.LogTraceRetryStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo(), methodParameters: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : filter.ToJson()));
                        var apiResultOfArrayOfString = this._client.GetFilteredSkuList
                                                       (
                            this._credentials, this.AccountId, filter.Criteria,
                            filter.SortField, filter.SortDirection);
                        ChannelAdvisorLogger.LogTraceRetryEnd(this.CreateMethodCallInfo(mark: mark, methodResult: apiResultOfArrayOfString.ToJson(), additionalInfo: this.AdditionalLogInfo(), methodParameters: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : filter.ToJson()));

                        return(apiResultOfArrayOfString);
                    });
                    ChannelAdvisorLogger.LogTrace(this.CreateMethodCallInfo(mark: mark, methodResult: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndReturnsForTrace) ? null : itemResponse.ToJson(), additionalInfo: this.AdditionalLogInfo()));

                    if (!this.IsRequestSuccessful(itemResponse))
                    {
                        filteredSkus.Add(null);
                        continue;
                    }

                    var items = itemResponse.ResultData;

                    if (items == null)
                    {
                        ChannelAdvisorLogger.LogEnd(this.CreateMethodCallInfo(mark: mark, methodResult: filteredSkus.ToJson(), additionalInfo: this.AdditionalLogInfo(), methodParameters: filter.ToJson()));
                        return(filteredSkus);
                    }

                    filteredSkus.AddRange(items);

                    if (items.Length == 0 || items.Length < filter.Criteria.PageSize)
                    {
                        ChannelAdvisorLogger.LogEnd(this.CreateMethodCallInfo(mark: mark, methodResult: filteredSkus.ToJson(), additionalInfo: this.AdditionalLogInfo(), methodParameters: filter.ToJson()));
                        return(filteredSkus);
                    }
                }
            }
            catch (Exception exception)
            {
                var channelAdvisorException = new ChannelAdvisorException(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo()), exception);
                ChannelAdvisorLogger.LogTraceException(channelAdvisorException);
                throw channelAdvisorException;
            }
        }