/// <summary> /// Sets the ListOrdersByNextTokenResult property. /// </summary> /// <param name="listOrdersByNextTokenResult">ListOrdersByNextTokenResult property.</param> /// <returns>this instance.</returns> public ListOrdersByNextTokenResponse WithListOrdersByNextTokenResult(ListOrdersByNextTokenResult listOrdersByNextTokenResult) { this._listOrdersByNextTokenResult = listOrdersByNextTokenResult; return(this); }
public override void ReadFragmentFrom(IMwsReader reader) { _listOrdersByNextTokenResult = reader.Read <ListOrdersByNextTokenResult>("ListOrdersByNextTokenResult"); _responseMetadata = reader.Read <ResponseMetadata>("ResponseMetadata"); }
public void Insert_NextToken(string token = null) { Amazon_Juchuu_NextToken = D_AmazonJuchuu(); Base_BL bbl = new Base_BL(); DataTable strbuff = new DataTable(); strbuff.Columns.Add("StoreCD"); strbuff.Columns.Add("APIKey"); strbuff.Columns.Add("SEQ"); strbuff.Columns.Add("OrderId"); MarketplaceWebServiceOrdersConfig config = new MarketplaceWebServiceOrdersConfig(); config.ServiceURL = CommonValue.strServiceURL; MarketplaceWebServiceOrders.MarketplaceWebServiceOrders client = new MarketplaceWebServiceOrdersClient( AccessKeyId, SecretKeyId, ApplicationName, ApplicationVersion, config); if (token != null) { ListOrdersByNextTokenRequest request1 = new ListOrdersByNextTokenRequest(); ListOrdersByNextTokenResult listOrdersByNextResult = new ListOrdersByNextTokenResult(); request1.SellerId = SellerId; request1.MWSAuthToken = MWSAuthToken; request1.NextToken = token; ListOrdersByNextTokenResponse response1 = client.ListOrdersByNextToken(request1); if (response1.IsSetListOrdersByNextTokenResult()) { listOrdersByNextResult = response1.ListOrdersByNextTokenResult; if (listOrdersByNextResult.IsSetOrders()) { List <Order> orders = listOrdersByNextResult.Orders; int i = 0; foreach (Order o in orders) { i++; strbuff.Rows.Add(StoreCD, APIKey, i, o.AmazonOrderId); GetListOrderdata(o, i, false); } } } Amazon__Entity ameDetails = new Amazon__Entity(); ameDetails.StoreCD = StoreCD; ameDetails.APIKey = APIKey; ameDetails.LastUpdatedAfter = UpdatedTimeBefore.ToString(); ameDetails.LastUpdatedBefore = listOrdersByNextResult.LastUpdatedBefore.ToString(); ameDetails.Xmldetails = bbl.DataTableToXml(Amazon_Juchuu_NextToken); ameDetails.XmlOrder = bbl.DataTableToXml(strbuff); TokenNo = TokenNo + 1; if (aml.AmazonAPI_Insert_NextToken(ameDetails)) { Console.WriteLine("Successfully Inserted Token " + (TokenNo).ToString() + "Times"); } else { Console.WriteLine("Unfortunately Inserted Failed Token " + (TokenNo).ToString() + "Times"); } Insert_NextToken(listOrdersByNextResult.NextToken); } else/// To be Continued. . . Insert { Console.Write("Order inserted Successfully!!!"); Console.Read(); } }
private Order[] ListOrders(DateTime CreatedAfter, DateTime CreatedBefore, DateTime LastUpdatedAfter, DateTime LastUpdatedBefore, EOrderStatus[] OrderStatus) { string NextToken = string.Empty; AmazonCredential Credentials = this.GetCredential(); MarketplaceWebServiceOrdersClient Client = this.GetClient(Credentials); ListOrdersRequest Request = new ListOrdersRequest() { SellerId = Credentials.SellerID, MarketplaceId = new List <string>() { Credentials.MarketplaceID }, }; if (CreatedAfter != default(DateTime) && CreatedBefore != default(DateTime)) { Request.CreatedAfter = CreatedAfter; Request.CreatedBefore = CreatedBefore; } if (LastUpdatedAfter != default(DateTime) && LastUpdatedBefore != default(DateTime)) { Request.LastUpdatedAfter = LastUpdatedAfter; Request.LastUpdatedBefore = LastUpdatedBefore; } if (OrderStatus != null) { Request.OrderStatus = OrderStatus.Select(Item => Item.ToString()).ToList(); } List <Order> Orders = new List <Order>(); Task ListOrdersTask = new Task(() => { while (true) { switch (string.IsNullOrWhiteSpace(NextToken)) { case true: this.Throttle(ERequestType.ListOrders); ListOrdersResponse Response = Client.ListOrders(Request); if (Response.IsSetListOrdersResult()) { ListOrdersResult Result = Response.ListOrdersResult; if (Result.IsSetOrders()) { foreach (var Order in Result.Orders) { Orders.Add(Order); } } if (Result.IsSetNextToken()) { NextToken = Result.NextToken; } else { goto EndOfLoop; } } break; case false: this.Throttle(ERequestType.ListOrders); ListOrdersByNextTokenRequest RequestNextToken = new ListOrdersByNextTokenRequest() { SellerId = Credentials.SellerID, NextToken = NextToken }; ListOrdersByNextTokenResponse ResponseNextToken = Client.ListOrdersByNextToken(RequestNextToken); if (ResponseNextToken.IsSetListOrdersByNextTokenResult()) { ListOrdersByNextTokenResult ResultNextToken = ResponseNextToken.ListOrdersByNextTokenResult; if (ResultNextToken.IsSetOrders()) { foreach (var Order in ResultNextToken.Orders) { Orders.Add(Order); } } if (ResultNextToken.IsSetNextToken()) { NextToken = ResultNextToken.NextToken; } else { goto EndOfLoop; } } break; } } EndOfLoop: Console.Write(""); }); ListOrdersTask.Start(); ListOrdersTask.Wait((int)Math.Ceiling(TimeSpan.FromMinutes(Definitions.Timeout_Minutes).Add(TimeSpan.FromHours(Definitions.Timeout_Hours)).TotalMilliseconds)); return(Orders.ToArray()); }
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) //{ //} }
/// <summary> /// If ListOrders returns a nextToken, thus indicating that there are more orders /// than returned that matched the given filter criteria, ListOrdersByNextToken /// can be used to retrieve those other orders using that nextToken. /// /// </summary> /// <param name="service">Instance of MarketplaceWebServiceOrders service</param> /// <param name="request">ListOrdersByNextTokenRequest request</param> public static void InvokeListOrdersByNextToken(MarketplaceWebServiceOrders service, ListOrdersByNextTokenRequest request) { try { ListOrdersByNextTokenResponse response = service.ListOrdersByNextToken(request); Console.WriteLine("Service Response"); Console.WriteLine("============================================================================="); Console.WriteLine(); Console.WriteLine(" ListOrdersByNextTokenResponse"); if (response.IsSetListOrdersByNextTokenResult()) { Console.WriteLine(" ListOrdersByNextTokenResult"); ListOrdersByNextTokenResult listOrdersByNextTokenResult = response.ListOrdersByNextTokenResult; if (listOrdersByNextTokenResult.IsSetNextToken()) { Console.WriteLine(" NextToken"); Console.WriteLine(" {0}", listOrdersByNextTokenResult.NextToken); } if (listOrdersByNextTokenResult.IsSetCreatedBefore()) { Console.WriteLine(" CreatedBefore"); Console.WriteLine(" {0}", listOrdersByNextTokenResult.CreatedBefore); } if (listOrdersByNextTokenResult.IsSetLastUpdatedBefore()) { Console.WriteLine(" LastUpdatedBefore"); Console.WriteLine(" {0}", listOrdersByNextTokenResult.LastUpdatedBefore); } if (listOrdersByNextTokenResult.IsSetOrders()) { Console.WriteLine(" Orders"); OrderList orders = listOrdersByNextTokenResult.Orders; List <Order> orderList = orders.Order; foreach (Order order in orderList) { Console.WriteLine(" Order"); if (order.IsSetAmazonOrderId()) { Console.WriteLine(" AmazonOrderId"); Console.WriteLine(" {0}", order.AmazonOrderId); } if (order.IsSetSellerOrderId()) { Console.WriteLine(" SellerOrderId"); Console.WriteLine(" {0}", order.SellerOrderId); } if (order.IsSetPurchaseDate()) { Console.WriteLine(" PurchaseDate"); Console.WriteLine(" {0}", order.PurchaseDate); } if (order.IsSetLastUpdateDate()) { Console.WriteLine(" LastUpdateDate"); Console.WriteLine(" {0}", order.LastUpdateDate); } if (order.IsSetOrderStatus()) { Console.WriteLine(" OrderStatus"); Console.WriteLine(" {0}", order.OrderStatus); } if (order.IsSetFulfillmentChannel()) { Console.WriteLine(" FulfillmentChannel"); Console.WriteLine(" {0}", order.FulfillmentChannel); } if (order.IsSetSalesChannel()) { Console.WriteLine(" SalesChannel"); Console.WriteLine(" {0}", order.SalesChannel); } if (order.IsSetOrderChannel()) { Console.WriteLine(" OrderChannel"); Console.WriteLine(" {0}", order.OrderChannel); } if (order.IsSetShipServiceLevel()) { Console.WriteLine(" ShipServiceLevel"); Console.WriteLine(" {0}", order.ShipServiceLevel); } if (order.IsSetShippingAddress()) { Console.WriteLine(" ShippingAddress"); Address shippingAddress = order.ShippingAddress; if (shippingAddress.IsSetName()) { Console.WriteLine(" Name"); Console.WriteLine(" {0}", shippingAddress.Name); } if (shippingAddress.IsSetAddressLine1()) { Console.WriteLine(" AddressLine1"); Console.WriteLine(" {0}", shippingAddress.AddressLine1); } if (shippingAddress.IsSetAddressLine2()) { Console.WriteLine(" AddressLine2"); Console.WriteLine(" {0}", shippingAddress.AddressLine2); } if (shippingAddress.IsSetAddressLine3()) { Console.WriteLine(" AddressLine3"); Console.WriteLine(" {0}", shippingAddress.AddressLine3); } if (shippingAddress.IsSetCity()) { Console.WriteLine(" City"); Console.WriteLine(" {0}", shippingAddress.City); } if (shippingAddress.IsSetCounty()) { Console.WriteLine(" County"); Console.WriteLine(" {0}", shippingAddress.County); } if (shippingAddress.IsSetDistrict()) { Console.WriteLine(" District"); Console.WriteLine(" {0}", shippingAddress.District); } if (shippingAddress.IsSetStateOrRegion()) { Console.WriteLine(" StateOrRegion"); Console.WriteLine(" {0}", shippingAddress.StateOrRegion); } if (shippingAddress.IsSetPostalCode()) { Console.WriteLine(" PostalCode"); Console.WriteLine(" {0}", shippingAddress.PostalCode); } if (shippingAddress.IsSetCountryCode()) { Console.WriteLine(" CountryCode"); Console.WriteLine(" {0}", shippingAddress.CountryCode); } if (shippingAddress.IsSetPhone()) { Console.WriteLine(" Phone"); Console.WriteLine(" {0}", shippingAddress.Phone); } } if (order.IsSetOrderTotal()) { Console.WriteLine(" OrderTotal"); Money orderTotal = order.OrderTotal; if (orderTotal.IsSetCurrencyCode()) { Console.WriteLine(" CurrencyCode"); Console.WriteLine(" {0}", orderTotal.CurrencyCode); } if (orderTotal.IsSetAmount()) { Console.WriteLine(" Amount"); Console.WriteLine(" {0}", orderTotal.Amount); } } if (order.IsSetNumberOfItemsShipped()) { Console.WriteLine(" NumberOfItemsShipped"); Console.WriteLine(" {0}", order.NumberOfItemsShipped); } if (order.IsSetNumberOfItemsUnshipped()) { Console.WriteLine(" NumberOfItemsUnshipped"); Console.WriteLine(" {0}", order.NumberOfItemsUnshipped); } if (order.IsSetPaymentExecutionDetail()) { Console.WriteLine(" PaymentExecutionDetail"); PaymentExecutionDetailItemList paymentExecutionDetail = order.PaymentExecutionDetail; List <PaymentExecutionDetailItem> paymentExecutionDetailItemList = paymentExecutionDetail.PaymentExecutionDetailItem; foreach (PaymentExecutionDetailItem paymentExecutionDetailItem in paymentExecutionDetailItemList) { Console.WriteLine(" PaymentExecutionDetailItem"); if (paymentExecutionDetailItem.IsSetPayment()) { Console.WriteLine(" Payment"); Money payment = paymentExecutionDetailItem.Payment; if (payment.IsSetCurrencyCode()) { Console.WriteLine(" CurrencyCode"); Console.WriteLine(" {0}", payment.CurrencyCode); } if (payment.IsSetAmount()) { Console.WriteLine(" Amount"); Console.WriteLine(" {0}", payment.Amount); } } if (paymentExecutionDetailItem.IsSetPaymentMethod()) { Console.WriteLine(" PaymentMethod"); Console.WriteLine(" {0}", paymentExecutionDetailItem.PaymentMethod); } } } if (order.IsSetPaymentMethod()) { Console.WriteLine(" PaymentMethod"); Console.WriteLine(" {0}", order.PaymentMethod); } if (order.IsSetMarketplaceId()) { Console.WriteLine(" MarketplaceId"); Console.WriteLine(" {0}", order.MarketplaceId); } if (order.IsSetBuyerEmail()) { Console.WriteLine(" BuyerEmail"); Console.WriteLine(" {0}", order.BuyerEmail); } if (order.IsSetBuyerName()) { Console.WriteLine(" BuyerName"); Console.WriteLine(" {0}", order.BuyerName); } if (order.IsSetShipmentServiceLevelCategory()) { Console.WriteLine(" ShipmentServiceLevelCategory"); Console.WriteLine(" {0}", order.ShipmentServiceLevelCategory); } if (order.IsSetShippedByAmazonTFM()) { Console.WriteLine(" ShippedByAmazonTFM"); Console.WriteLine(" {0}", order.ShippedByAmazonTFM); } if (order.IsSetTFMShipmentStatus()) { Console.WriteLine(" TFMShipmentStatus"); Console.WriteLine(" {0}", order.TFMShipmentStatus); } } } } 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); Console.WriteLine(); } catch (MarketplaceWebServiceOrdersException ex) { Console.WriteLine("Caught Exception: " + ex.Message); Console.WriteLine("Response Status Code: " + ex.StatusCode); Console.WriteLine("Error Code: " + ex.ErrorCode); Console.WriteLine("Error Type: " + ex.ErrorType); Console.WriteLine("Request ID: " + ex.RequestId); Console.WriteLine("XML: " + ex.XML); Console.WriteLine("ResponseHeaderMetadata: " + ex.ResponseHeaderMetadata); } }