Esempio n. 1
0
        private ListOrdersResponse InvokeListOrders(PXGraph graph, ServiceCallParameters objParams)
        {
            ListOrdersResponse response = new ListOrdersResponse();

            try
            {
                ListOrdersRequest request = new ListOrdersRequest();
                request.SellerId     = objParams.objSOAmazonSetup.SellerId;
                request.MWSAuthToken = objParams.objSOAmazonSetup.AuthToken;
                List <string> marketplaceId = new List <string>();
                marketplaceId.Add(objParams.objSOAmazonSetup.MarketplaceId);
                request.MarketplaceId = marketplaceId;
                request.CreatedAfter  = Convert.ToDateTime(objParams.fromDate);
                if (objParams.toDate.Value.Date < DateTime.Now.Date)
                {
                    request.CreatedBefore = objParams.toDate.Value.AddDays(1).AddTicks(-1);
                }
                PXTrace.WriteInformation("objParams.fromDate.Value.Date:" + objParams.fromDate.Value.Date.ToString());
                PXTrace.WriteInformation("objParams.toDate.Value.Date:" + objParams.toDate.Value.Date.ToString());
                PXTrace.WriteInformation("request.CreatedAfter:" + request.CreatedAfter.ToString());
                PXTrace.WriteInformation("request.CreatedBefore:" + request.CreatedBefore.ToString());
                List <string> liFulfillmentChannel = null;
                List <string> liOrderStatus        = null;
                SOHelper.GetFilterValues(objParams.objSOAmazonSetup.IntegrationType.Trim(), out liFulfillmentChannel, out liOrderStatus);
                request.FulfillmentChannel = liFulfillmentChannel;
                request.OrderStatus        = liOrderStatus;
                response = this.clientOrder.ListOrders(request);
            }
            catch (Exception ex)
            {
                if (ex is MarketplaceWebServiceOrdersException)
                {
                    MarketplaceWebServiceOrdersException exception = ex as MarketplaceWebServiceOrdersException;
                    if (!string.IsNullOrEmpty(exception.ErrorCode) && exception.ErrorCode.ToLower().Trim() == SOMessages.requestThrottled)
                    {
                        Thread.Sleep(SOHelper.DelayProcess(graph, SOConstants.apiListOrders));
                        response = InvokeListOrders(graph, objParams);
                    }
                    else
                    {
                        throw new PXException(!string.IsNullOrEmpty(ex.Message) ? ex.Message :
                                              ex.InnerException != null && ex.InnerException.InnerException != null ? ex.InnerException.InnerException.Message
                           : SOConstants.exceptionIsEmpty);
                    }
                }
                else
                {
                    throw new PXException(!string.IsNullOrEmpty(ex.Message) ? ex.Message :
                                          ex.InnerException != null && ex.InnerException.InnerException != null ? ex.InnerException.InnerException.Message
                            : SOConstants.exceptionIsEmpty);
                }
            }
            return(response);
        }
Esempio n. 2
0
        private GetOrderResponse InvokeGetOrder(PXGraph graph, ServiceCallParameters objParams)
        {
            GetOrderResponse getOrderRes = new GetOrderResponse();

            try
            {
                GetOrderRequest request = new GetOrderRequest();
                request.SellerId     = objParams.objSOAmazonSetup.SellerId;
                request.MWSAuthToken = objParams.objSOAmazonSetup.AuthToken;
                List <string> liAmazonOrderId = new List <string>();
                if (!string.IsNullOrEmpty(objParams.amwOrderID))
                {
                    liAmazonOrderId.Add(objParams.amwOrderID);
                }
                request.AmazonOrderId = liAmazonOrderId;
                getOrderRes           = this.clientOrder.GetOrder(request);
            }
            catch (Exception ex)
            {
                if (ex is MarketplaceWebServiceOrdersException)
                {
                    MarketplaceWebServiceOrdersException exception = ex as MarketplaceWebServiceOrdersException;
                    if (!string.IsNullOrEmpty(exception.ErrorCode) && exception.ErrorCode.ToLower().Trim() == SOMessages.requestThrottled)
                    {
                        Thread.Sleep(SOHelper.DelayProcess(graph, SOConstants.apiGetOrder));
                        getOrderRes = InvokeGetOrder(graph, objParams);
                    }
                    else
                    {
                        throw new PXException(!string.IsNullOrEmpty(ex.Message) ? ex.Message :
                                              ex.InnerException != null && ex.InnerException.InnerException != null ? ex.InnerException.InnerException.Message
                            : SOConstants.exceptionIsEmpty);
                    }
                }
                else
                {
                    throw new PXException(!string.IsNullOrEmpty(ex.Message) ? ex.Message :
                                          ex.InnerException != null && ex.InnerException.InnerException != null ? ex.InnerException.InnerException.Message
                           : SOConstants.exceptionIsEmpty);
                }
            }
            return(getOrderRes);
        }
Esempio n. 3
0
        private ListOrderItemsResponse GetSalesOrderLineItems(PXGraph graph, ServiceCallParameters objParams)
        {
            ListOrderItemsResponse lineItemsRes = new ListOrderItemsResponse();

            try
            {
                ListOrderItemsRequest request = new ListOrderItemsRequest();
                request.SellerId      = objParams.objSOAmazonSetup.SellerId;
                request.MWSAuthToken  = objParams.objSOAmazonSetup.AuthToken;
                request.AmazonOrderId = objParams.amwOrderID;
                lineItemsRes          = this.clientOrder.ListOrderItems(request);
            }
            catch (Exception ex)
            {
                if (ex is MarketplaceWebServiceOrdersException)
                {
                    MarketplaceWebServiceOrdersException exception = ex as MarketplaceWebServiceOrdersException;
                    if (!string.IsNullOrEmpty(exception.ErrorCode) && exception.ErrorCode.ToLower().Trim() == SOMessages.requestThrottled)
                    {
                        Thread.Sleep(SOHelper.DelayProcess(graph, SOConstants.apiGetListOrderItems));
                        lineItemsRes = GetSalesOrderLineItems(graph, objParams);
                    }
                    else
                    {
                        throw new PXException(!string.IsNullOrEmpty(ex.Message) ? ex.Message :
                                              ex.InnerException != null && ex.InnerException.InnerException != null ? ex.InnerException.InnerException.Message
                            : SOConstants.exceptionIsEmpty);
                    }
                }
                else
                {
                    throw new PXException(!string.IsNullOrEmpty(ex.Message) ? ex.Message :
                                          ex.InnerException != null && ex.InnerException.InnerException != null ? ex.InnerException.InnerException.Message
                            : SOConstants.exceptionIsEmpty);
                }
            }
            return(lineItemsRes);

            #endregion
        }
Esempio n. 4
0
        public ListOrdersByNextTokenResponse InvokeListOrdersByNextToken(PXGraph graph, ServiceCallParameters objParams)
        {
            ListOrdersByNextTokenRequest  request = new ListOrdersByNextTokenRequest();
            ListOrdersByNextTokenResponse responseOrderByNextToken = new ListOrdersByNextTokenResponse();

            try
            {
                request.SellerId         = objParams.objSOAmazonSetup.SellerId;
                request.MWSAuthToken     = objParams.objSOAmazonSetup.AuthToken;
                request.NextToken        = objParams.nextToken;
                responseOrderByNextToken = this.clientOrder.ListOrdersByNextToken(request);
            }
            catch (Exception ex)
            {
                if (ex is MarketplaceWebServiceOrdersException)
                {
                    MarketplaceWebServiceOrdersException exception = ex as MarketplaceWebServiceOrdersException;
                    if (!string.IsNullOrEmpty(exception.ErrorCode) && exception.ErrorCode.ToLower().Trim() == SOMessages.requestThrottled)
                    {
                        Thread.Sleep(SOHelper.DelayProcess(graph, SOConstants.apiListOrdersByNextToken));
                        responseOrderByNextToken = InvokeListOrdersByNextToken(graph, objParams);
                    }
                    else
                    {
                        throw new PXException(!string.IsNullOrEmpty(ex.Message) ? ex.Message :
                                              ex.InnerException != null && ex.InnerException.InnerException != null ? ex.InnerException.InnerException.Message
                            : SOConstants.exceptionIsEmpty);
                    }
                }
                else
                {
                    throw new PXException(!string.IsNullOrEmpty(ex.Message) ? ex.Message :
                                          ex.InnerException != null && ex.InnerException.InnerException != null ? ex.InnerException.InnerException.Message
                            : SOConstants.exceptionIsEmpty);
                }
            }
            return(responseOrderByNextToken);
        }