示例#1
0
 private GlobalConfig()
 {
     IniReader iniReader = new IniReader(System.Environment.CurrentDirectory + "\\config.ini");
     string awsSection = "AWS_US";
     accessKey = iniReader.ReadValue(awsSection, "accessKey");
     secretKey = iniReader.ReadValue(awsSection, "secretKey");
     appName = iniReader.ReadValue(awsSection, "appName");
     appVersion = iniReader.ReadValue(awsSection, "appVersion");
     serviceURL = iniReader.ReadValue(awsSection, "serviceURL");
     sellerId = iniReader.ReadValue(awsSection, "sellerId");
     marketplaceId = iniReader.ReadValue(awsSection, "marketplaceId");
     skuPriceCount = int.Parse(iniReader.ReadValue(awsSection, "skuPriceCount"));
     skuPriceWaitTime = int.Parse(iniReader.ReadValue(awsSection, "skuPriceWaitTime"));
     adaptRange = float.Parse(iniReader.ReadValue(awsSection, "adaptRange"));
     saleStartDate = iniReader.ReadValue(awsSection, "saleStartDate");
     saleEndDate = iniReader.ReadValue(awsSection, "saleEndDate");
     timeFormat = iniReader.ReadValue(awsSection, "timeFormat");
     inventoryReportType = iniReader.ReadValue(awsSection, "inventoryReportType");
     unshippedOrderReportType = iniReader.ReadValue(awsSection, "unshippedOrderReportType");
     historyOrderReportType = iniReader.ReadValue(awsSection, "historyOrderReportType");
     eubBuzType = iniReader.ReadValue(awsSection, "eubBuzType");
     adaptPriceFeedType = iniReader.ReadValue(awsSection, "adaptPriceFeedType");
     confirmOrderFeedType = iniReader.ReadValue(awsSection, "confirmOrderFeedType");
     shipCarrierCode = iniReader.ReadValue(awsSection, "shipCarrierCode");
     shipCarrierName = iniReader.ReadValue(awsSection, "shipCarrierName");
     shipDateFormat = iniReader.ReadValue(awsSection, "shipDateFormat");
 }
        public static void RunSample()
        {
            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.
             ***********************************************************************/

            IniReader iniReader = new IniReader(System.Environment.CurrentDirectory + "\\config.ini");
            string awsSection = "AWS_US";

            String accessKeyId = iniReader.ReadValue(awsSection, "accessKey");
            String secretAccessKey = iniReader.ReadValue(awsSection, "secretKey");

            /************************************************************************
            * 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.
             ***********************************************************************/

            string applicationName = iniReader.ReadValue(awsSection, "appName"); ;
            string applicationVersion = iniReader.ReadValue(awsSection, "appVersion"); ;

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

            /************************************************************************
             * All MWS requests must contain the seller's merchant ID and
             * marketplace ID.
             ***********************************************************************/
            string merchantId = iniReader.ReadValue(awsSection, "sellerId");
            string marketplaceId = iniReader.ReadValue(awsSection, "marketplaceId");

            /************************************************************************
             * 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#"
                );
            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 = iniReader.ReadValue(awsSection, "MWSAuthToken"); // 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 = "_POST_PRODUCT_PRICING_DATA_";

                //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 = "51635016699";
                request.FeedSubmissionResult = File.Open("feedSubmissionResult1.xml", FileMode.OpenOrCreate, FileAccess.ReadWrite);

                GetFeedSubmissionResultSample.InvokeGetFeedSubmissionResult(service, request);
                request.FeedSubmissionResult.Close();
            }

            /************************************************************************
             * 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);
        }
        public static void RunSample()
        {
            DataSet ds = MySqlHelper.GetDataSet(MySqlHelper.Conn, System.Data.CommandType.Text, "select * from t_product", null);
            // TODO: Set the below configuration variables before attempting to run
            IniReader iniReader = new IniReader(System.Environment.CurrentDirectory + "\\config.ini");

            string awsSection = "AWS_US";

            // Developer AWS access key
            string accessKey = iniReader.ReadValue(awsSection, "accessKey");

            // Developer AWS secret key
            string secretKey = "DbRpGI97sF0lot67Wm5Dkgc9chXd7GkmzMxu/JrV";

            // The client application name
            string appName = "UprightBuzSample";

            // The client application version
            string appVersion = "1.0";

            // The endpoint for region service and version (see developer guide)
            // ex: https://mws.amazonservices.com
            string serviceURL = "https://mws.amazonservices.com";

            // Create a configuration object
            MarketplaceWebServiceOrdersConfig config = new MarketplaceWebServiceOrdersConfig();
            config.ServiceURL = serviceURL;
            // Set other client connection configurations here if needed
            // Create the client itself
            MarketplaceWebServiceOrders client = new MarketplaceWebServiceOrdersClient(accessKey, secretKey, appName, appVersion, config);

            MarketplaceWebServiceOrdersSample sample = new MarketplaceWebServiceOrdersSample(client);

            // Uncomment the operation you'd like to test here
            // TODO: Modify the request created in the Invoke method to be valid

            try
            {
                IMWSResponse response = null;
                // response = sample.InvokeGetOrder();
                // response = sample.InvokeGetServiceStatus();
                // response = sample.InvokeListOrderItems();
                // response = sample.InvokeListOrderItemsByNextToken();
                response = sample.InvokeListOrders();
                // response = sample.InvokeListOrdersByNextToken();
                Console.WriteLine("Response:");
                ResponseHeaderMetadata rhmd = response.ResponseHeaderMetadata;
                // We recommend logging the request id and timestamp of every call.
                Console.WriteLine("RequestId: " + rhmd.RequestId);
                Console.WriteLine("Timestamp: " + rhmd.Timestamp);
                string responseXml = response.ToXML();
                Console.WriteLine(responseXml);
            }
            catch (MarketplaceWebServiceOrdersException ex)
            {
                // Exception properties are important for diagnostics.
                ResponseHeaderMetadata rhmd = ex.ResponseHeaderMetadata;
                Console.WriteLine("Service Exception:");
                if (rhmd != null)
                {
                    Console.WriteLine("RequestId: " + rhmd.RequestId);
                    Console.WriteLine("Timestamp: " + rhmd.Timestamp);
                }
                Console.WriteLine("Message: " + ex.Message);
                Console.WriteLine("StatusCode: " + ex.StatusCode);
                Console.WriteLine("ErrorCode: " + ex.ErrorCode);
                Console.WriteLine("ErrorType: " + ex.ErrorType);
                throw ex;
            }
        }