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 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; } }
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 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; } }
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 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; } }
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; } }
/// <summary> /// Gets the orders. /// </summary> /// <typeparam name="T">Type of order response.</typeparam> /// <param name="orderCriteria">The order criteria.</param> /// <param name="mark"></param> /// <returns>Orders matching supplied criteria.</returns> public async Task <IEnumerable <T> > GetOrdersAsync <T>(OrderCriteria orderCriteria, Mark mark = null) where T : OrderResponseItem { if (mark.IsBlank()) { mark = Mark.CreateNew(); } try { ChannelAdvisorLogger.LogStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo(), methodParameters: orderCriteria.ToJson())); if (string.IsNullOrEmpty(orderCriteria.DetailLevel)) { orderCriteria.DetailLevel = "High"; } int pageSize; orderCriteria.PageSize = this._pageSizes.TryGetValue(orderCriteria.DetailLevel, out pageSize) ? pageSize : 20; orderCriteria.PageNumberFilter = 1; var orders = new List <T>(); while (true) { var ordersFromPage = await this.GetOrdersPageAsync(orderCriteria, mark).ConfigureAwait(false); if (ordersFromPage == null || ordersFromPage.Length == 0) { break; } orders.AddRange(ordersFromPage.OfType <T>()); orderCriteria.PageNumberFilter += 1; } await this.CheckFulfillmentStatusAsync(orders, mark); ChannelAdvisorLogger.LogEnd(this.CreateMethodCallInfo(mark: mark, methodResult: orders.ToJson(), additionalInfo: this.AdditionalLogInfo(), methodParameters: orderCriteria.ToJson())); return(orders); } catch (Exception exception) { var channelAdvisorException = new ChannelAdvisorException(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo(), methodParameters: orderCriteria.ToJson()), exception); ChannelAdvisorLogger.LogTraceException(channelAdvisorException); throw channelAdvisorException; } }
public IEnumerable <string> GetAllSkus(Mark mark = null) { if (mark.IsBlank()) { mark = Mark.CreateNew(); } try { ChannelAdvisorLogger.LogStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo())); var filteredSkus = this.GetFilteredSkus(new ItemsFilter(), mark); ChannelAdvisorLogger.LogEnd(this.CreateMethodCallInfo(mark: mark, methodResult: filteredSkus.ToJson(), additionalInfo: this.AdditionalLogInfo())); return(filteredSkus); } catch (Exception exception) { var channelAdvisorException = new ChannelAdvisorException(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo()), exception); ChannelAdvisorLogger.LogTraceException(channelAdvisorException); throw channelAdvisorException; } }
private void CheckFulfillmentStatus <T>(List <T> orders, Mark mark = null) where T : OrderResponseItem { var refundedOrderIds = GetRefundedOrderIds(orders); if (refundedOrderIds.Count == 0) { return; } int pageSize; if (!this._pageSizes.TryGetValue("High", out pageSize)) { pageSize = 50; } var cancelledOrderIds = new List <int>(); var ordersParts = ItemsService.ToChunks(refundedOrderIds, pageSize); ChannelAdvisorLogger.LogStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo(), methodParameters: refundedOrderIds.ToJson())); foreach (var part in ordersParts) { var ordersFulfillment = AP.CreateQuery(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Get(() => { var results = this._fulfillmentServiceClient.GetOrderFulfillmentDetailList(this._fulfillmentServiceCredentials, this.AccountId, part.ToArray(), null); CheckCaSuccess(results); var resultData = results.ResultData ?? new FulfillmentService.OrderFulfillmentResponse[0]; return(resultData); }); ChannelAdvisorLogger.LogTrace(this.CreateMethodCallInfo(mark: mark, methodResult: ordersFulfillment.ToJson(), additionalInfo: this.AdditionalLogInfo(), methodParameters: part.ToJson())); var cancelledOrderIdsPart = ordersFulfillment.Where(o => o.FulfillmentList.All(fulfillment => fulfillment.FulfillmentStatus == "Canceled")).Select(o => o.OrderID); cancelledOrderIds.AddRange(cancelledOrderIdsPart); } ChannelAdvisorLogger.LogEnd(this.CreateMethodCallInfo(mark: mark, methodResult: cancelledOrderIds.ToJson(), additionalInfo: this.AdditionalLogInfo(), methodParameters: refundedOrderIds.ToJson())); CancelOrders(orders, cancelledOrderIds); }
private async Task CheckFulfillmentStatusAsync <T>(List <T> orders, Mark mark = null) where T : OrderResponseItem { var refundedOrderIds = GetRefundedOrderIds(orders); if (refundedOrderIds.Count == 0) { return; } int pageSize; if (!this._pageSizes.TryGetValue("High", out pageSize)) { pageSize = 50; } var ordersParts = ItemsService.ToChunks(refundedOrderIds, pageSize); ChannelAdvisorLogger.LogStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo(), methodParameters: refundedOrderIds.ToJson())); var cancelledOrderIds = (await ordersParts.ProcessInBatchAsync(3, async part => { var ordersFulfillment = await AP.CreateQueryAsync(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Get(async() => { var results = await this._fulfillmentServiceClient.GetOrderFulfillmentDetailListAsync(this._fulfillmentServiceCredentials, this.AccountId, part.ToArray(), null).ConfigureAwait(false); CheckCaSuccess(results.GetOrderFulfillmentDetailListResult); var resultData = results.GetOrderFulfillmentDetailListResult.ResultData ?? new FulfillmentService.OrderFulfillmentResponse[0]; return(resultData); }).ConfigureAwait(false); ChannelAdvisorLogger.LogTrace(this.CreateMethodCallInfo(mark: mark, methodResult: ordersFulfillment.ToJson(), additionalInfo: this.AdditionalLogInfo(), methodParameters: part.ToJson())); return(ordersFulfillment.Where(o => o.FulfillmentList.All(fulfillment => fulfillment.FulfillmentStatus == "Canceled")).Select(o => o.OrderID)); }).ConfigureAwait(false)).SelectMany(x => x).ToArray(); ChannelAdvisorLogger.LogEnd(this.CreateMethodCallInfo(mark: mark, methodResult: cancelledOrderIds.ToJson(), additionalInfo: this.AdditionalLogInfo(), methodParameters: refundedOrderIds.ToJson())); CancelOrders(orders, cancelledOrderIds); }
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; } }
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; } }