Пример #1
0
        public MarketplaceWebServiceClient GetMWSClient()
        {
            MarketplaceWebServiceConfig config = new MarketplaceWebServiceConfig();

            config.ServiceURL = "https://mws.amazonservices.com";

            config.SetUserAgentHeader(
                "berkeley",
                "1.0",
                "C#",
                "<Parameter 1>", "<Parameter 2>");


            MarketplaceWebServiceClient service =
                new MarketplaceWebServiceClient(
                    this.AccessKeyId,
                    this.SecretAccessKey,
                    "berkeley",
                    "1.0",
                    config);



            return(service);
        }
        private static void Test()
        {
            var config = new MarketplaceWebServiceConfig();

            config.SetUserAgentHeader( "", "", "C#" );

            config.ServiceURL = "https://mws.amazonservices.com";

            MarketplaceWebService service = new MarketplaceWebServiceClient(
                Secret.AwsAccessKeyId,
                Secret.AwsSecretAccessKey,
                config );

            var request = new SubmitFeedRequest {
                Merchant = Secret.MerchantId,
                MWSAuthToken = null,//"",
                MarketplaceIdList = new IdList { Id = new List< string >( new string[] { Secret.MarketplaceId } ) },
                FeedContent = File.Open( Filename, FileMode.Open, FileAccess.Read ),
                FeedType = FeedType
            };
            request.ContentMD5 = MarketplaceWebServiceClient.CalculateContentMD5( request.FeedContent );
            request.FeedContent.Position = 0;

            SubmitFeedSample.InvokeSubmitFeed( service, request );
        }
Пример #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Preparing application...");

            string accessKeyId        = "<Your AWS Access Key>";
            string secretAccessKey    = "<Your AWS Secret Key>";
            string applicationName    = "<Your Application Name>";
            string applicationVersion = "<Your Application Version>";
            string merchantId         = "<Your Merchant ID>";
            string marketplaceId      = "<Your Marketplace ID>";

            MarketplaceWebServiceConfig config = new MarketplaceWebServiceConfig();

            config.ServiceURL = "https://mws.amazonservices.com";

            Console.WriteLine("Contacting Amazon web services...");

            config.SetUserAgentHeader(
                applicationName,
                applicationVersion,
                "C#",
                "<Parameter 1>", "<Parameter 2>");
            MarketplaceWebService.MarketplaceWebService service = new MarketplaceWebServiceClient(accessKeyId, secretAccessKey, config);

            Console.WriteLine("Service client created. Downloading settlement report...");

            DownloadSettlementReport(service, merchantId);

            Console.Read();
        }
Пример #4
0
        private MarketplaceWebServiceClient GetMwsClient()
        {
            var mwsConfig = new MarketplaceWebServiceConfig();

            mwsConfig.ServiceURL = "https://mws.amazonservices.com";
            mwsConfig.SetUserAgentHeader("Eshopo LLC", "1.0", "C#", null);

            return(new MarketplaceWebServiceClient(_awsAccessKey, _secretKey, mwsConfig));
        }
Пример #5
0
        public AmazonMarketplaceReportProvider()
        {
            // create configuratin to use US marketplace
            var config = new MarketplaceWebServiceConfig {
                ServiceURL = RequestHelper.ServiceUrl
            };

            config.SetUserAgentHeader("EIS Inventory System", "3.0", "C#");

            _amazonClient = new MarketplaceWebServiceClient("AKIAJDQNAJIEJ2XZWVQA",
                                                            "iRJplr+w2vZ1felGmV/OuUqOSreEyAx6c7o8nF3J",
                                                            config);
        }
Пример #6
0
        /// <summary>
        /// Default public contructor. All properties are set via the config file
        /// </summary>
        public AmazonIntegration()
        {
            // Verify that the settings in the config file are setup correctly.
            if (string.IsNullOrWhiteSpace(_AccessKeyId))
            {
                throw new InvalidOperationException("AWSAccessKeyId setting in the config file can't be whitespace, blank or null");
            }
            if (string.IsNullOrWhiteSpace(_SecretAccessKey))
            {
                throw new InvalidOperationException("AWSSecretAccessKey setting in the config file can't be whitespace, blank or null");
            }
            if (string.IsNullOrWhiteSpace(_ApplicationName))
            {
                throw new InvalidOperationException("AWSApplicationName setting in the config file can't be whitespace, blank or null");
            }
            if (string.IsNullOrWhiteSpace(_ApplicationVersion))
            {
                throw new InvalidOperationException("AWSApplicationVersion setting in the config file can't be whitespace, blank or null");
            }
            if (string.IsNullOrWhiteSpace(_MerchantId))
            {
                throw new InvalidOperationException("AWSMerchantId setting in the config file can't be whitespace, blank or null");
            }
            if (string.IsNullOrWhiteSpace(_MarketplaceId))
            {
                throw new InvalidOperationException("AWSMarketplaceId setting in the config file can't be whitespace, blank or null");
            }
            if (string.IsNullOrWhiteSpace(_TemporaryFileDirectory))
            {
                throw new InvalidOperationException("TempFileDirectory setting in the config file can't be whitespace, blank or null");
            }

            var config = new MarketplaceWebServiceConfig();

            // Set configuration to use US marketplace
            config.ServiceURL = "https://mws.amazonservices.com";
            // Set the HTTP Header for user agent for the application.
            config.SetUserAgentHeader(
                _ApplicationName,
                _ApplicationVersion,
                "C#");
            _AmazonClient = new MarketplaceWebServiceClient(_AccessKeyId, _SecretAccessKey, config);

            // Setup the orders service client
            var ordersConfig = new MarketplaceWebServiceOrdersConfig();

            ordersConfig.ServiceURL = "https://mws.amazonservices.com/Orders/2011-01-01";
            ordersConfig.SetUserAgent(_ApplicationName, _ApplicationVersion);
            _AmazonOrdersClient = new MarketplaceWebServiceOrdersClient(
                _ApplicationName, _ApplicationVersion, _AccessKeyId, _SecretAccessKey, ordersConfig);
        }
Пример #7
0
        public AmazonReportController()
        {
            // init the reports directory
            _reportsDirectory = ConfigurationManager.AppSettings["ReportsPath"].ToString();
            _merchantId       = ConfigurationManager.AppSettings["MerchantId"].ToString();
            _accessKeyId      = ConfigurationManager.AppSettings["AccessKeyId"].ToString();
            _secretAccessKey  = ConfigurationManager.AppSettings["SecretAccessKey"].ToString();

            // create configuratin to use US marketplace
            var config = new MarketplaceWebServiceConfig {
                ServiceURL = "https://mws.amazonservices.com"
            };

            config.SetUserAgentHeader("EIS Reports Service", "3.0", "C#");
            _amazonClient = new MarketplaceWebServiceClient(_accessKeyId, _secretAccessKey, config);
        }
Пример #8
0
        public MwsProductsApi(string sellerId, string marketPlaceId, string accessKeyId, string secretAccessKeyId, string serviceUrl)
        {
            m_sellerId      = sellerId;
            m_marketPlaceId = marketPlaceId;

            MarketplaceWebServiceProductsConfig config = new MarketplaceWebServiceProductsConfig {
                ServiceURL = serviceUrl
            };

            m_productClient = new MarketplaceWebServiceProductsClient(string.Empty, string.Empty, accessKeyId, secretAccessKeyId, config);

            MarketplaceWebServiceConfig configService = new MarketplaceWebServiceConfig()
                                                        .WithServiceURL("https://mws.amazonservices.com");

            configService.SetUserAgentHeader(string.Empty, string.Empty, "C#");

            m_service = new MarketplaceWebServiceClient(accessKeyId, secretAccessKeyId, configService);
        }
Пример #9
0
        public MwsFeedsApi(string sellerId, string marketPlaceId, string accessKeyId, string secretAccessKeyId, string merchantIdentifier)
        {
            m_merchantId    = sellerId;
            m_marketPlaceId = marketPlaceId;

            m_merchantId         = sellerId;
            m_merchantIdentifier = merchantIdentifier;

            const string serviceUrl = "https://mws.amazonservices.com";

            MarketplaceWebServiceConfig config = new MarketplaceWebServiceConfig {
                ServiceURL = serviceUrl
            };

            config.ServiceURL = serviceUrl;
            config.SetUserAgentHeader("applicationName", "applicationVersion", "C#", "<Parameter 1>", "<Parameter 1>");

            m_service = new MarketplaceWebServiceClient(accessKeyId, secretAccessKeyId, config);
        }
Пример #10
0
        public bool ConfirmOrdersShipment()
        {
            // init the Amazon order API
            var config = new MarketplaceWebServiceConfig {
                ServiceURL = "https://mws.amazonservices.com"
            };

            config.SetUserAgentHeader(_ApplicationName, _Version, "C#");
            var serviceClient        = new MarketplaceWebServiceClient(_credential.AccessKeyId, _credential.SecretKey, config);
            var orderFulfillmentList = new List <OrderFulfillment>();

            // get the unshipped orders with tracking number for confirming its shipment
            var unshippedOrderFeeds = _orderRepository.GetUnshippedOrdersForShipment(ChannelName);

            if (!unshippedOrderFeeds.Any())
            {
                Console.WriteLine("No unshipped orders found from {0} for shipment confirmation.", ChannelName);
                return(true);
            }

            try
            {
                Console.WriteLine("Sending {0} orders for shipment confirmation...", unshippedOrderFeeds.Count);

                // create the order fulfillment
                unshippedOrderFeeds.ForEach(order =>
                {
                    // create fulfillment item list from the order items
                    var fulfillmentItems = new List <OrderFulfillmentItem>();
                    foreach (var item in order.OrderItems)
                    {
                        fulfillmentItems.Add(new OrderFulfillmentItem
                        {
                            Item     = item.OrderItemId,
                            Quantity = item.Quantity.ToString()
                        });
                    }

                    // then, the order fulfillment information
                    orderFulfillmentList.Add(new OrderFulfillment
                    {
                        Item            = order.OrderId,
                        FulfillmentDate = order.FulfillmentDate,
                        FulfillmentData = new OrderFulfillmentFulfillmentData
                        {
                            Item                  = order.Carrier.Code,
                            ShippingMethod        = "Ground", // order.ShippingMethod,
                            ShipperTrackingNumber = order.ShipperTrackingNumber
                        },
                        Item1 = fulfillmentItems.ToArray()
                    });
                });

                // iterate to the order fulfillment and add it into envelope message
                var envelopeMessages = new List <AmazonEnvelopeMessage>();
                for (var i = 0; i < orderFulfillmentList.Count; i++)
                {
                    var message = new AmazonEnvelopeMessage
                    {
                        MessageID = string.Format("{0}", i + 1),
                        Item      = orderFulfillmentList[i]
                    };
                    envelopeMessages.Add(message);
                }

                // create Amazon envelope object
                var amazonEnvelope = new AmazonEnvelope
                {
                    Header = new Header {
                        DocumentVersion = "1.01", MerchantIdentifier = _credential.MerchantId
                    },
                    MessageType = AmazonEnvelopeMessageType.OrderFulfillment,
                    Message     = envelopeMessages.ToArray()
                };

                // let's add these orders to the shipment history
                addOrderShipmentHistoryAsync(unshippedOrderFeeds);

                // parse the envelope into file
                var xmlFullName = XmlParser.WriteXmlToFile(amazonEnvelope, "AmazonOrderFulfillment");

                // create feed controller and send the confirmation shipment feed
                var submitController = new SubmitFeedController(serviceClient, _logger, _credential.MarketplaceId, _credential.MerchantId, _ApplicationName);
                var streamResponse   = submitController.SubmitFeedAndGetResponse(xmlFullName, AmazonFeedType._POST_ORDER_FULFILLMENT_DATA_);
                parsedResultStreamAndLogReport(streamResponse, AmazonEnvelopeMessageType.OrderFulfillment, _ApplicationName);

                _logger.LogInfo(LogEntryType.AmazonOrdersProvider,
                                string.Format("{1}:{2} - Successfully sent confirming order shipment for Order IDs: \"{0}\"", string.Join("\", \"", unshippedOrderFeeds.Select(x => x.OrderId)), ChannelName, _ApplicationName, Constants.APP_NAME));
                Console.WriteLine("Successfully sent confirming order shipment for Order IDs: \"{0}\"", string.Join("\", \"", unshippedOrderFeeds.Select(x => x.OrderId)));

                return(true);
            }
            catch (Exception ex)
            {
                _logger.LogError(LogEntryType.AmazonOrdersProvider,
                                 string.Format("{0}:{4} Error in confirming order shipment for for Order IDs: \"{3}\". <br/>Error Message: {1} <br/> Access Key: {2}", ChannelName,
                                               (ex.InnerException != null ? string.Format("{0} <br/>Inner Message: {1}",
                                                                                          ex.Message, ex.InnerException.Message) : ex.Message),
                                               _credential.AccessKeyId,
                                               string.Join("\", \"", unshippedOrderFeeds.Select(x => x.OrderId)),
                                               _ApplicationName),
                                 ex.StackTrace);
                Console.WriteLine("Error in sending shipment confirmation! Error Message: {0} \nStackTrace: {1} ", ex.Message, ex.StackTrace);

                // let's delete the order confirmation
                deleteOrderShipmentHistoryAsync(unshippedOrderFeeds);

                return(false);
            }
        }
Пример #11
0
        private void DownloadSalesData()
        {
            this.StatusDescription = string.Format("Creating MWS client");
            // Set up MWS client
            string accessKey     = System.Configuration.ConfigurationManager.AppSettings["MwsAccK"];
            string secretKey     = System.Configuration.ConfigurationManager.AppSettings["MwsSecK"];
            string sellerId      = System.Configuration.ConfigurationManager.AppSettings["MwsSeller"];
            string marketplaceId = System.Configuration.ConfigurationManager.AppSettings["MwsMktpl"];
            MarketplaceWebServiceConfig config = new MarketplaceWebServiceConfig();

            config.ServiceURL = "https://mws.amazonservices.com ";
            config.SetUserAgentHeader("CMA", "1.0", "C#", new string[] { });
            MarketplaceWebServiceClient client = new MarketplaceWebServiceClient(accessKey, secretKey, config);


            // Submit the report request
            MarketplaceWebService.Model.RequestReportRequest request = new MarketplaceWebService.Model.RequestReportRequest();
            request.ReportType = "_GET_FLAT_FILE_ALL_ORDERS_DATA_BY_LAST_UPDATE_";
            request.Merchant   = sellerId;
            request.StartDate  = DateTime.Now.AddDays(-30).AddHours(-6);
            request.EndDate    = DateTime.Now.AddHours(-6);

            this.StatusDescription = string.Format("Requesting Report Type {0} for {1} through {2}", request.ReportType, request.StartDate.ToShortDateString(), request.EndDate.ToShortDateString());
            var responseToRequestReport = client.RequestReport(request);

            Thread.Sleep(1000);

            string reportRequestId = "";

            if (responseToRequestReport.IsSetRequestReportResult())
            {
                if (responseToRequestReport.RequestReportResult.IsSetReportRequestInfo())
                {
                    if (responseToRequestReport.RequestReportResult.ReportRequestInfo.IsSetReportRequestId())
                    {
                        reportRequestId = responseToRequestReport.RequestReportResult.ReportRequestInfo.ReportRequestId;
                    }
                    else
                    {
                        // Would be good to implement wait-and-retry here
                        throw new Exception("ReportRequestId was not returned from RequestReport()");
                    }
                }
            }

            this.StatusDescription = string.Format("Report Request ID: {0}", reportRequestId);
            Thread.Sleep(1000);

            // Check for the report to have a _DONE_ status
            string reportId = "";

            bool reportDone = false;

            do
            {
                this.StatusDescription = string.Format("Checking report status");
                MarketplaceWebService.Model.GetReportRequestListRequest requestGetReportRequestList = new MarketplaceWebService.Model.GetReportRequestListRequest();
                requestGetReportRequestList.ReportRequestIdList    = new MarketplaceWebService.Model.IdList();
                requestGetReportRequestList.ReportRequestIdList.Id = new List <string>();
                requestGetReportRequestList.ReportRequestIdList.Id.Add(reportRequestId);
                requestGetReportRequestList.Merchant = sellerId;

                var responseToGetReportRequestList = client.GetReportRequestList(requestGetReportRequestList);

                if (responseToGetReportRequestList.IsSetGetReportRequestListResult() && responseToGetReportRequestList.GetReportRequestListResult.IsSetReportRequestInfo() && responseToGetReportRequestList.GetReportRequestListResult.ReportRequestInfo.Count != 0)
                {
                    this.StatusDescription = string.Format("Report status: {0}", responseToGetReportRequestList.GetReportRequestListResult.ReportRequestInfo[0].ReportProcessingStatus);
                    Thread.Sleep(500);
                    if (responseToGetReportRequestList.GetReportRequestListResult.ReportRequestInfo[0].ReportProcessingStatus.Equals("_DONE_"))
                    {
                        reportDone = true;
                        if (responseToGetReportRequestList.GetReportRequestListResult.ReportRequestInfo[0].IsSetGeneratedReportId())
                        {
                            reportId = responseToGetReportRequestList.GetReportRequestListResult.ReportRequestInfo[0].GeneratedReportId;
                            this.StatusDescription = string.Format("Report ID: {0}", reportId);
                        }
                        else
                        {
                            // ReportId was not returned, call GetReportList()
                            this.StatusDescription = string.Format("Report ID was not returned. Trying GetReportList()");
                            var requestGetReportList = new MarketplaceWebService.Model.GetReportListRequest();
                            requestGetReportList.ReportRequestIdList    = new MarketplaceWebService.Model.IdList();
                            requestGetReportList.ReportRequestIdList.Id = new List <string>();
                            requestGetReportList.ReportRequestIdList.Id.Add(reportRequestId);
                            requestGetReportList.Merchant = sellerId;

                            var responseToGetReportList = client.GetReportList(requestGetReportList);

                            if (responseToGetReportList.IsSetGetReportListResult() && responseToGetReportList.GetReportListResult.IsSetReportInfo() && responseToGetReportList.GetReportListResult.ReportInfo.Count != 0)
                            {
                                reportId = responseToGetReportList.GetReportListResult.ReportInfo[0].ReportId;
                                this.StatusDescription = string.Format("Report ID: {0}", reportId);
                            }
                            else
                            {
                                throw new Exception("ReportId could not be retrieved.");
                            }
                        }
                    }
                    else if (responseToGetReportRequestList.GetReportRequestListResult.ReportRequestInfo[0].ReportProcessingStatus.Equals("_DONE_NO_DATA_"))
                    {
                        throw new Exception("Report returned with status _DONE_NO_DATA_");
                    }
                    else
                    {
                        for (int secondsTilRetry = 60; secondsTilRetry > 0; secondsTilRetry--)
                        {
                            this.StatusDescription = string.Format("Report status: {0} (Will check again in {1}s)", responseToGetReportRequestList.GetReportRequestListResult.ReportRequestInfo[0].ReportProcessingStatus, secondsTilRetry);
                            Thread.Sleep(1000);
                        }
                    }
                }
            } while (!reportDone);

            Thread.Sleep(1000);

            // Retrieve the report
            string saveFileName = reportId + ".txt";

            this.StatusDescription = string.Format("Downloading report to {0}", saveFileName);
            MarketplaceWebService.Model.GetReportRequest requestGetReport = new MarketplaceWebService.Model.GetReportRequest();
            requestGetReport.ReportId = reportId;
            requestGetReport.Merchant = sellerId;

            using (Stream file = File.Open(saveFileName, FileMode.OpenOrCreate, FileAccess.ReadWrite)) {
                requestGetReport.Report = file;
                var responseToGetReport = client.GetReport(requestGetReport);
            }
        }
        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);
        }
Пример #13
0
        public static string RequestAmazonInventoryReport(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"]);

            string ReportRequestId       = "";
            RequestReportRequest request = new RequestReportRequest();

            request.Merchant             = merchantId;
            request.MarketplaceIdList    = new IdList();
            request.MarketplaceIdList.Id = new List <string>(new string[] { marketplaceId });

            request.ReportType = "_GET_FLAT_FILE_OPEN_LISTINGS_DATA_";
            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>");
            MarketplaceWebService.MarketplaceWebService service = new MarketplaceWebServiceClient(accessKeyId, secretAccessKey, config);

            try
            {
                RequestReportResponse response = service.RequestReport(request);


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

                Console.WriteLine("        RequestReportResponse");

                if (response.IsSetRequestReportResult())
                {
                    Console.WriteLine("            RequestReportResult");
                    RequestReportResult requestReportResult = response.RequestReportResult;
                    ReportRequestInfo   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);
                        ReportRequestId = 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");
                    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, "RequestAmazonInventoryReport ", accountName + " " + ex.Message.ToString(), senderEmail, messageFromPassword, messageToEmail, smtpClient, smtpPortNum);
            }

            return(ReportRequestId);
        }
Пример #14
0
        public static void GetAmazonReport(string accountName, string merchantId, string marketplaceId, string accessKeyId, string secretAccessKey, string reportGenerateId)
        {
            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"]);

            GetReportRequest request = new GetReportRequest();

            request.Merchant = merchantId;
            request.ReportId = reportGenerateId;
            //request.Report = File.Open(ConfigurationManager.AppSettings["filePath"], FileMode.OpenOrCreate, FileAccess.ReadWrite);
            request.Report = new FileStream(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\" + accountName + "_AmazonInventoryReport.xml", FileMode.Truncate, FileAccess.ReadWrite);

            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>");
            MarketplaceWebService.MarketplaceWebService service = new MarketplaceWebServiceClient(accessKeyId, secretAccessKey, config);
            try
            {
                GetReportResponse response = service.GetReport(request);


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

                Console.WriteLine("        GetReportResponse");
                if (response.IsSetGetReportResult())
                {
                    Console.WriteLine("            GetReportResult");
                    GetReportResult getReportResult = response.GetReportResult;
                    if (getReportResult.IsSetContentMD5())
                    {
                        Console.WriteLine("                ContentMD5");
                        Console.WriteLine("                    {0}", getReportResult.ContentMD5);
                    }
                }
                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, "GetAmazonReport ", accountName + " " + ex.Message.ToString(), senderEmail, messageFromPassword, messageToEmail, smtpClient, smtpPortNum);
            }
            request.Report.Close();
            request.Report.Dispose();
        }
Пример #15
0
        public bool ConfirmOrderShimpmentDetails(MarketplaceOrderFulfillment marketplaceOrder, string submittedBy)
        {
            if (!marketplaceOrder.OrderItems.Any())
            {
                return(false);
            }

            // create configuratin to use US marketplace
            var config = new MarketplaceWebServiceConfig {
                ServiceURL = RequestHelper.ServiceUrl
            };

            config.SetUserAgentHeader(_ApplicationName, _Version, "C#");
            _amazonClient = new MarketplaceWebServiceClient(_credential.AccessKeyId, _credential.SecretKey, config);

            try
            {
                // create fulfillment item list from the order items
                var fulfillmentItems = new List <OrderFulfillmentItem>();
                foreach (var item in marketplaceOrder.OrderItems)
                {
                    fulfillmentItems.Add(new OrderFulfillmentItem
                    {
                        Item     = item.OrderItemId,
                        Quantity = item.Quantity.ToString()
                    });
                }

                // create the order fulfillment information
                var fulfillment = new OrderFulfillment
                {
                    Item            = marketplaceOrder.OrderId,
                    FulfillmentDate = marketplaceOrder.FulfillmentDate,
                    FulfillmentData = new OrderFulfillmentFulfillmentData
                    {
                        Item                  = marketplaceOrder.Carrier.Code,
                        ShippingMethod        = marketplaceOrder.ShippingMethod,
                        ShipperTrackingNumber = marketplaceOrder.ShipperTrackingNumber
                    },
                    Item1 = fulfillmentItems.ToArray()
                };

                // create Amazon envelope object
                var amazonEnvelope = new AmazonEnvelope
                {
                    Header = new Header {
                        DocumentVersion = "1.01", MerchantIdentifier = _credential.MerchantId
                    },
                    MessageType = AmazonEnvelopeMessageType.OrderFulfillment,
                    Message     = new AmazonEnvelopeMessage[] {
                        new AmazonEnvelopeMessage {
                            MessageID = "1", Item = fulfillment
                        }
                    }
                };

                // parse the envelope into file
                var xmlFullName = XmlParser.WriteXmlToFile(amazonEnvelope, "OrderFulfillment");

                var submitController = new SubmitFeedController(_amazonClient, _logger, _credential.MarketplaceId, _credential.MerchantId, submittedBy);
                var streamResponse   = submitController.SubmitFeedAndGetResponse(xmlFullName, AmazonFeedType._POST_ORDER_FULFILLMENT_DATA_);
                parsedResultStreamAndLogReport(streamResponse, AmazonEnvelopeMessageType.OrderFulfillment, submittedBy);

                _logger.Add(LogEntrySeverity.Information, LogEntryType.AmazonOrdersProvider, string.Format("{0} - Successfully sent confirming order shipment for Order ID \'{1}\'", ChannelName, marketplaceOrder.OrderId));
                return(true);
            }
            catch (Exception ex)
            {
                _logger.Add(LogEntrySeverity.Error, LogEntryType.AmazonOrdersProvider,
                            string.Format("{0} - Error in confirming order shipment for OrderId: {3}. <br/>Error Message: {1} <br/> Access Key: {2}", ChannelName,
                                          EisHelper.GetExceptionMessage(ex),
                                          _credential.AccessKeyId,
                                          marketplaceOrder.OrderId),
                            ex.StackTrace);

                return(false);
            }
        }
Пример #16
0
        public static string SubmitAmazonTrackingFeed(string filepath, string merchantId, string marketplaceId, string accessKeyId, string secretAccessKey)
        {
            string            feedSubmissionId = "";
            SubmitFeedRequest request          = new SubmitFeedRequest();

            request.Merchant             = merchantId;
            request.MarketplaceIdList    = new IdList();
            request.MarketplaceIdList.Id = new List <string>(new string[] { marketplaceId });
            request.FeedContent          = File.Open(filepath, FileMode.Open, FileAccess.Read);
            request.ContentMD5           = MarketplaceWebServiceClient.CalculateContentMD5(request.FeedContent);
            request.FeedContent.Position = 0;
            request.FeedType             = "_POST_ORDER_FULFILLMENT_DATA_";

            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>");
            MarketplaceWebService.MarketplaceWebService service = new MarketplaceWebServiceClient(accessKeyId, secretAccessKey, config);

            try
            {
                SubmitFeedResponse response = service.SubmitFeed(request);


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

                Console.WriteLine("        SubmitFeedResponse");
                if (response.IsSetSubmitFeedResult())
                {
                    Console.WriteLine("            SubmitFeedResult");
                    SubmitFeedResult submitFeedResult = response.SubmitFeedResult;
                    if (submitFeedResult.IsSetFeedSubmissionInfo())
                    {
                        Console.WriteLine("                FeedSubmissionInfo");
                        FeedSubmissionInfo feedSubmissionInfo = submitFeedResult.FeedSubmissionInfo;
                        if (feedSubmissionInfo.IsSetFeedSubmissionId())
                        {
                            Console.WriteLine("                    FeedSubmissionId");
                            Console.WriteLine("                        {0}", feedSubmissionInfo.FeedSubmissionId);
                            feedSubmissionId = feedSubmissionInfo.FeedSubmissionId;
                        }
                        if (feedSubmissionInfo.IsSetFeedType())
                        {
                            Console.WriteLine("                    FeedType");
                            Console.WriteLine("                        {0}", feedSubmissionInfo.FeedType);
                        }
                        if (feedSubmissionInfo.IsSetSubmittedDate())
                        {
                            Console.WriteLine("                    SubmittedDate");
                            Console.WriteLine("                        {0}", feedSubmissionInfo.SubmittedDate);
                        }
                        if (feedSubmissionInfo.IsSetFeedProcessingStatus())
                        {
                            Console.WriteLine("                    FeedProcessingStatus");
                            Console.WriteLine("                        {0}", feedSubmissionInfo.FeedProcessingStatus);
                        }
                        if (feedSubmissionInfo.IsSetStartedProcessingDate())
                        {
                            Console.WriteLine("                    StartedProcessingDate");
                            Console.WriteLine("                        {0}", feedSubmissionInfo.StartedProcessingDate);
                        }
                        if (feedSubmissionInfo.IsSetCompletedProcessingDate())
                        {
                            Console.WriteLine("                    CompletedProcessingDate");
                            Console.WriteLine("                        {0}", feedSubmissionInfo.CompletedProcessingDate);
                        }
                    }
                }
                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, "SubmitAmazonTrackingFeed Error:", ex.Message.ToString(), senderEmail, messageFromPassword, messageToEmail, smtpClient, smtpPortNum);

                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);
            }

            return(feedSubmissionId);
        }
        /**
         * Samples for Marketplace Web Service functionality
         */
        public static void Main(string[] args)
        {
            Console.WriteLine("===========================================");
            Console.WriteLine("Welcome to Marketplace Web Service Samples!");
            Console.WriteLine("===========================================");

            Console.WriteLine("To get started:");
            Console.WriteLine("===========================================");
            Console.WriteLine("  - Fill in your AWS credentials");
            Console.WriteLine("  - Uncomment sample you're interested in trying");
            Console.WriteLine("  - Set request with desired parameters");
            Console.WriteLine("  - Hit F5 to run!");
            Console.WriteLine();

            Console.WriteLine("===========================================");
            Console.WriteLine("Samples Output");
            Console.WriteLine("===========================================");
            Console.WriteLine();

            /************************************************************************
             * Access Key ID and Secret Acess Key ID, obtained from:
             * http://aws.amazon.com
             *
             * IMPORTANT: Your Secret Access Key is a secret, and should be known
             * only by you and AWS. You should never include your Secret Access Key
             * in your requests to AWS. You should never e-mail your Secret Access Key
             * to anyone. It is important to keep your Secret Access Key confidential
             * to protect your account.
             ***********************************************************************/
            String accessKeyId     = "AKIAIKYYTE7TYRWSAIEA";
            String secretAccessKey = "jFA0WUoRP1yJty5pp8BXWfHN/UwMOecXQ6grn2D9";

            /************************************************************************
             * Instantiate  Implementation of Marketplace Web Service
             ***********************************************************************/

            //MarketplaceWebServiceConfig config = new MarketplaceWebServiceConfig();

            /************************************************************************
             * The application name and version are included in each MWS call's
             * HTTP User-Agent field. These are required fields.
             ***********************************************************************/

            const string applicationName    = "T-Tek Seller Tool";
            const string applicationVersion = "0.1";

            /*MarketplaceWebService service =
             *  new MarketplaceWebServiceClient(
             *      accessKeyId,
             *      secretAccessKey,
             *      applicationName,
             *      applicationVersion,
             *      config);*/


            /************************************************************************
             * All MWS requests must contain the seller's merchant ID and
             * marketplace ID.
             ***********************************************************************/
            const string merchantId    = "A380610PV1XE6A";
            const string marketplaceId = "ATVPDKIKX0DER";

            /************************************************************************
             * Uncomment to configure the client instance. Configuration settings
             * include:
             *
             *  - MWS Service endpoint URL
             *  - Proxy Host and Proxy Port
             *  - User Agent String to be sent to Marketplace Web Service  service
             *
             ***********************************************************************/
            MarketplaceWebServiceConfig config = new MarketplaceWebServiceConfig();

            config.ProxyHost = "https://PROXY_URL";
            config.ProxyPort = 9090;
            //
            // IMPORTANT: Uncomment out the appropiate line for the country you wish
            // to sell in:
            //
            // United States:
            config.ServiceURL = "https://mws.amazonservices.com";
            //
            // United Kingdom:
            // config.ServiceURL = "https://mws.amazonservices.co.uk";
            //
            // Germany:
            // config.ServiceURL = "https://mws.amazonservices.de";
            //
            // France:
            // config.ServiceURL = "https://mws.amazonservices.fr";
            //
            // Japan:
            // config.ServiceURL = "https://mws.amazonservices.jp";
            //
            // China:
            // config.ServiceURL = "https://mws.amazonservices.com.cn";
            //
            // Canada:
            // config.ServiceURL = "https://mws.amazonservices.ca";
            //
            // Italy:
            // config.ServiceURL = "https://mws.amazonservices.it";
            //
            config.SetUserAgentHeader(
                applicationName,
                applicationVersion,
                "C#",
                "<Parameter 1>", "<Parameter 2>");
            MarketplaceWebService service = new MarketplaceWebServiceClient(accessKeyId, secretAccessKey, config);


            /************************************************************************
             * Uncomment to try out Mock Service that simulates Marketplace Web Service
             * responses without calling Marketplace Web Service  service.
             *
             * Responses are loaded from local XML files. You can tweak XML files to
             * experiment with various outputs during development
             *
             * XML files available under MarketplaceWebService\Mock tree
             *
             ***********************************************************************/
            //MarketplaceWebService service = new MarketplaceWebServiceMock();


            /************************************************************************
             * Uncomment to invoke Get Report Action
             ***********************************************************************/
            {
                GetReportRequest request = new GetReportRequest();
                request.Merchant = merchantId;
                //request.MWSAuthToken = "<Your MWS Auth Token>"; // Optional

                // Note that depending on the type of report being downloaded, a report can reach
                // sizes greater than 1GB. For this reason we recommend that you _always_ program to
                // MWS in a streaming fashion. Otherwise, as your business grows you may silently reach
                // the in-memory size limit and have to re-work your solution.
                // NOTE: Due to Content-MD5 validation, the stream must be read/write.
                request.ReportId = "REPORT_ID";
                request.Report   = File.Open("report.xml", FileMode.OpenOrCreate, FileAccess.ReadWrite);
                GetReportSample.InvokeGetReport(service, request);
            }

            /************************************************************************
             * Uncomment to invoke Get Report Schedule Count Action
             ***********************************************************************/
            {
                GetReportScheduleCountRequest request = new GetReportScheduleCountRequest();
                request.Merchant = merchantId;
                //request.MWSAuthToken = "<Your MWS Auth Token>"; // Optional
                // @TODO: set additional request parameters here
                GetReportScheduleCountSample.InvokeGetReportScheduleCount(service, request);
            }


            /************************************************************************
             * Uncomment to invoke Get Report Request List By Next Token Action
             ***********************************************************************/
            {
                //GetReportRequestListByNextTokenRequest request = new GetReportRequestListByNextTokenRequest();
                //request.Merchant = merchantId;
                //request.MWSAuthToken = "<Your MWS Auth Token>"; // Optional
                //request.NextToken = "NextToken from GetReportRequestList";
                // @TODO: set additional request parameters here
                //GetReportRequestListByNextTokenSample.InvokeGetReportRequestListByNextToken(service, request);
            }

            /************************************************************************
             * Uncomment to invoke Update Report Acknowledgements Action
             ***********************************************************************/
            {
                //UpdateReportAcknowledgementsRequest request = new UpdateReportAcknowledgementsRequest();
                //request.Merchant = merchantId;
                //request.MWSAuthToken = "<Your MWS Auth Token>"; // Optional
                //request.WithReportIdList(new IdList().WithId("REPORT_ID"));
                // @TODO: set additional request parameters here
                //UpdateReportAcknowledgementsSample.InvokeUpdateReportAcknowledgements(service, request);
            }


            /************************************************************************
             * Uncomment to invoke Submit Feed Action
             ***********************************************************************/
            {
                // SubmitFeedRequest request = new SubmitFeedRequest();
                // request.Merchant = merchantId;
                // request.MWSAuthToken = "<Your MWS Auth Token>"; // Optional
                // request.MarketplaceIdList = new IdList();
                // request.MarketplaceIdList.Id = new List<string>( new string [] { marketplaceId } );

                // MWS exclusively offers a streaming interface for uploading your feeds. This is because
                // feed sizes can grow to the 1GB+ range - and as your business grows you could otherwise
                // silently reach the feed size where your in-memory solution will no longer work, leaving you
                // puzzled as to why a solution that worked for a long time suddenly stopped working though
                // you made no changes. For the same reason, we strongly encourage you to generate your feeds to
                // local disk then upload them directly from disk to MWS.

                //request.FeedContent = File.Open("feed.xml", FileMode.Open, FileAccess.Read);

                // Calculating the MD5 hash value exhausts the stream, and therefore we must either reset the
                // position, or create another stream for the calculation.
                //request.ContentMD5 = MarketplaceWebServiceClient.CalculateContentMD5(request.FeedContent);
                //request.FeedContent.Position = 0;

                //request.FeedType = "FEED_TYPE";

                //SubmitFeedSample.InvokeSubmitFeed(service, request);
            }


            /************************************************************************
             * Uncomment to invoke Get Report Count Action
             ***********************************************************************/
            {
                // GetReportCountRequest request = new GetReportCountRequest();
                // request.Merchant = merchantId;
                // request.MWSAuthToken = "<Your MWS Auth Token>"; // Optional
                // @TODO: set additional request parameters here
                // GetReportCountSample.InvokeGetReportCount(service, request);
            }

            /************************************************************************
             * Uncomment to invoke Get Feed Submission List By Next Token Action
             ***********************************************************************/
            {
                //GetFeedSubmissionListByNextTokenRequest request = new GetFeedSubmissionListByNextTokenRequest();
                //request.Merchant = merchantId;
                //request.MWSAuthToken = "<Your MWS Auth Token>"; // Optional
                //request.NextToken = "NextToken from GetFeedSubmissionList";
                // @TODO: set additional request parameters here
                //GetFeedSubmissionListByNextTokenSample.InvokeGetFeedSubmissionListByNextToken(service, request);
            }

            /************************************************************************
             * Uncomment to invoke Cancel Feed Submissions Action
             ***********************************************************************/
            {
                //CancelFeedSubmissionsRequest request = new CancelFeedSubmissionsRequest();
                //request.Merchant = merchantId;
                //request.MWSAuthToken = "<Your MWS Auth Token>"; // Optional
                // @TODO: set additional request parameters here
                //CancelFeedSubmissionsSample.InvokeCancelFeedSubmissions(service, request);
            }

            /************************************************************************
             * Uncomment to invoke Request Report Action
             ***********************************************************************/
            {
                //RequestReportRequest request = new RequestReportRequest();
                //request.Merchant = merchantId;
                //request.MWSAuthToken = "<Your MWS Auth Token>"; // Optional
                //request.MarketplaceIdList = new IdList();
                //request.MarketplaceIdList.Id = new List<string>( new string [] { marketplaceId } );

                //request.ReportType = "Desired Report Type";
                // @TODO: set additional request parameters here
                //request.ReportOptions = "ShowSalesChannel=true";
                //RequestReportSample.InvokeRequestReport(service, request);
            }

            /************************************************************************
             * Uncomment to invoke Get Feed Submission Count Action
             ***********************************************************************/
            {
                //GetFeedSubmissionCountRequest request = new GetFeedSubmissionCountRequest();
                //request.Merchant = merchantId;
                //request.MWSAuthToken = "<Your MWS Auth Token>"; // Optional
                // @TODO: set additional request parameters here
                //GetFeedSubmissionCountSample.InvokeGetFeedSubmissionCount(service, request);
            }

            /************************************************************************
             * Uncomment to invoke Cancel Report Requests Action
             ***********************************************************************/
            {
                //CancelReportRequestsRequest request = new CancelReportRequestsRequest();
                //request.Merchant = merchantId;
                //request.MWSAuthToken = "<Your MWS Auth Token>"; // Optional
                // @TODO: set additional request parameters here
                //CancelReportRequestsSample.InvokeCancelReportRequests(service, request);
            }

            /************************************************************************
             * Uncomment to invoke Get Report List Action
             ***********************************************************************/
            {
                //GetReportListRequest request = new GetReportListRequest();
                //request.Merchant = merchantId;
                //request.MWSAuthToken = "<Your MWS Auth Token>"; // Optional
                // @TODO: set additional request parameters here
                //GetReportListSample.InvokeGetReportList(service, request);
            }

            /************************************************************************
             * Uncomment to invoke Get Feed Submission Result Action
             ***********************************************************************/
            {
                //GetFeedSubmissionResultRequest request = new GetFeedSubmissionResultRequest();
                //request.Merchant = merchantId;
                //request.MWSAuthToken = "<Your MWS Auth Token>"; // Optional

                // Note that depending on the size of the feed sent in, and the number of errors and warnings,
                // the result can reach sizes greater than 1GB. For this reason we recommend that you _always_
                // program to MWS in a streaming fashion. Otherwise, as your business grows you may silently reach
                // the in-memory size limit and have to re-work your solution.
                // NOTE: Due to Content-MD5 validation, the stream must be read/write.
                //request.FeedSubmissionId = "FEED_SUBMISSION_ID";
                //request.FeedSubmissionResult = File.Open("feedSubmissionResult.xml", FileMode.OpenOrCreate, FileAccess.ReadWrite);

                //GetFeedSubmissionResultSample.InvokeGetFeedSubmissionResult(service, request);
            }

            /************************************************************************
             * Uncomment to invoke Get Feed Submission List Action
             ***********************************************************************/
            {
                //GetFeedSubmissionListRequest request = new GetFeedSubmissionListRequest();
                //request.Merchant = merchantId;
                //request.MWSAuthToken = "<Your MWS Auth Token>"; // Optional
                // @TODO: set additional request parameters here
                //GetFeedSubmissionListSample.InvokeGetFeedSubmissionList(service, request);
            }

            /************************************************************************
             * Uncomment to invoke Get Report Request List Action
             ***********************************************************************/
            {
                //GetReportRequestListRequest request = new GetReportRequestListRequest();
                //request.Merchant = merchantId;
                //request.MWSAuthToken = "<Your MWS Auth Token>"; // Optional
                // @TODO: set additional request parameters here
                //GetReportRequestListSample.InvokeGetReportRequestList(service, request);
            }

            /************************************************************************
             * Uncomment to invoke Get Report Schedule List By Next Token Action
             ***********************************************************************/
            {
                //GetReportScheduleListByNextTokenRequest request = new GetReportScheduleListByNextTokenRequest();
                //request.Merchant = merchantId;
                //request.MWSAuthToken = "<Your MWS Auth Token>"; // Optional
                //request.NextToken = "NextToken from GetReportScheduleList";
                // @TODO: set additional request parameters here
                //GetReportScheduleListByNextTokenSample.InvokeGetReportScheduleListByNextToken(service, request);
            }

            /************************************************************************
             * Uncomment to invoke Get Report List By Next Token Action
             ***********************************************************************/
            {
                // GetReportListByNextTokenRequest request = new GetReportListByNextTokenRequest();
                // request.Merchant = merchantId;
                // request.MWSAuthToken = "<Your MWS Auth Token>"; // Optional
                //request.NextToken = "NextToken from GetReportList";
                // @TODO: set additional request parameters here
                // GetReportListByNextTokenSample.InvokeGetReportListByNextToken(service, request);
            }

            /************************************************************************
             * Uncomment to invoke Manage Report Schedule Action
             ***********************************************************************/
            {
                //ManageReportScheduleRequest request = new ManageReportScheduleRequest();
                //request.Merchant = merchantId;
                //request.MWSAuthToken = "<Your MWS Auth Token>"; // Optional
                //request.ReportType = "Report Type";
                //request.Schedule = "Schedule";
                // @TODO: set additional request parameters here
                //ManageReportScheduleSample.InvokeManageReportSchedule(service, request);
            }

            /************************************************************************
             * Uncomment to invoke Get Report Request Count Action
             ***********************************************************************/
            {
                //GetReportRequestCountRequest request = new GetReportRequestCountRequest();
                //request.Merchant = merchantId;
                //request.MWSAuthToken = "<Your MWS Auth Token>"; // Optional
                // @TODO: set additional request parameters here
                //GetReportRequestCountSample.InvokeGetReportRequestCount(service, request);
            }

            /************************************************************************
             * Uncomment to invoke Get Report Schedule List Action
             ***********************************************************************/
            {
                //GetReportScheduleListRequest request = new GetReportScheduleListRequest();
                //request.Merchant = merchantId;
                //request.MWSAuthToken = "<Your MWS Auth Token>"; // Optional
                // @TODO: set additional request parameters here
                //GetReportScheduleListSample.InvokeGetReportScheduleList(service, request);
            }


            Console.WriteLine();
            Console.WriteLine("===========================================");
            Console.WriteLine("End of output. You can close this window");
            Console.WriteLine("===========================================");

            System.Threading.Thread.Sleep(50000);
        }
Пример #18
0
        public static void GetAmazonTrackingFeedSubmissionResult(string feedSubmissionId, string merchantId, string marketplaceId, string accessKeyId, string secretAccessKey)
        {
            GetFeedSubmissionResultRequest request = new GetFeedSubmissionResultRequest();

            request.Merchant         = merchantId;
            request.FeedSubmissionId = feedSubmissionId;
            //request.FeedSubmissionResult = File.Open("feedSubmissionResult.xml", FileMode.OpenOrCreate, FileAccess.ReadWrite);
            request.FeedSubmissionResult = new FileStream(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\AmazonTrackingResult.xml", FileMode.Truncate, FileAccess.ReadWrite);

            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>");
            MarketplaceWebService.MarketplaceWebService service = new MarketplaceWebServiceClient(accessKeyId, secretAccessKey, config);
            string requestId = "";

            try
            {
                GetFeedSubmissionResultResponse response = service.GetFeedSubmissionResult(request);


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

                Console.WriteLine("        GetFeedSubmissionResultResponse");
                if (response.IsSetGetFeedSubmissionResultResult())
                {
                    Console.WriteLine("            GetFeedSubmissionResult");
                    GetFeedSubmissionResultResult getFeedSubmissionResultResult = response.GetFeedSubmissionResultResult;
                    if (getFeedSubmissionResultResult.IsSetContentMD5())
                    {
                        Console.WriteLine("                ContentMD5");
                        Console.WriteLine("                    {0}", getFeedSubmissionResultResult.ContentMD5);
                    }
                }

                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, "AmazonTrackingResult->GetAmazonTrackingResult: ", feedSubmissionId + ": " + ex.Message.ToString(), senderEmail, messageFromPassword, messageToEmail, smtpClient, smtpPortNum);

                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);
            }

            request.FeedSubmissionResult.Close();
            request.FeedSubmissionResult.Dispose();
        }