private SubmitFeedResponse InvokeSubmitFeed(SubmitFeedParamaters objParams, string xmlFeedContent)
        {
            SubmitFeedResponse resSubmitFeed = new SubmitFeedResponse();

            try
            {
                UTF8Encoding      encoding   = new UTF8Encoding();
                Stream            streamData = new MemoryStream(encoding.GetBytes(xmlFeedContent));
                SubmitFeedRequest request    = new SubmitFeedRequest();
                request.Merchant             = objParams.objSOAmazonSetup.SellerId;
                request.FeedContent          = streamData;
                request.ContentMD5           = MarketplaceWebServiceClient.CalculateContentMD5(request.FeedContent);
                request.FeedContent.Position = 0;
                request.PurgeAndReplace      = false;
                request.FeedType             = SOConstants.feedTypePostOrderFulfillment;
                request.MWSAuthToken         = objParams.objSOAmazonSetup.AuthToken;
                resSubmitFeed = clientFeed.SubmitFeed(request);
            }
            catch (Exception ex)
            {
                if (ex is MarketplaceWebServiceException)
                {
                    MarketplaceWebServiceException exception = ex as MarketplaceWebServiceException;
                    if (!string.IsNullOrEmpty(exception.ErrorCode) && exception.ErrorCode.ToLower().Trim() == SOMessages.requestThrottled)
                    {
                        Thread.Sleep(SOHelper.DelayProcess(objParams.objPartialMaint, SOConstants.apiSubmitFeed));
                        resSubmitFeed = InvokeSubmitFeed(objParams, xmlFeedContent);
                    }
                    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(resSubmitFeed);
        }
Ejemplo n.º 2
0
        private RequestReportResponse InvokeRequestReport(PXGraph graph, ReportParameters reportParams)
        {
            RequestReportResponse reqReportResponse = new RequestReportResponse();

            try
            {
                RequestReportRequest request          = new RequestReportRequest();
                DateTime?            businessDateTime = PX.Common.PXTimeZoneInfo.Now;
                request.Merchant     = reportParams.objSOAmazonSetup.SellerId;
                request.MWSAuthToken = reportParams.objSOAmazonSetup.AuthToken;
                request.ReportType   = SOConstants.amazonFulfilledShipmentData;
                request.StartDate    = Convert.ToDateTime(reportParams.fromDate);
                request.EndDate      = Convert.ToDateTime(reportParams.toDate).Date >= businessDateTime.Value.Date ? businessDateTime.Value.AddMinutes(-2) : Convert.ToDateTime(reportParams.toDate).AddDays(1);
                reqReportResponse    = clientReports.RequestReport(request);
            }
            catch (Exception ex)
            {
                if (ex is MarketplaceWebServiceException)
                {
                    MarketplaceWebServiceException exception = ex as MarketplaceWebServiceException;
                    if (!string.IsNullOrEmpty(exception.ErrorCode) && exception.ErrorCode.ToLower().Trim() == SOMessages.requestThrottled)
                    {
                        Thread.Sleep(SOHelper.DelayProcess(graph, SOConstants.apiRequestReport));
                        reqReportResponse = InvokeRequestReport(graph, reportParams);
                    }
                    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(reqReportResponse);
        }
Ejemplo n.º 3
0
 public void InvokeGetReport(PXGraph graph, ReportParameters reportParams, MemoryStream ms)
 {
     try
     {
         GetReportRequest request = new GetReportRequest();
         request.Merchant     = reportParams.objSOAmazonSetup.SellerId;
         request.MWSAuthToken = reportParams.objSOAmazonSetup.AuthToken;
         request.ReportId     = reportParams.generatedReportId;
         request.Report       = ms;
         clientReports.GetReport(request);
     }
     catch (Exception ex)
     {
         if (ex is MarketplaceWebServiceException)
         {
             MarketplaceWebServiceException exception = ex as MarketplaceWebServiceException;
             if (!string.IsNullOrEmpty(exception.ErrorCode) && exception.ErrorCode.ToLower().Trim() == SOMessages.requestThrottled)
             {
                 Thread.Sleep(SOHelper.DelayProcess(graph, SOConstants.apiGetReport));
                 InvokeGetReport(graph, reportParams, ms);
             }
             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);
         }
     }
 }
 private void GetSubmitFeedResult(SubmitFeedParamaters objParams, string submissionFeedId, MemoryStream ms)
 {
     try
     {
         GetFeedSubmissionResultRequest request = new GetFeedSubmissionResultRequest();
         request.FeedSubmissionId     = submissionFeedId;
         request.Merchant             = objParams.objSOAmazonSetup.SellerId;
         request.MWSAuthToken         = objParams.objSOAmazonSetup.AuthToken;
         request.FeedSubmissionResult = ms;
         clientFeed.GetFeedSubmissionResult(request);
     }
     catch (Exception ex)
     {
         if (ex is MarketplaceWebServiceException)
         {
             MarketplaceWebServiceException exception = ex as MarketplaceWebServiceException;
             if (!string.IsNullOrEmpty(exception.ErrorCode) && exception.ErrorCode.ToLower().Trim() == SOConstants.feedProcessingResultNotReady)
             {
                 Thread.Sleep(SOHelper.DelayProcess(objParams.objPartialMaint, SOConstants.apiFeedResultWaiting));
                 GetSubmitFeedResult(objParams, submissionFeedId, ms);
             }
             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);
         }
     }
 }
Ejemplo n.º 5
0
        private ReportRequestInfo InvokeGetReportRequestList(PXGraph graph, ReportParameters reportParams)
        {
            GetReportRequestListResponse reqReportListResponse = new GetReportRequestListResponse();

            reportParams.reportInfo = new ReportRequestInfo();
            try
            {
                GetReportRequestListRequest request = new GetReportRequestListRequest();
                request.Merchant     = reportParams.objSOAmazonSetup.SellerId;
                request.MWSAuthToken = reportParams.objSOAmazonSetup.AuthToken;
                request.MaxCount     = 1;
                if (!string.IsNullOrEmpty(reportParams.reportRequestId))
                {
                    IdList liReportIds = new IdList();
                    liReportIds.Id.Add(reportParams.reportRequestId);
                    request.ReportRequestIdList = liReportIds;
                }
                TypeList liReportTypes = new TypeList();
                liReportTypes.Type.Add(SOConstants.amazonFulfilledShipmentData);
                request.ReportTypeList = liReportTypes;
                StatusList liReportStatus = new StatusList();
                liReportStatus.Status.Add(SOConstants.statusDone);
                request.ReportProcessingStatusList = liReportStatus;
                reqReportListResponse = clientReports.GetReportRequestList(request);

                if (reqReportListResponse != null && reqReportListResponse.GetReportRequestListResult != null && reqReportListResponse.GetReportRequestListResult.ReportRequestInfo != null && reqReportListResponse.GetReportRequestListResult.ReportRequestInfo.Count > 0)
                {
                    liReportRequestInfo = reqReportListResponse.GetReportRequestListResult.ReportRequestInfo;
                    foreach (ReportRequestInfo reportRequestInfoItem in liReportRequestInfo)
                    {
                        if (reportRequestInfoItem.GeneratedReportId == null && string.IsNullOrEmpty(reportRequestInfoItem.GeneratedReportId) && reportRequestInfoItem.ReportProcessingStatus == SOConstants.statusInProgress || reportRequestInfoItem.ReportProcessingStatus == SOConstants.statusSubmitted)
                        {
                            Thread.Sleep(SOHelper.DelayProcess(graph, SOConstants.getGeneratedReportID));
                            reportParams.reportInfo = InvokeGetReportRequestList(graph, reportParams);
                        }
                        else if (reportRequestInfoItem.GeneratedReportId != null && !string.IsNullOrEmpty(reportRequestInfoItem.GeneratedReportId) && reportRequestInfoItem.ReportProcessingStatus == SOConstants.statusDone)
                        {
                            reportParams.reportInfo = reportRequestInfoItem;
                            break;
                        }
                    }
                }
                else
                {
                    RequestAndGetReportData(graph, reportParams);
                }
            }
            catch (Exception ex)
            {
                if (ex is MarketplaceWebServiceException)
                {
                    MarketplaceWebServiceException exception = ex as MarketplaceWebServiceException;
                    if (!string.IsNullOrEmpty(exception.ErrorCode) && exception.ErrorCode.ToLower().Trim() == SOMessages.requestThrottled)
                    {
                        Thread.Sleep(SOHelper.DelayProcess(graph, SOConstants.apiGetRequestReportList));
                        reportParams.reportInfo = InvokeGetReportRequestList(graph, reportParams);
                    }
                    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(reportParams.reportInfo);
        }