/// <summary> /// Converts a SubmitFeedResponse for the UpdateOrderFulfillment flow into an OrderFulfillmentException if needed. /// </summary> /// <param name="submitFeedResponse">The response object.</param> /// <returns>An exception if an error exists in the response object, else null.</returns> private AmazonOrderRefundException ConvertResultToOrderRefundException(Stream submitFeedResponse) { using (Stream responseStream = submitFeedResponse) { // The result may not be an xml document. This will be revealed with testing. var doc = new XmlDocument(); doc.Load(responseStream); // Check to see if any of the updates had an error else just return fine. var report = doc.SelectSingleNode("/AmazonEnvelope/Message/ProcessingReport"); var errorResults = report.SelectNodes("Result[ResultCode='Error']"); if (errorResults.Count > 0) { var processingSummary = report.SelectSingleNode("ProcessingSummary"); var successCount = int.Parse(processingSummary.SelectSingleNode("MessagesSuccessful").InnerText); var errorCount = int.Parse(processingSummary.SelectSingleNode("MessagesWithError").InnerText); var warningCount = int.Parse(processingSummary.SelectSingleNode("MessagesWithWarning").InnerText); var exception = new AmazonOrderRefundException(string.Format(System.Globalization.CultureInfo.CurrentCulture, "{0} Orders did not update successfully. {1} Orders updated sucessfully. {2} Orders updated with warnings.", errorCount, successCount, warningCount)); foreach (XmlNode result in errorResults) { exception.ErrorResults.Add(new AmazonOrderRefundException.Result() { Code = result.SelectSingleNode("ResultMessageCode").InnerText, Description = result.SelectSingleNode("ResultDescription").InnerText, }); } return(exception); } else { return(null); } } }
/// <summary> /// Converts a SubmitFeedResponse for the UpdateOrderFulfillment flow into an OrderFulfillmentException if needed. /// </summary> /// <param name="submitFeedResponse">The response object.</param> /// <returns>An exception if an error exists in the response object, else null.</returns> private AmazonOrderRefundException ConvertResultToOrderRefundException(Stream submitFeedResponse) { using (Stream responseStream = submitFeedResponse) { // The result may not be an xml document. This will be revealed with testing. var doc = new XmlDocument(); doc.Load(responseStream); // Check to see if any of the updates had an error else just return fine. var report = doc.SelectSingleNode("/AmazonEnvelope/Message/ProcessingReport"); var errorResults = report.SelectNodes("Result[ResultCode='Error']"); if (errorResults.Count > 0) { var processingSummary = report.SelectSingleNode("ProcessingSummary"); var successCount = int.Parse(processingSummary.SelectSingleNode("MessagesSuccessful").InnerText); var errorCount = int.Parse(processingSummary.SelectSingleNode("MessagesWithError").InnerText); var warningCount = int.Parse(processingSummary.SelectSingleNode("MessagesWithWarning").InnerText); var exception = new AmazonOrderRefundException(string.Format(System.Globalization.CultureInfo.CurrentCulture, "{0} Orders did not update successfully. {1} Orders updated sucessfully. {2} Orders updated with warnings.", errorCount, successCount, warningCount)); foreach (XmlNode result in errorResults) { exception.ErrorResults.Add(new AmazonOrderRefundException.Result() { Code = result.SelectSingleNode("ResultMessageCode").InnerText, Description = result.SelectSingleNode("ResultDescription").InnerText, }); } return exception; } else return null; } }