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 void AssignLabelListToItemList(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()));

                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.AssignLabelListToInventoryItemList(this._credentials, this.AccountId, labels, createLabelIfNotExist, 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;
            }
        }
Ejemplo n.º 3
0
        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 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;
            }
        }
Ejemplo n.º 5
0
        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;
            }
        }
Ejemplo n.º 6
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;
            }
        }
Ejemplo n.º 7
0
        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;
            }
        }
Ejemplo n.º 8
0
        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;
            }
        }
Ejemplo n.º 9
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;
            }
        }
Ejemplo n.º 10
0
        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 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;
            }
        }
Ejemplo n.º 12
0
 public void SubmitOrderShipmentList(IEnumerable <OrderShipment> orderShipments)
 {
     orderShipments.DoWithPages(50, p => AP.CreateSubmit(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Do(() =>
     {
         var result = this._client.SubmitOrderShipmentList(this._credentials, this.AccountId, p.ToArray());
         this.CheckCaSuccess(result);
     }));
 }
Ejemplo n.º 13
0
 public async Task PingAsync()
 {
     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);
 }
Ejemplo n.º 14
0
 public void Ping()
 {
     AP.CreateQuery(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Do(() =>
     {
         var result = this._client.Ping(this._credentials);
         this.CheckCaSuccess(result);
     });
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Submits the order.
 /// </summary>
 /// <param name="orderSubmit">The order submit.</param>
 /// <returns>New order CA id.</returns>
 public int SubmitOrder(OrderSubmit orderSubmit)
 {
     return(AP.CreateSubmit(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Get(() =>
     {
         var apiResults = this._client.SubmitOrder(this._credentials, this.AccountId, orderSubmit);
         this.CheckCaSuccess(apiResults);
         return apiResults.ResultData;
     }));
 }
Ejemplo n.º 16
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;
            }
        }
Ejemplo n.º 17
0
 public async Task <OrderShipmentHistoryResponse[]> GetOrderShipmentHistoryListAsync(int[] orderIdList, string[] clientOrderIdentifierList)
 {
     return(await AP.CreateSubmit(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Get(async() =>
     {
         var result = await this._client.GetOrderShipmentHistoryListAsync(this._credentials, this.AccountId, orderIdList, clientOrderIdentifierList).ConfigureAwait(false);
         this.CheckCaSuccess(result.GetOrderShipmentHistoryListResult);
         return result.GetOrderShipmentHistoryListResult.ResultData;
     }).ConfigureAwait(false));
 }
Ejemplo n.º 18
0
 public IEnumerable <OrderUpdateResponse> UpdateOrderList(OrderUpdateSubmit[] orderUpdates)
 {
     return(AP.CreateSubmit(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Get(() =>
     {
         var results = this._client.UpdateOrderList(this._credentials, this.AccountId, orderUpdates);
         this.CheckCaSuccess(results);
         return results.ResultData;
     }));
 }
Ejemplo n.º 19
0
 public OrderShipmentHistoryResponse[] GetOrderShipmentHistoryList(int[] orderIdList, string[] clientOrderIdentifierList)
 {
     return(AP.CreateSubmit(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Get(() =>
     {
         var result = this._client.GetOrderShipmentHistoryList(this._credentials, this.AccountId, orderIdList, clientOrderIdentifierList);
         this.CheckCaSuccess(result);
         return result.ResultData;
     }));
 }
Ejemplo n.º 20
0
 public async Task <int> SubmitOrderAsync(OrderSubmit orderSubmit)
 {
     return(await AP.CreateSubmitAsync(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Get(async() =>
     {
         var apiResults = await this._client.SubmitOrderAsync(this._credentials, this.AccountId, orderSubmit).ConfigureAwait(false);
         this.CheckCaSuccess(apiResults.SubmitOrderResult);
         return apiResults.SubmitOrderResult.ResultData;
     }).ConfigureAwait(false));
 }
Ejemplo n.º 21
0
 public async Task <IEnumerable <OrderUpdateResponse> > UpdateOrderListAsync(OrderUpdateSubmit[] orderUpdates)
 {
     return(await AP.CreateSubmitAsync(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Get(async() =>
     {
         var results = await this._client.UpdateOrderListAsync(this._credentials, this.AccountId, orderUpdates).ConfigureAwait(false);
         this.CheckCaSuccess(results.UpdateOrderListResult);
         return results.UpdateOrderListResult.ResultData;
     }).ConfigureAwait(false));
 }
Ejemplo n.º 22
0
        private void LogUnexpectedError(OrderCriteria orderCriteria, APIResultOfArrayOfOrderResponseItem orderList, int?pageNumberBy1, string callerMemberName, int attempt)
        {
            var additionalLogInfo = ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo, callerMemberName)();
            var criteria          = string.Format("StatusUpdateFilterBeginTimeGMTField: {0}. StatusUpdateFilterEndTimeGMTField: {1}. Number in sequence for pageSize equal 1 : {2}", orderCriteria.StatusUpdateFilterBeginTimeGMT.GetValueOrDefault(), orderCriteria.StatusUpdateFilterEndTimeGMT.GetValueOrDefault(), pageNumberBy1);
            var message           = "Unexpected Error. Attempt: {0}. Additional info: {1} {2}".FormatWith(attempt, additionalLogInfo, criteria);
            var exception         = new ChannelAdvisorException(orderList.MessageCode, message);

            ChannelAdvisorLogger.LogTraceException(exception);
        }
Ejemplo n.º 23
0
        public void WithdrawListing(IList <string> itemSkus, string withdrawReason)
        {
            if (itemSkus == null || itemSkus.Count == 0)
            {
                return;
            }

            itemSkus.DoWithPages(100, s => AP.CreateSubmit(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Do(() =>
            {
                var result = this._client.WithdrawListings(this._credentials, this.AccountId, s.ToArray(), null, withdrawReason);
                this.CheckCaSuccess(result);
            }));
        }
Ejemplo n.º 24
0
 public async Task MarkOrderShippedAsync(int orderId, string carrierCode, string classCode, string trackingNumber, DateTime dateShipped)
 {
     try
     {
         await AP.CreateSubmitAsync(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Do(async() =>
         {
             var result = await this._client.SubmitOrderShipmentListAsync(this._credentials, this.AccountId, CreateShipmentByOrderId(orderId, carrierCode, classCode, trackingNumber, dateShipped)).ConfigureAwait(false);
             this.CheckCaSuccess(result.SubmitOrderShipmentListResult);
         }).ConfigureAwait(false);
     }
     catch (Exception e)
     {
         throw new MarkOrderShippedException(orderId.ToString(CultureInfo.InvariantCulture), this.AccountId, carrierCode, classCode, trackingNumber, e);
     }
 }
Ejemplo n.º 25
0
 public async Task MarkOrderShippedAsync(string clientOrderId, PartialShipmentContents partialShipmentContents)
 {
     try
     {
         await AP.CreateSubmitAsync(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Do(async() =>
         {
             var result = await this._client.SubmitOrderShipmentListAsync(this._credentials, this.AccountId, CreatePartialShipmentByClientId(clientOrderId, partialShipmentContents)).ConfigureAwait(false);
             this.CheckCaSuccess(result.SubmitOrderShipmentListResult);
         }).ConfigureAwait(false);
     }
     catch (Exception e)
     {
         throw new MarkOrderShippedException(clientOrderId, this.AccountId, partialShipmentContents.CarrierCode, partialShipmentContents.ClassCode, partialShipmentContents.TrackingNumber, e);
     }
 }
Ejemplo n.º 26
0
 public void MarkOrderShipped(string clientOrderId, PartialShipmentContents partialShipmentContents)
 {
     try
     {
         AP.CreateSubmit(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Do(() =>
         {
             var result = this._client.SubmitOrderShipmentList(this._credentials, this.AccountId, CreatePartialShipmentByClientId(clientOrderId, partialShipmentContents));
             this.CheckCaSuccess(result);
         });
     }
     catch (Exception e)
     {
         throw new MarkOrderShippedException(clientOrderId, this.AccountId, partialShipmentContents.CarrierCode, partialShipmentContents.ClassCode, partialShipmentContents.TrackingNumber, e);
     }
 }
Ejemplo n.º 27
0
        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;
            }));
        }
Ejemplo n.º 28
0
        private async Task <OrderResponseItem[]> GetOrdersPageAsync(OrderCriteria orderCriteria, Mark mark = null)
        {
            return(await AP.CreateQueryAsync(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo, mark: mark)).Get(async() =>
            {
                var results = await this._client.GetOrderListAsync(this._credentials, this.AccountId, orderCriteria).ConfigureAwait(false);
                CheckCaSuccess(results.GetOrderListResult);
                var resultData = results.GetOrderListResult.ResultData ?? new OrderResponseItem[0];

                // If you get message code = 1 (Unexpected)
                if (results.GetOrderListResult.MessageCode == 1)
                {
                    resultData = await this.HandleErrorUnexpectedAsync(orderCriteria).ConfigureAwait(false);
                }

                return resultData;
            }).ConfigureAwait(false));
        }
Ejemplo n.º 29
0
        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);
        }
Ejemplo n.º 30
0
        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);
        }