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 void Ping(Mark mark = null) { if (mark.IsBlank()) { mark = Mark.CreateNew(); } try { ChannelAdvisorLogger.LogStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfoString)); AP.CreateQuery(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Do(() => { var result = this._client.Ping(this._credentials); this.CheckCaSuccess(result); }); ChannelAdvisorLogger.LogTraceEnd(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfoString)); } catch (Exception exception) { var channelAdvisorException = new ChannelAdvisorException(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfoString), exception); ChannelAdvisorLogger.LogTraceException(channelAdvisorException); throw channelAdvisorException; } }
public void Ping(Mark mark = null) { if (mark.IsBlank()) { mark = Mark.CreateNew(); } try { ChannelAdvisorLogger.LogStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo())); AP.CreateQuery(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Do(() => { ChannelAdvisorLogger.LogTraceRetryStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo())); var result = this._client.Ping(this._credentials); ChannelAdvisorLogger.LogTraceRetryEnd(this.CreateMethodCallInfo(mark: mark, methodResult: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : result.ToJson(), additionalInfo: this.AdditionalLogInfo())); this.CheckCaSuccess(result); }); 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 void Ping() { AP.CreateQuery(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Do(() => { var result = this._client.Ping(this._credentials); this.CheckCaSuccess(result); }); }
private OrderResponseItem[] GetOrdersPage(OrderCriteria orderCriteria) { return(AP.CreateQuery(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Get(() => { var results = this._client.GetOrderList(this._credentials, this.AccountId, orderCriteria); CheckCaSuccess(results); var resultData = results.ResultData ?? new OrderResponseItem[0]; // If you get message code = 1 (Unexpected) if (results.MessageCode == 1) { resultData = this.HandleErrorUnexpected(orderCriteria); } return resultData; })); }
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); }
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; } }