public ListOrdersResponse AmazonOrderResponse() { MarketplaceWebServiceOrdersConfig config = new MarketplaceWebServiceOrdersConfig(); config.ServiceURL = CommonValue.strServiceURL; MarketplaceWebServiceOrders.MarketplaceWebServiceOrders client = new MarketplaceWebServiceOrdersClient( AccessKeyId, SecretKeyId, ApplicationName, ApplicationVersion, config); ListOrdersRequest _req = new ListOrdersRequest(); List <string> _marketPlaceId = new List <string>(); _marketPlaceId.Add(MarketplaceId); _req.MarketplaceId = _marketPlaceId; _req.CreatedAfter = DateTime.Now.AddDays(-1); _req.SellerId = SellerId; _req.MWSAuthToken = MWSAuthToken; return(listorders = client.ListOrders(_req)); }
/// <summary> /// Implement the Process step for PowerShell Cmdlets /// </summary> protected override void ProcessRecord() { base.ProcessRecord(); /* * // If no dates are specificied, start a day ago ... * if (CreatedBefore == DateTime.MaxValue && CreatedAfter == DateTime.MinValue) * { * CreatedAfter = DateTime.UtcNow.AddDays(-1); * } */ // Amazon's policy doesn't allow calling with a CreatedBefore after two minutes before the request time if (CreatedBefore == DateTime.MaxValue) { CreatedBefore = DateTime.Now.AddMinutes(-2); } var orderRequest = new ListOrdersRequest { MarketplaceId = new MarketplaceIdList(), OrderStatus = new OrderStatusList(), BuyerEmail = this.BuyerEmail, SellerId = this.MerchantId, SellerOrderId = this.SellerOrderId, CreatedAfter = this.CreatedAfter, CreatedBefore = this.CreatedBefore }; orderRequest.OrderStatus.Status.AddRange(OrderStatus); orderRequest.MarketplaceId.Id.AddRange(Marketplace); var response = marketplaceWebServiceOrdersClient.ListOrders(orderRequest); foreach (var order in response.ListOrdersResult.Orders.Order) { var output = new PSObject(order); if (IncludeItems.ToBool()) { var itemRequest = new ListOrderItemsRequest { AmazonOrderId = order.AmazonOrderId, SellerId = this.MerchantId, }; var items = marketplaceWebServiceOrdersClient.ListOrderItems(itemRequest); output.Properties.Add(new PSNoteProperty("Items", items.ListOrderItemsResult.OrderItems.OrderItem)); } WriteObject(output); } }
private ListOrdersResponse GetOrders(string mpId, string sellerId) { var listOrdersRequest = new ListOrdersRequest(); var marketplaceIdList = new List <string>(); listOrdersRequest .WithSellerId(sellerId) .WithCreatedAfter(new DateTime(2012, 6, 4)) .WithMarketplaceId(marketplaceIdList.ToArray()) ; return(_client.ListOrders(listOrdersRequest)); }
/// <summary> /// Fetches the newly created orders from the marketplaces from a given date. /// </summary> /// <param name="lastUpdated">The starting created order date for when orders are supposed to be pulled.</param> /// <returns>A collection of marketplace orders.</returns> public IEnumerable <Contracts.MarketplaceOrder> GetMarketplaceOrders(DateTime createdAfter) { var marketplaceOrders = new List <Contracts.MarketplaceOrder>(); var listOrdersResponse = _AmazonOrdersClient.ListOrders(CreateListOrdersRequest(createdAfter)); if (!string.IsNullOrWhiteSpace(listOrdersResponse.ListOrdersResult.NextToken)) { throw new MarketplaceWebServiceException("ListOrders returned a next token. Please restructure the code to continue pulling orders with this token."); } // Convert the orders to the marketplace contracts and get the items. for (int i = 0; i < listOrdersResponse.ListOrdersResult.Orders.Order.Count; ++i) { // The maximum request quota for ListOrderItems is 30 after that it restores at 2 per second. // So if the order's that are being pulled exceed 30, then sleep for 2 seconds each one. if (i > 30) { System.Threading.Thread.Sleep(2000); } marketplaceOrders.Add(ConvertOrderResponseToMarketplaceOrder(listOrdersResponse.ListOrdersResult.Orders.Order[i])); } return(marketplaceOrders); }
public void LeerPedidos(DateTime FechInicial, string cuenta, string OrderStatus) { int pagina = 1; this.Cuenta = cuenta; ListOrdersRequest request = new ListOrdersRequest(); request.SellerId = MERCHANT_ID; string format = "MMM d, yyyy h:mm:ss tt PDT"; CultureInfo provider = CultureInfo.InvariantCulture; DateTime now = DateTime.Now.Add(new TimeSpan(0, -10, 0)); DateTime createdAfter = DateTime.ParseExact("Aug 10, 2017 2:42:18 PM PDT", format, provider); request.CreatedAfter = createdAfter; request.CreatedBefore = now; List <string> orderStatus = new List <string>(); orderStatus.Add(OrderStatus); request.OrderStatus = orderStatus; List <string> marketplaceId = new List <string>(); marketplaceId.Add(MARKETPLACE_ID); request.MarketplaceId = marketplaceId; //List<string> fulfillmentChannel = new List<string>(); //request.FulfillmentChannel = fulfillmentChannel; //List<string> paymentMethod = new List<string>(); //request.PaymentMethod = paymentMethod; //string buyerEmail = "example"; //request.BuyerEmail = buyerEmail; //string sellerOrderId = "example"; //request.SellerOrderId = sellerOrderId; //decimal maxResultsPerPage = 1; //request.MaxResultsPerPage = maxResultsPerPage; //List<string> tfmShipmentStatus = new List<string>(); //request.TFMShipmentStatus = tfmShipmentStatus; MarketplaceWebServiceOrdersConfig config = new MarketplaceWebServiceOrdersConfig { ServiceURL = "https://mws.amazonservices.es/Orders/2013-09-01" }; MarketplaceWebServiceOrdersClient client = new MarketplaceWebServiceOrdersClient(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, "AppName", "0.0", config); ListOrdersResponse a = new ListOrdersResponse(); bool retryRequest = true; while (retryRequest == true) { retryRequest = false; try { eventAntesPagina(new EventosAmazon { pagina = pagina, linea = 0, retardo = 0 }); a = client.ListOrders(request); eventDespuesPagina(new EventosAmazon { pagina = pagina, linea = 0, retardo = 0 }); } catch (MarketplaceWebServiceOrdersException ex) { if (ex.ErrorCode.Contains("RequestThrottled")) { int retardo = 60000; retryRequest = true; eventAntesRetardoTroleo(new EventosAmazon { pagina = pagina, linea = 0, retardo = retardo }); System.Threading.Thread.Sleep(retardo); eventDespuesRetardoTroleo?.Invoke(new EventosAmazon { pagina = pagina, linea = 0, retardo = retardo }); } else { eventError?.Invoke(new EventosAmazon { pagina = pagina, linea = 0, retardo = 0, error = ex.Detail }); } } } // foreach (Order order in a.ListOrdersResult.Orders) // GrabarOrder(order, cuenta); Task t = new Task( () => { Parallel.ForEach(a.ListOrdersResult.Orders, new ParallelOptions { MaxDegreeOfParallelism = 2 }, order => { int numero = a.ListOrdersResult.Orders.IndexOf(order); LeerLineasPedido(order, pagina, numero); GrabarOrder(order, cuenta); }); }); t.Start(); while (!t.IsCompleted) { Application.DoEvents(); } string NextToken = a.ListOrdersResult.NextToken; // return; while (!string.IsNullOrEmpty(NextToken)) { pagina++; ListOrdersByNextTokenRequest nextRequest = new ListOrdersByNextTokenRequest(); nextRequest.NextToken = NextToken; nextRequest.SellerId = request.SellerId; retryRequest = true; ListOrdersByNextTokenResponse b = new ListOrdersByNextTokenResponse(); while (retryRequest == true) { retryRequest = false; try { eventAntesPagina(new EventosAmazon { pagina = pagina, linea = 0, retardo = 0 }); b = client.ListOrdersByNextToken(nextRequest); eventDespuesPagina(new EventosAmazon { pagina = pagina, linea = 0, retardo = 0 }); Task tn = new Task( () => { Parallel.ForEach(b.ListOrdersByNextTokenResult.Orders, new ParallelOptions { MaxDegreeOfParallelism = 2 }, order => { int numero = b.ListOrdersByNextTokenResult.Orders.IndexOf(order); LeerLineasPedido(order, pagina, numero); GrabarOrder(order, cuenta); }); }); tn.Start(); while (!tn.IsCompleted) { Application.DoEvents(); } } catch (MarketplaceWebServiceOrdersException ex) { //The ListOrders and ListOrdersByNextToken operations together share a maximum request quota of six and a restore rate of one request every minute. // Request quota // The number of requests that you can submit at one time without throttling.The request quota decreases with every request you submit.The request quota increases at the restore rate. // Restore rate // The rate at which your request quota increases over time, up to the maximum request quota. // Maximum request quota // The maximum size that the request quota can reach. if (ex.ErrorCode.Contains("RequestThrottled")) { int retardo = 60000; retryRequest = true; eventAntesRetardoTroleo(new EventosAmazon { pagina = pagina, linea = 0, retardo = retardo }); System.Threading.Thread.Sleep(retardo); eventDespuesRetardoTroleo?.Invoke(new EventosAmazon { pagina = pagina, linea = 0, retardo = retardo }); } } if (b.IsSetListOrdersByNextTokenResult()) { NextToken = b.ListOrdersByNextTokenResult.NextToken; } else { break; } } } }
public IEnumerable <MarketplaceOrder> GetMarketplaceOrders(DateTime createdAfter) { var marketplaceOrders = new List <MarketplaceOrder>(); try { // init the Amazon web service var config = new MarketplaceWebServiceOrdersConfig { ServiceURL = "https://mws.amazonservices.com" }; config.SetUserAgent(_ApplicationName, _Version); _ordersClient = new MarketplaceWebServiceOrdersClient(_credential.AccessKeyId, _credential.SecretKey, config); Console.WriteLine("{0} fetching orders for {1}...", ChannelName, createdAfter); // create ListOrdersRequest object var listOrdersRequest = new ListOrdersRequest { SellerId = _credential.MerchantId, MarketplaceId = new List <string> { { _credential.MarketplaceId } }, LastUpdatedAfter = createdAfter.Date }; var listOrdersResponse = _ordersClient.ListOrders(listOrdersRequest); var ordersResult = listOrdersResponse.ListOrdersResult.Orders; var nextToken = listOrdersResponse.ListOrdersResult.NextToken; ListOrdersByNextTokenResponse nextOrderResponse = null; Console.WriteLine("{0} retrieved {1} orders and {2} next results page.", ChannelName, listOrdersResponse.ListOrdersResult.Orders.Count, !string.IsNullOrWhiteSpace(nextToken) ? "HAS" : "NO"); do { if (nextOrderResponse != null) { ordersResult = nextOrderResponse.ListOrdersByNextTokenResult.Orders; nextToken = nextOrderResponse.ListOrdersByNextTokenResult.NextToken; Console.WriteLine("{0} retrieved {1} next orders and {2} next results page.", ChannelName, ordersResult.Count, !string.IsNullOrWhiteSpace(nextToken) ? "HAS" : "NO"); } // Convert the orders to the marketplace contracts and get the items. for (int i = 0; i < ordersResult.Count; ++i) { // The maximum request quota for ListOrderItems is 30 after that it restores at 2 per second. // So if the order's that are being pulled exceed 30, then sleep for 2 seconds each one. if (i > 30) { Thread.Sleep(2000); } marketplaceOrders.Add(convertOrderResponseToMarketplaceOrder(ordersResult[i])); } // do a rquest for the next page result of orders if next token is not null if (!string.IsNullOrWhiteSpace(nextToken)) { // pause at least 1 minute, this is the restore rate for ListOrdersByNextToken for every 6 quota Thread.Sleep(61000); var nextTokenRequest = new ListOrdersByNextTokenRequest { SellerId = _credential.MerchantId, NextToken = nextToken }; nextOrderResponse = _ordersClient.ListOrdersByNextToken(nextTokenRequest); } } while (!string.IsNullOrWhiteSpace(nextToken)); Console.WriteLine("{0} done fetching orders: {1} items", ChannelName, marketplaceOrders.Count); } catch (Exception ex) { Console.WriteLine("Error in getting orders for {0}! Error message: {1}", ChannelName, ex.Message); _logger.LogError(LogEntryType.AmazonOrdersProvider, string.Format("Error in retrieving orders for Amazon. Error message: {0}", ex.Message), ex.StackTrace); _emailService.SendEmailAdminException(subject: "Amazon - Get Marketplace Orders Error", exParam: ex, useDefaultTemplate: true, url: "GetMarketplaceOrders Method", userName: "******"); } return(marketplaceOrders); }
public void ListOrders() { ame = new Amazon__Entity(); aml = new Amazon__BL(); ame = aml.MAPI_DRequest(); //string SellerId = CommonValue.strMerchantId; //string MarketplaceId = CommonValue.strMarketplaceId; //string AccessKeyId = CommonValue.strAccessKeyId; //string SecretKeyId = CommonValue.strSecretKeyId; //string ApplicationVersion = CommonValue.strApplicationVersion; //string ApplicationName = CommonValue.strApplicationName; //string MWSAuthToken = CommonValue.strMWSAuthToken; //string strbuff = string.Empty; SellerId = ame.strMerchantId; MarketplaceId = ame.strMarketplaceId; AccessKeyId = ame.strAccessKeyId; MWSAuthToken = ame.strMWSAuthToken; SecretKeyId = ame.strSecretKeyId; APIKey = ame.APIKey; StoreCD = ame.StoreCD; string ApplicationVersion = CommonValue.strApplicationVersion; string ApplicationName = CommonValue.strApplicationName; DataTable strbuff = new DataTable(); var LastUpdatedBefore = aml.Amazon_DRequest(); if (LastUpdatedBefore != null) { UpdatedTimeBefore = Convert.ToDateTime(LastUpdatedBefore).AddDays(-1); } else { UpdatedTimeBefore = DateTime.Now;; } MarketplaceWebServiceOrdersConfig config = new MarketplaceWebServiceOrdersConfig(); config.ServiceURL = CommonValue.strServiceURL; MarketplaceWebServiceOrders.MarketplaceWebServiceOrders client = new MarketplaceWebServiceOrdersClient( AccessKeyId, SecretKeyId, ApplicationName, ApplicationVersion, config); ListOrdersRequest request = new ListOrdersRequest(); request.SellerId = SellerId; request.LastUpdatedAfter = UpdatedTimeBefore; List <string> lstMarketplace = new List <string>(); lstMarketplace.Add(MarketplaceId); request.MarketplaceId = lstMarketplace; request.MWSAuthToken = MWSAuthToken; request.MaxResultsPerPage = 40; ListOrdersResponse response = client.ListOrders(request); ListOrdersResult listOrdersResult = new ListOrdersResult(); if (response.IsSetListOrdersResult()) { listOrdersResult = response.ListOrdersResult; if (listOrdersResult.IsSetOrders()) { List <Order> orders = listOrdersResult.Orders; strbuff.Columns.Add("StoreCD"); strbuff.Columns.Add("APIKey"); strbuff.Columns.Add("SEQ"); strbuff.Columns.Add("OrderId"); int i = 0; Amazon_Juchuu = D_AmazonJuchuu(); foreach (Order o in orders) { i++; strbuff.Rows.Add(StoreCD, APIKey, i, o.AmazonOrderId); GetListOrderdata(o, i); } } // txtListOrders.Text = strbuff; } Base_BL bbl = new Base_BL(); string OrderDetails = ""; string AmazonOrderId = ""; OrderDetails = bbl.DataTableToXml(Amazon_Juchuu); AmazonOrderId = bbl.DataTableToXml(strbuff); TokenNo = TokenNo + 1; Insert_FirstToken(listOrdersResult, OrderDetails, AmazonOrderId); if (listOrdersResult.NextToken != null) { Insert_NextToken(response.ListOrdersResult.NextToken); } Insert_Items(client); Console.Read(); // //else //{ // Console.Write("Order Inserted Successfully!!!"); // Console.Read(); //} }
public static DataSet ListAmazonOrderHeader(string accountName, string merchantId, string marketplaceId, string accessKeyId, string secretAccessKey) { DataSet amazonOrderHeaderListDs = new DataSet(); const string applicationName = "<Your Application Name>"; const string applicationVersion = "<Your Application Version>"; ListOrdersRequest request = new ListOrdersRequest(); string sellerId = merchantId; request.SellerId = sellerId; DateTime createdAfter = System.DateTime.Now.AddDays(-15); request.CreatedAfter = createdAfter; List <string> orderStatusList = new List <string>(); orderStatusList.Add("Unshipped"); orderStatusList.Add("PartiallyShipped"); //orderStatusList.Add("Shipped"); //orderStatusList.Add("Pending"); //orderStatusList.Add("Canceled"); request.OrderStatus = orderStatusList; List <string> marketplaceIdList = new List <string>(); marketplaceIdList.Add(marketplaceId); request.MarketplaceId = marketplaceIdList; MarketplaceWebServiceOrdersConfig config = new MarketplaceWebServiceOrdersConfig(); config.ServiceURL = "https://mws.amazonservices.com"; MarketplaceWebServiceOrdersClient client = new MarketplaceWebServiceOrdersClient(accessKeyId, secretAccessKey, applicationName, applicationVersion, config); //MarketplaceWebServiceOrdersSample sample = new MarketplaceWebServiceOrdersSample(client); try { IMWSResponse response = null; response = client.ListOrders(request); ResponseHeaderMetadata rhmd = response.ResponseHeaderMetadata; string responseXml = response.ToXML(); System.IO.File.WriteAllText(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\AmazonOrderHeaderList.xml", responseXml); amazonOrderHeaderListDs.ReadXml(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\AmazonOrderHeaderList.xml", XmlReadMode.InferSchema); return(amazonOrderHeaderListDs); } catch (MarketplaceWebServiceOrdersException ex) { 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); ExceptionUtility exceptionUtility = new ExceptionUtility(); exceptionUtility.ErrorWarningMethod("Amazon List Order Header Service Exception: " + accountName, "Message: " + ex.Message, senderEmail, messageFromPassword, messageToEmail, smtpClient, smtpPortNum); return(amazonOrderHeaderListDs); } catch (Exception ex) { ExceptionUtility exceptionUtility = new ExceptionUtility(); exceptionUtility.ErrorWarningMethod("Amazon List Order Header Code General Error: " + accountName, "ex: " + ex.Message, senderEmail, messageFromPassword, messageToEmail, smtpClient, smtpPortNum); return(amazonOrderHeaderListDs); } }
public JsonResult CreateOrder() { MarketplaceWebServiceOrdersConfig config = new MarketplaceWebServiceOrdersConfig(); config.ServiceURL = CommonValue.strServiceURL; MarketplaceWebServiceOrders.MarketplaceWebServiceOrders client = new MarketplaceWebServiceOrdersClient( AccessKeyId, SecretKeyId, ApplicationName, ApplicationVersion, config); ListOrdersRequest _req = new ListOrdersRequest(); List <string> _marketPlaceId = new List <string>(); _marketPlaceId.Add(MarketplaceId); _req.MarketplaceId = _marketPlaceId; _req.CreatedAfter = DateTime.Now.AddDays(-1); //_req.CreatedBefore = Convert.ToDateTime("2017-01-01"); //_req.CreatedAfter = Convert.ToDateTime("2017-01-01"); _req.SellerId = SellerId; _req.MWSAuthToken = MWSAuthToken; ListOrdersResponse listorders = client.ListOrders(_req); ProductWarehouseInventory product; bool shippingRequired = false; var _objAmazonOrderResponse = AmazonOrderResponse(); List <AmazonOrderItemModel> _objAmazonOrderItem = new List <AmazonOrderItemModel>(); ListOrderItemsResponse _objOrderitem = new ListOrderItemsResponse(); foreach (var item in _objAmazonOrderResponse.ListOrdersResult.Orders) { _objOrderitem = AmazonOrderItemResponse(item.AmazonOrderId); var orderitem = _objOrderitem.ListOrderItemsResult.OrderItems; foreach (var _orderitem in orderitem) { AmazonOrderItemModel _objSku = new AmazonOrderItemModel(); _objSku.AmazonSKU = _orderitem.SellerSKU; _objAmazonOrderItem.Add(_objSku); } } Customer customer = _customerService.GetCustomerByEmail("*****@*****.**"); AddOrderItemsToCart(_objAmazonOrderItem, customer, 1); if (customer == null) { ErrorNotification("Customer Not Found Order Api"); } OrderModel model = new OrderModel(); //if (shippingRequired) //{ // bool isValid = true; // isValid &= SetShippingOption(orderDelta.Dto.ShippingRateComputationMethodSystemName, // orderDelta.Dto.ShippingMethod, // orderDelta.Dto.StoreId ?? _storeContext.CurrentStore.Id, // customer, // BuildShoppingCartItemsFromOrderItemDtos(orderDelta.Dto.OrderItemDtos.ToList(), // customer.Id, // orderDelta.Dto.StoreId ?? _storeContext.CurrentStore.Id)); // isValid &= ValidateAddress(orderDelta.Dto.ShippingAddress, "shipping_address"); // if (!isValid) // { // return Error(HttpStatusCode.BadRequest); // } //} //if (!OrderSettings.DisableBillingAddressCheckoutStep) //{ // bool isValid = ValidateAddress(orderDelta.Dto.BillingAddress, "billing_address"); // if (!isValid) // { // return Error(HttpStatusCode.BadRequest); // } //} // Order newOrder = _factory.Initialize(); // orderDelta.Merge(newOrder); //// Order newOrder = new Order(); //// _orderService.InsertOrder(newOrder); //// customer.BillingAddress = newOrder.BillingAddress; //// customer.ShippingAddress = newOrder.ShippingAddress; //// // If the customer has something in the cart it will be added too. Should we clear the cart first? ////// newOrder.Customer = customer; //// // The default value will be the currentStore.id, but if it isn't passed in the json we need to set it by hand. //// if (!orderDelta.Dto.StoreId.HasValue) //// { //// newOrder.StoreId = _storeContext.CurrentStore.Id; //// } // PlaceOrderResult placeOrderResult = PlaceOrder(newOrder, customer); //if (!placeOrderResult.Success) //{ // foreach (var error in placeOrderResult.Errors) // { // ModelState.AddModelError("order placement", error); // } // return Error(HttpStatusCode.BadRequest); //} //ICustomerActivityService.InsertActivity("AddNewOrder", // _localizationService.GetResource("ActivityLog.AddNewOrder"), newOrder.Id); //var ordersRootObject = new OrdersRootObject(); //OrderDto placedOrderDto = placeOrderResult.PlacedOrder.ToDto(); //ordersRootObject.Orders.Add(placedOrderDto); //var json = _jsonFieldsSerializer.Serialize(newOrder, string.Empty); return(Json("result")); }
public static void GetOrderList() { dt = new DataTable(); dt.Columns.Add("OrderId"); MarketplaceWebServiceOrdersConfig config = new MarketplaceWebServiceOrdersConfig(); string SellerId = "A3U1G59YKB47LS"; string MarketplaceId = "A1VC38T7YXB528"; string AccessKeyId = "AKIAJFRPIMOTC4CJGHLQ"; string SecretKeyId = "4KI9yuXr7Ni64iFpdjnW1dw3LNdNXIn4rgOnNrZQ"; string ApplicationVersion = "1.0"; string ApplicationName = "ラスタスポーツ"; string MWSAuthToken = "amzn.mws.fea748c0-bfe0-4039-0cc0-88b6ce5c0058"; string serviceURL = "https://mws.amazonservices.jp"; string strbuff = string.Empty; config.ServiceURL = serviceURL; MarketplaceWebServiceOrders.MarketplaceWebServiceOrders client = new MarketplaceWebServiceOrdersClient( AccessKeyId, SecretKeyId, ApplicationName, ApplicationVersion, config); //ListOrder try { ListOrdersRequest request = new ListOrdersRequest(); request.SellerId = SellerId; request.CreatedAfter = DateTime.Now.AddDays(-1); List <string> lstMarketplace = new List <string>(); lstMarketplace.Add(MarketplaceId); request.MarketplaceId = lstMarketplace; request.MWSAuthToken = MWSAuthToken; ListOrdersResponse response = client.ListOrders(request); if (response.IsSetListOrdersResult()) { ListOrdersResult listOrdersResult = response.ListOrdersResult; if (listOrdersResult.IsSetOrders()) { List <Order> orders = listOrdersResult.Orders; foreach (Order order in orders) { dt.Rows.Add(order.AmazonOrderId); } } } } catch (Exception ex) { var msge = ex.Message; } //// ListOrderByNextToken try { ListOrdersRequest request = new ListOrdersRequest(); request.SellerId = SellerId; request.CreatedAfter = DateTime.Now.AddDays(-1); List <string> lstMarketplace = new List <string>(); lstMarketplace.Add(MarketplaceId); request.MarketplaceId = lstMarketplace; request.MaxResultsPerPage = 14; request.MWSAuthToken = MWSAuthToken; ListOrdersResponse response = client.ListOrders(request); if (response.IsSetListOrdersResult()) { ListOrdersResult listOrdersResult = response.ListOrdersResult; if (listOrdersResult.IsSetOrders()) { if (listOrdersResult.NextToken != null) { ListOrdersByNextTokenRequest request1 = new ListOrdersByNextTokenRequest(); request1.SellerId = SellerId; request1.MWSAuthToken = MWSAuthToken; request1.NextToken = listOrdersResult.NextToken; ListOrdersByNextTokenResponse response1 = client.ListOrdersByNextToken(request1); if (response1.IsSetListOrdersByNextTokenResult()) { ListOrdersByNextTokenResult listOrdersByNextResult = response1.ListOrdersByNextTokenResult; if (listOrdersByNextResult.IsSetOrders()) { List <Order> orders = listOrdersByNextResult.Orders; foreach (Order order in orders) { dt.Rows.Add(order.AmazonOrderId); // strbuff += order.AmazonOrderId + System.Environment.NewLine; } } } } } var val = strbuff; } Environment.Exit(0); } catch (Exception ex) { } // //List Order Item //try //{ // foreach (DataRow dr in dt.Rows) // { // ListOrderItemsRequest request = new ListOrderItemsRequest(); // request.SellerId = SellerId; // request.AmazonOrderId = dr["OrderId"].ToString(); // request.MWSAuthToken = MWSAuthToken; // ListOrderItemsResponse response = client.ListOrderItems(request); // if (response.IsSetListOrderItemsResult()) // { // ListOrderItemsResult listOrderItemsResult = response.ListOrderItemsResult; // if (listOrderItemsResult.IsSetOrderItems()) // { // List<OrderItem> orderItems = listOrderItemsResult.OrderItems; // foreach (OrderItem orderItem in orderItems) // { // strbuff += "商品名:" + orderItem.Title + System.Environment.NewLine; // } // } // } // } //} //catch (Exception ex) //{ //} //// ListOrderItem_byNextToken try { foreach (DataRow dr in dt.Rows) { ListOrderItemsRequest request = new ListOrderItemsRequest(); request.SellerId = SellerId; request.AmazonOrderId = dr["OrderId"].ToString(); request.MWSAuthToken = MWSAuthToken; ListOrderItemsResponse response = client.ListOrderItems(request); if (response.IsSetListOrderItemsResult()) { ListOrderItemsResult listOrderItemsResult = response.ListOrderItemsResult; if (listOrderItemsResult.NextToken != null) { ListOrderItemsByNextTokenRequest request1 = new ListOrderItemsByNextTokenRequest(); request1.SellerId = SellerId; request1.MWSAuthToken = MWSAuthToken; request1.NextToken = listOrderItemsResult.NextToken; ListOrderItemsByNextTokenResponse response1 = client.ListOrderItemsByNextToken(request1); if (response1.IsSetListOrderItemsByNextTokenResult()) { ListOrderItemsByNextTokenResult listOrderByNextItemsResult = response1.ListOrderItemsByNextTokenResult; if (listOrderByNextItemsResult.IsSetOrderItems()) { List <OrderItem> orderItems = listOrderItemsResult.OrderItems; foreach (OrderItem orderItem in orderItems) { if (orderItem.IsSetOrderItemId()) { strbuff += "商品名:" + orderItem.Title + System.Environment.NewLine; } } } } } } } } catch (Exception ex) { } //// GetOrder //try //{ // foreach (DataRow dr in dt.Rows) // { // GetOrderRequest request = new GetOrderRequest(); // request.SellerId = SellerId; // request.MWSAuthToken = MWSAuthToken; // List<string> amazonorderId = new List<string>(); // amazonorderId.Add(dr["OrderId"].ToString()); // request.AmazonOrderId = amazonorderId; // GetOrderResponse response = client.GetOrder(request); // if (response.IsSetGetOrderResult()) // { // List<Order> orders = response.GetOrderResult.Orders; // foreach (Order order in orders) // { // strbuff += "購入者:" + order.AmazonOrderId + ","+ order.OrderStatus + System.Environment.NewLine; // } // } // } //} //catch (Exception ex) //{ //} //// GetService Status //try //{ // MarketplaceWebServiceOrdersConfig config1 = new MarketplaceWebServiceOrdersConfig(); // config1.ServiceURL = serviceURL; // MarketplaceWebServiceOrders.MarketplaceWebServiceOrders client1 = new MarketplaceWebServiceOrdersClient( // AccessKeyId, // SecretKeyId, // ApplicationName, // ApplicationVersion, // config1); // MarketplaceWebServiceOrders.Model.GetServiceStatusRequest request = new MarketplaceWebServiceOrders.Model.GetServiceStatusRequest(); // request.SellerId = SellerId; // request.MWSAuthToken = MWSAuthToken; // // MarketplaceWebServiceOrders.Model.GetServiceStatusRequest // var response = client1.GetServiceStatus(request); // if (response.IsSetGetServiceStatusResult()) // { // strbuff = "処理状況:" + response.GetServiceStatusResult.Status; // } //} //catch (Exception ex) //{ //} }