private void RequestReports(RequestsListInfo reportRequestList)
        {
            var marketplaceIdList = new IdList {
                Id = reportRequestList.MarketPlaceId
            };
            var access = reportRequestList.Access;

            foreach (var requestInfo in reportRequestList)
            {
                var reportType = requestInfo.Name;

                var requestReportRequest = new RequestReportRequest {
                    MarketplaceIdList = marketplaceIdList,
                    Merchant          = reportRequestList.UserId,
                    ReportOptions     = "ShowSalesChannel=true",
                    ReportType        = reportType
                };

                if (reportRequestList.StartDate.HasValue)
                {
                    requestReportRequest.StartDate = reportRequestList.StartDate.Value.ToUniversalTime();
                }

                if (reportRequestList.EndDate.HasValue)
                {
                    requestReportRequest.EndDate = reportRequestList.EndDate.Value.ToUniversalTime();
                }

                RequestInfo info = requestInfo;

                var resp = AmazonWaitBeforeRetryHelper.DoServiceAction(
                    reportRequestList.ErrorRetryingInfo,
                    RequestGetReportTrapForThrottling,
                    reportType,
                    access,
                    reportRequestList.RequestsCounter,
                    () => _Service.RequestReport(requestReportRequest),
                    "RequestReport");

                if (resp != null && resp.IsSetRequestReportResult())
                {
                    info.SetId(resp.RequestReportResult.ReportRequestInfo.ReportRequestId);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// returns the number of feeds matching all of the specified criteria.
        ///
        /// </summary>
        /// <param name="service">Instance of MarketplaceWebService service.</param>
        /// <param name="request">GetFeedSubmissionCountRequest request.</param>
        public static async Task InvokeRequestReport(IMarketplaceWebService service, RequestReportRequest request)
        {
            try
            {
                var response = await service.RequestReport(request);

                Console.WriteLine("Service Response");
                Console.WriteLine("=============================================================================");
                Console.WriteLine();

                Console.WriteLine("        RequestReportResponse");

                if (response.IsSetRequestReportResult())
                {
                    Console.WriteLine("            RequestReportResult");
                    var requestReportResult = response.RequestReportResult;
                    var reportRequestInfo   = requestReportResult.ReportRequestInfo;
                    Console.WriteLine("                  ReportRequestInfo");

                    if (reportRequestInfo.IsSetReportProcessingStatus())
                    {
                        Console.WriteLine("               ReportProcessingStatus");
                        Console.WriteLine("                                  {0}", reportRequestInfo.ReportProcessingStatus);
                    }

                    if (reportRequestInfo.IsSetReportRequestId())
                    {
                        Console.WriteLine("                      ReportRequestId");
                        Console.WriteLine("                                  {0}", reportRequestInfo.ReportRequestId);
                    }

                    if (reportRequestInfo.IsSetReportType())
                    {
                        Console.WriteLine("                           ReportType");
                        Console.WriteLine("                                  {0}", reportRequestInfo.ReportType);
                    }

                    if (reportRequestInfo.IsSetStartDate())
                    {
                        Console.WriteLine("                            StartDate");
                        Console.WriteLine("                                  {0}", reportRequestInfo.StartDate);
                    }

                    if (reportRequestInfo.IsSetEndDate())
                    {
                        Console.WriteLine("                              EndDate");
                        Console.WriteLine("                                  {0}", reportRequestInfo.EndDate);
                    }

                    if (reportRequestInfo.IsSetSubmittedDate())
                    {
                        Console.WriteLine("                        SubmittedDate");
                        Console.WriteLine("                                  {0}", reportRequestInfo.SubmittedDate);
                    }
                }

                if (response.IsSetResponseMetadata())
                {
                    Console.WriteLine("            ResponseMetadata");
                    var responseMetadata = response.ResponseMetadata;
                    if (responseMetadata.IsSetRequestId())
                    {
                        Console.WriteLine("                RequestId");
                        Console.WriteLine("                    {0}", responseMetadata.RequestId);
                    }
                }

                Console.WriteLine("            ResponseHeaderMetadata");
                Console.WriteLine("                RequestId");
                Console.WriteLine("                    " + response.ResponseHeaderMetadata.RequestId);
                Console.WriteLine("                ResponseContext");
                Console.WriteLine("                    " + response.ResponseHeaderMetadata.ResponseContext);
                Console.WriteLine("                Timestamp");
                Console.WriteLine("                    " + response.ResponseHeaderMetadata.Timestamp);
            }
            catch (MarketplaceWebServiceException ex)
            {
                Console.WriteLine("Caught Exception: " + ex.Message);
                Console.WriteLine("Response Status Code: " + ex.StatusCode);
                Console.WriteLine("Error Code: " + ex.ErrorCode);
                Console.WriteLine("Error Type: " + ex.ErrorType);
                Console.WriteLine("Request ID: " + ex.RequestId);
                Console.WriteLine("XML: " + ex.XML);
                Console.WriteLine("ResponseHeaderMetadata: " + ex.ResponseHeaderMetadata);
            }
        }