/// <summary> /// Get a ReportRequestInfo for a reportRequestId /// </summary> /// <param name="reportRequestId"></param> /// <returns></returns> public ReportRequestInfo GetReportRequestInfo(string reportRequestId) { if (string.IsNullOrWhiteSpace(reportRequestId)) { throw new ArgumentNullException("reportRequestId is empty"); } nLogger.Info("GetReportRequestResult start"); GetReportRequestListResult reportRequestList = GetReportRequestList(); return(reportRequestList.ReportRequestInfo.FirstOrDefault(rr => rr.ReportRequestId == reportRequestId)); }
public void GetReportRequestListTest() { GetReportRequestListResult response = reportHandler.GetReportRequestList(); Assert.IsTrue(response.ReportRequestInfo.Count > 0); foreach (var item in response.ReportRequestInfo) { Console.WriteLine("ReportRequestId: " + item.ReportRequestId); Console.WriteLine("ReportType: " + item.ReportType); Console.WriteLine("GeneratedReportId: " + item.GeneratedReportId); Console.WriteLine("SubmittedDate: " + item.SubmittedDate); Console.WriteLine("ReportProcessingStatus: " + item.ReportProcessingStatus); Console.WriteLine("---------------------------------------------- "); } //50033017756 }
/// <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 void InvokeGetReportRequestList(MarketplaceWebService service, GetReportRequestListRequest request) { try { GetReportRequestListResponse response = service.GetReportRequestList(request); Console.WriteLine("Service Response"); Console.WriteLine("============================================================================="); Console.WriteLine(); Console.WriteLine(" GetReportRequestListResponse"); if (response.IsSetGetReportRequestListResult()) { Console.WriteLine(" GetReportRequestListResult"); GetReportRequestListResult getReportRequestListResult = response.GetReportRequestListResult; List <ReportRequestInfo> reportRequestInfoList = getReportRequestListResult.ReportRequestInfo; foreach (ReportRequestInfo reportRequestInfo in reportRequestInfoList) { 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.IsSetGeneratedReportId()) { Console.WriteLine(" GeneratedReportId"); Console.WriteLine(" {0}", reportRequestInfo.GeneratedReportId); } 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"); ResponseMetadata 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); } }
public static DataTable GetAmazonReportRequestList(string accountName, string merchantId, string marketplaceId, string accessKeyId, string secretAccessKey) { string senderEmail = ConfigurationManager.AppSettings["senderEmail"]; string messageFromPassword = ConfigurationManager.AppSettings["messageFromPassword"]; string messageToEmail = ConfigurationManager.AppSettings["messageToEmail"]; string smtpClient = ConfigurationManager.AppSettings["smtpClient"]; int smtpPortNum = ConvertUtility.ToInt(ConfigurationManager.AppSettings["smtpPortNum"]); DataTable GeneratedReportDt = new DataTable(); GeneratedReportDt.Columns.Add("ReportRequestId", typeof(System.String)); GeneratedReportDt.Columns.Add("ReportGenerateId", typeof(System.String)); GeneratedReportDt.Columns.Add("Status", typeof(System.String)); GetReportRequestListRequest request = new GetReportRequestListRequest(); request.Merchant = merchantId; const string applicationName = "<Your Application Name>"; const string applicationVersion = "<Your Application Version>"; MarketplaceWebServiceConfig config = new MarketplaceWebServiceConfig(); config.ServiceURL = "https://mws.amazonservices.com"; config.SetUserAgentHeader( applicationName, applicationVersion, "C#", "<Parameter 1>", "<Parameter 2>"); request.MaxCount = 3; MarketplaceWebService.MarketplaceWebService service = new MarketplaceWebServiceClient(accessKeyId, secretAccessKey, config); try { GetReportRequestListResponse response = service.GetReportRequestList(request); Console.WriteLine("Service Response"); Console.WriteLine("============================================================================="); Console.WriteLine(); Console.WriteLine(" GetReportRequestListResponse"); if (response.IsSetGetReportRequestListResult()) { Console.WriteLine(" GetReportRequestListResult"); GetReportRequestListResult getReportRequestListResult = response.GetReportRequestListResult; List <ReportRequestInfo> reportRequestInfoList = getReportRequestListResult.ReportRequestInfo; foreach (ReportRequestInfo reportRequestInfo in reportRequestInfoList) { DataRow GeneratedReportDr = GeneratedReportDt.NewRow(); Console.WriteLine(" ReportRequestInfo"); if (reportRequestInfo.IsSetReportProcessingStatus()) { Console.WriteLine(" ReportProcessingStatus"); Console.WriteLine(" {0}", reportRequestInfo.ReportProcessingStatus); GeneratedReportDr["Status"] = reportRequestInfo.ReportProcessingStatus; } if (reportRequestInfo.IsSetReportRequestId()) { Console.WriteLine(" ReportRequestId"); Console.WriteLine(" {0}", reportRequestInfo.ReportRequestId); GeneratedReportDr["ReportRequestId"] = reportRequestInfo.ReportRequestId; } if (reportRequestInfo.IsSetGeneratedReportId()) { Console.WriteLine(" GeneratedReportId"); Console.WriteLine(" {0}", reportRequestInfo.GeneratedReportId); GeneratedReportDr["ReportGenerateId"] = reportRequestInfo.GeneratedReportId; } 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); } GeneratedReportDt.Rows.Add(GeneratedReportDr); } } if (response.IsSetResponseMetadata()) { Console.WriteLine(" ResponseMetadata"); ResponseMetadata 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) { ExceptionUtility exceptionUtility = new ExceptionUtility(); exceptionUtility.CatchMethod(ex, "GetAmazonReportRequestList ", accountName + " " + ex.Message.ToString(), senderEmail, messageFromPassword, messageToEmail, smtpClient, smtpPortNum); } return(GeneratedReportDt); }
public void GetReports(string reportType) { try { MarketplaceWebServiceClient service = new MarketplaceWebServiceClient(accessKeyId, secretAccessKey, applicationName, applicationVersion, config); RequestReportRequest reportRequestRequest = new RequestReportRequest(); reportRequestRequest.Merchant = sellerId; reportRequestRequest.MWSAuthToken = mwsAuthToken; reportRequestRequest.MarketplaceIdList = new IdList(); reportRequestRequest.MarketplaceIdList.Id.Add("ATVPDKIKX0DER"); reportRequestRequest.ReportType = "_GET_FLAT_FILE_OFFAMAZONPAYMENTS_SANDBOX_SETTLEMENT_DATA_"; // you can change ReportType here: //http://docs.developer.amazonservices.com/en_IN/reports/Reports_ReportType.html RequestReportResponse requestResponse = service.RequestReport(reportRequestRequest); IdList lstRequestID = new IdList(); lstRequestID.Id.Add(requestResponse.RequestReportResult.ReportRequestInfo.ReportRequestId); GetReportRequestListRequest reportRequestListRequest = new GetReportRequestListRequest(); reportRequestListRequest.Merchant = sellerId; reportRequestListRequest.ReportRequestIdList = lstRequestID; reportRequestListRequest.MWSAuthToken = mwsAuthToken; List <ReportRequestInfo> myListzz = new List <ReportRequestInfo>(); GetReportRequestListResponse reportRequestListResponse = new GetReportRequestListResponse(); reportRequestListResponse = service.GetReportRequestList(reportRequestListRequest); GetReportRequestListResult reportRequestListResult = new GetReportRequestListResult(); reportRequestListResult = reportRequestListResponse.GetReportRequestListResult; myListzz = reportRequestListResult.ReportRequestInfo; if (myListzz.Count > 0) { while (myListzz[0].ReportProcessingStatus.ToString() != "_DONE_") { Console.WriteLine("Waiting for Report"); Thread.Sleep(60000); reportRequestListResponse = service.GetReportRequestList(reportRequestListRequest); reportRequestListResult = reportRequestListResponse.GetReportRequestListResult; myListzz = reportRequestListResult.ReportRequestInfo; } } //if (myListzz[0].GeneratedReportId == null) { // GetReportListRequest reportListRequest = new GetReportListRequest(); // reportListRequest.Merchant = sellerId; // reportListRequest.MWSAuthToken = mwsAuthToken; // reportListRequest.ReportRequestIdList = lstRequestID; // reportListRequest.ReportTypeList = new TypeList(); // reportListRequest.ReportTypeList.Type = new List<string>() { "_GET_MERCHANT_LISTINGS_ALL_DATA_" }; // var reportList = service.GetReportList(reportListRequest); // if (myListzz.Count > 0) // { // GetReportRequest reportRequest = new GetReportRequest(); // reportRequest.Merchant = sellerId; // reportRequest.MWSAuthToken = mwsAuthToken; // reportRequest.ReportId = myListzz[0].GeneratedReportId; // var report = service.GetReport(reportRequest); // } //} //if (myListzz.Count > 0) //{ // while (myListzz[0].ReportProcessingStatus.ToString() != "_DONE_") // { // Console.WriteLine("Waiting for Report"); // //Thread.Sleep(61000); // reportRequestListResponse = // service.GetReportRequestList(reportRequestListRequest); // reportRequestListResult = // reportRequestListResponse.GetReportRequestListResult; // myListzz = reportRequestListResult.ReportRequestInfo; // } // if (myListzz[0].GeneratedReportId != null) // { // GetReportRequest reportRequest = new GetReportRequest(); // reportRequest.Merchant = sellerId; // String source = "C:\\myreport.txt"; // reportRequest.ReportId = myListzz[0].GeneratedReportId; // // reportRequest.Report = File.Open(source, FileMode.Create, FileAccess.ReadWrite); // service.GetReport(reportRequest); // } //} } catch (Exception ex) { var msg = ex.Message; } }