public GetReportResult GetReport(string reportId)
        {
            if (string.IsNullOrWhiteSpace(reportId))
            {
                throw new ArgumentNullException("reportId is empty");
            }

            nLogger.Info("GetReport for : " + reportId);

            GetReportRequest req = new GetReportRequest();

            req.MWSAuthToken = serviceContext.MwsAuthToken;
            if (string.IsNullOrEmpty(req.MWSAuthToken))
            {
                req.MWSAuthToken = "MWSAuthToken";
            }
            req.Merchant = serviceContext.SellerId;
            req.ReportId = reportId;

            GetReportResponse response = null;

            try
            {
                response = service.GetReport(req);
            }
            catch (Exception e)
            {
                nLogger.Error("GetReport Failed");
                throw;
            }

            return(response.GetReportResult);
        }
Exemple #2
0
        /// <summary>
        /// The GetReport operation returns the contents of a report. Reports can potentially be
        /// very large (>100MB) which is why we only return one report at a time, and in a
        /// streaming fashion.
        ///
        /// </summary>
        /// <param name="service">Instance of MarketplaceWebService service</param>
        /// <param name="request">GetReportRequest request</param>
        private static void invokeGetReport(MarketplaceWebService.MarketplaceWebService service, GetReportRequest request)
        {
            try
            {
                Console.WriteLine("Downloading report...");

                GetReportResponse response = service.GetReport(request);

                Console.WriteLine("Downloaded!");
            }
            catch (MarketplaceWebServiceException ex)
            {
                Console.WriteLine("Caught Exception: " + ex.Message);
                Console.WriteLine("Please try again in a couple of minutes.");  //Exception might be because of Amazon's limit of downloading a report once a minute. Try in a couple of min.
            }
        }
Exemple #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);
         }
     }
 }