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 async Task <bool> RequestAccessAsync(int localId, Mark mark = null) { if (mark.IsBlank()) { mark = Mark.CreateNew(); } try { ChannelAdvisorLogger.LogStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfoString, methodParameters: localId.ToString())); var requestAsyncResult = await AP.CreateSubmitAsync(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Get(async() => { var result = await this._client.RequestAccessAsync(this._credentials, localId).ConfigureAwait(false); this.CheckCaSuccess(result.RequestAccessResult); return(result.RequestAccessResult.ResultData); }).ConfigureAwait(false); ; ChannelAdvisorLogger.LogTraceEnd(this.CreateMethodCallInfo(mark: mark, methodResult: requestAsyncResult.ToJson(), additionalInfo: this.AdditionalLogInfoString, methodParameters: localId.ToString())); return(requestAsyncResult); } catch (Exception exception) { var channelAdvisorException = new ChannelAdvisorException(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfoString), exception); ChannelAdvisorLogger.LogTraceException(channelAdvisorException); throw channelAdvisorException; } }
public AuthorizationResponse[] GetAuthorizationList(string localId, Mark mark = null) { if (mark.IsBlank()) { mark = Mark.CreateNew(); } try { ChannelAdvisorLogger.LogStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfoString, methodParameters: localId)); var authorizationResponses = AP.CreateSubmit(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Get(() => { var result = this._client.GetAuthorizationList(this._credentials, localId); this.CheckCaSuccess(result); return(result.ResultData); }); ChannelAdvisorLogger.LogTraceEnd(this.CreateMethodCallInfo(mark: mark, methodResult: authorizationResponses.ToJson(), additionalInfo: this.AdditionalLogInfoString, methodParameters: localId)); return(authorizationResponses); } catch (Exception exception) { var channelAdvisorException = new ChannelAdvisorException(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfoString), 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.AdditionalLogInfoString)); await AP.CreateQueryAsync(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Do(async() => { var result = await this._client.PingAsync(this._credentials).ConfigureAwait(false); this.CheckCaSuccess(result.PingResult); }).ConfigureAwait(false); 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 async Task <AuthorizationResponse[]> GetAuthorizationListAsync(Mark mark = null) { if (mark.IsBlank()) { mark = Mark.CreateNew(); } try { ChannelAdvisorLogger.LogStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfoString)); var authorizationResponses = await this.GetAuthorizationListAsync(string.Empty, mark).ConfigureAwait(false); ChannelAdvisorLogger.LogTraceEnd(this.CreateMethodCallInfo(mark: mark, methodResult: authorizationResponses.ToJson(), additionalInfo: this.AdditionalLogInfoString)); return(authorizationResponses); } catch (Exception exception) { var channelAdvisorException = new ChannelAdvisorException(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfoString), exception); ChannelAdvisorLogger.LogTraceException(channelAdvisorException); throw channelAdvisorException; } }
public async Task <PagedApiResponse <string> > GetFilteredSkusAsync(ItemsFilter filter, int startPage, int pageLimit, Mark mark = null) { if (mark.IsBlank()) { mark = Mark.CreateNew(); } var parameters = new { filter, startPage, pageLimit }; try { ChannelAdvisorLogger.LogStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo(), methodParameters: parameters.ToJson())); filter.Criteria.PageSize = 100; filter.Criteria.PageNumber = (startPage > 0) ? startPage - 1 : 1; var skus = new List <string>(); for (var iteration = 0; iteration < pageLimit; iteration++) { 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 : parameters.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 : parameters.ToJson())); return(getFilteredSkuListResponse); }).ConfigureAwait(false); ChannelAdvisorLogger.LogTrace(this.CreateMethodCallInfo(mark: mark, methodResult: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndReturnsForTrace) ? null : itemResponse.ToJson(), additionalInfo: this.AdditionalLogInfo(), methodParameters: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndReturnsForTrace) ? null : parameters.ToJson())); if (!this.IsRequestSuccessful(itemResponse.GetFilteredSkuListResult)) { continue; } var pageSkus = itemResponse.GetFilteredSkuListResult.ResultData; if (pageSkus == null) { var pagedApiResponse = new PagedApiResponse <string>(skus, filter.Criteria.PageNumber, true); ChannelAdvisorLogger.LogEnd(this.CreateMethodCallInfo(mark: mark, methodResult: pagedApiResponse.ToJson(), additionalInfo: this.AdditionalLogInfo(), methodParameters: parameters.ToJson())); return(pagedApiResponse); } skus.AddRange(pageSkus); if (pageSkus.Length == 0 || pageSkus.Length < filter.Criteria.PageSize) { var pagedApiResponse = new PagedApiResponse <string>(skus, filter.Criteria.PageNumber, true); ChannelAdvisorLogger.LogEnd(this.CreateMethodCallInfo(mark: mark, methodResult: pagedApiResponse.ToJson(), additionalInfo: this.AdditionalLogInfo(), methodParameters: parameters.ToJson())); return(pagedApiResponse); } } var apiResponse = new PagedApiResponse <string>(skus, filter.Criteria.PageNumber, false); ChannelAdvisorLogger.LogTraceEnd(this.CreateMethodCallInfo(mark: mark, methodResult: apiResponse.ToJson(), additionalInfo: this.AdditionalLogInfo(), methodParameters: parameters.ToJson())); return(apiResponse); } catch (Exception exception) { var channelAdvisorException = new ChannelAdvisorException(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo()), exception); ChannelAdvisorLogger.LogTraceException(channelAdvisorException); throw channelAdvisorException; } }