Esempio n. 1
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);
        }
        public RequestReportResult RequestReport(string reportType, DateTime startDate, DateTime endDate, string reportOptions = "")
        {
            if (string.IsNullOrWhiteSpace(reportType))
            {
                throw new ArgumentNullException("reportType is empty");
            }

            nLogger.Info(string.Format("RequestReport start for reportType: {0}, startDate: {1}, endDate: {2}", reportType, startDate, endDate));

            RequestReportRequest request = new RequestReportRequest();

            request.ReportType    = reportType;
            request.Merchant      = serviceContext.SellerId;;
            request.MWSAuthToken  = serviceContext.MwsAuthToken;;             // Optional
            request.StartDate     = startDate;
            request.EndDate       = endDate;
            request.ReportOptions = reportOptions;
            RequestReportResponse response = service.RequestReport(request);

            return(response.RequestReportResult);
        }