public async override Task <ListOrdersResponse> ListOrders(ListOrdersRequest request, ServerCallContext context) { var response = new ListOrdersResponse(); response.OrderIds.AddRange(await _repo.ListOrderIds(request.BuyerId)); return(response); }
public static ListOrdersResponse Unmarshall(UnmarshallerContext _ctx) { ListOrdersResponse listOrdersResponse = new ListOrdersResponse(); listOrdersResponse.HttpResponse = _ctx.HttpResponse; listOrdersResponse.TotalCount = _ctx.LongValue("ListOrders.TotalCount"); listOrdersResponse.RequestId = _ctx.StringValue("ListOrders.RequestId"); listOrdersResponse.ErrorCode = _ctx.StringValue("ListOrders.ErrorCode"); listOrdersResponse.ErrorMessage = _ctx.StringValue("ListOrders.ErrorMessage"); listOrdersResponse.Success = _ctx.BooleanValue("ListOrders.Success"); List <ListOrdersResponse.ListOrders_Order> listOrdersResponse_orders = new List <ListOrdersResponse.ListOrders_Order>(); for (int i = 0; i < _ctx.Length("ListOrders.Orders.Length"); i++) { ListOrdersResponse.ListOrders_Order order = new ListOrdersResponse.ListOrders_Order(); order.StatusDesc = _ctx.StringValue("ListOrders.Orders[" + i + "].StatusDesc"); order.Comment = _ctx.StringValue("ListOrders.Orders[" + i + "].Comment"); order.CreateTime = _ctx.StringValue("ListOrders.Orders[" + i + "].CreateTime"); order.Committer = _ctx.StringValue("ListOrders.Orders[" + i + "].Committer"); order.OrderId = _ctx.LongValue("ListOrders.Orders[" + i + "].OrderId"); order.LastModifyTime = _ctx.StringValue("ListOrders.Orders[" + i + "].LastModifyTime"); order.PluginType = _ctx.StringValue("ListOrders.Orders[" + i + "].PluginType"); order.CommitterId = _ctx.LongValue("ListOrders.Orders[" + i + "].CommitterId"); order.StatusCode = _ctx.StringValue("ListOrders.Orders[" + i + "].StatusCode"); listOrdersResponse_orders.Add(order); } listOrdersResponse.Orders = listOrdersResponse_orders; return(listOrdersResponse); }
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> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { ListOrdersResponse response = new ListOrdersResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("NextToken", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.NextToken = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("Orders", targetDepth)) { var unmarshaller = new ListUnmarshaller <OrderSummary, OrderSummaryUnmarshaller>(OrderSummaryUnmarshaller.Instance); response.Orders = unmarshaller.Unmarshall(context); continue; } } return(response); }
public void synOrder(Shop shop) { if (shop.OrderLastUpDatedAfter == null) { shop.OrderLastUpDatedAfter = AppConstant.lastUpdatedAfter; } if (lastUpdatedAfter == null) { this.lastUpdatedAfter = shop.OrderLastUpDatedAfter.Value; } this.sellerId = shop.SellerId; this.mwsAuthToken = shop.MwsAuthToken; shopId = shop.Id; shopMarketplaceId = shop.ShopMarketplaceId; MarketplaceWebServiceOrdersConfig config = new MarketplaceWebServiceOrdersConfig(); config.ServiceURL = serviceURL; client = new MarketplaceWebServiceOrdersClient(accessKey, secretKey, appName, appVersion, config); ListOrdersResponse listOrdersResponse = getListOrders(); if (listOrdersResponse == null) { return; } foreach (Order order in listOrdersResponse.ListOrdersResult.Orders) { dealOrder(shopId, order); } if (String.IsNullOrEmpty(listOrdersResponse.ListOrdersResult.NextToken)) { return; } ListOrdersByNextTokenResponse listOrdersByNextTokenResponse = getListOrdersByNextToken(listOrdersResponse.ListOrdersResult.NextToken); if (listOrdersByNextTokenResponse == null) { return; } while (true) { foreach (Order order in listOrdersByNextTokenResponse.ListOrdersByNextTokenResult.Orders) { dealOrder(shopId, order); } if (String.IsNullOrEmpty(listOrdersByNextTokenResponse.ListOrdersByNextTokenResult.NextToken)) { return; } listOrdersByNextTokenResponse = getListOrdersByNextToken(listOrdersByNextTokenResponse.ListOrdersByNextTokenResult.NextToken); if (listOrdersByNextTokenResponse == null) { return; } } }
private ListOrdersResponse InvokeListOrders(PXGraph graph, ServiceCallParameters objParams) { ListOrdersResponse response = new ListOrdersResponse(); try { ListOrdersRequest request = new ListOrdersRequest(); request.SellerId = objParams.objSOAmazonSetup.SellerId; request.MWSAuthToken = objParams.objSOAmazonSetup.AuthToken; List <string> marketplaceId = new List <string>(); marketplaceId.Add(objParams.objSOAmazonSetup.MarketplaceId); request.MarketplaceId = marketplaceId; request.CreatedAfter = Convert.ToDateTime(objParams.fromDate); if (objParams.toDate.Value.Date < DateTime.Now.Date) { request.CreatedBefore = objParams.toDate.Value.AddDays(1).AddTicks(-1); } PXTrace.WriteInformation("objParams.fromDate.Value.Date:" + objParams.fromDate.Value.Date.ToString()); PXTrace.WriteInformation("objParams.toDate.Value.Date:" + objParams.toDate.Value.Date.ToString()); PXTrace.WriteInformation("request.CreatedAfter:" + request.CreatedAfter.ToString()); PXTrace.WriteInformation("request.CreatedBefore:" + request.CreatedBefore.ToString()); List <string> liFulfillmentChannel = null; List <string> liOrderStatus = null; SOHelper.GetFilterValues(objParams.objSOAmazonSetup.IntegrationType.Trim(), out liFulfillmentChannel, out liOrderStatus); request.FulfillmentChannel = liFulfillmentChannel; request.OrderStatus = liOrderStatus; response = this.clientOrder.ListOrders(request); } catch (Exception ex) { if (ex is MarketplaceWebServiceOrdersException) { MarketplaceWebServiceOrdersException exception = ex as MarketplaceWebServiceOrdersException; if (!string.IsNullOrEmpty(exception.ErrorCode) && exception.ErrorCode.ToLower().Trim() == SOMessages.requestThrottled) { Thread.Sleep(SOHelper.DelayProcess(graph, SOConstants.apiListOrders)); response = InvokeListOrders(graph, objParams); } else { throw new PXException(!string.IsNullOrEmpty(ex.Message) ? ex.Message : ex.InnerException != null && ex.InnerException.InnerException != null ? ex.InnerException.InnerException.Message : SOConstants.exceptionIsEmpty); } } else { throw new PXException(!string.IsNullOrEmpty(ex.Message) ? ex.Message : ex.InnerException != null && ex.InnerException.InnerException != null ? ex.InnerException.InnerException.Message : SOConstants.exceptionIsEmpty); } } return(response); }
/// <summary> /// Handles the specified command. /// </summary> /// <param name="command">The command.</param> public async void Handle(AmazonGetOrders3dPartyCommand command) { InfoAccumulator info = new InfoAccumulator(); ListOrdersRequest request = new ListOrdersRequest { MWSAuthToken = command.AuthorizationToken, MarketplaceId = new List <string>(command.MarketplaceId), SellerId = command.SellerId, CreatedAfter = command.DateFrom.ToUniversalTime() }; //get first page ListOrdersResponse response = await AmazonService.Orders.ListOrders(request); List <IEnumerable <AmazonOrderItemAndPayments> > results = new List <IEnumerable <AmazonOrderItemAndPayments> >(); if (response.IsSetListOrdersResult()) { //process first page var orders = CreateOrders(response.ListOrdersResult); results.Add(orders); //get next pages string nextToken = response.ListOrdersResult.NextToken; while (StringUtils.IsNotEmpty(nextToken)) { var nextRequest = new ListOrdersByNextTokenRequest { MWSAuthToken = command.AuthorizationToken, NextToken = nextToken, SellerId = command.SellerId }; //get next page ListOrdersByNextTokenResponse nextResponse = await AmazonService.Orders.ListOrdersByNextToken(nextRequest); if (nextResponse != null && nextResponse.IsSetListOrdersByNextTokenResult()) { //process next page results var nextOrders = nextResponse.ListOrdersByNextTokenResult.Orders.Select(CreateAmazonOrderItem); results.Add(nextOrders); nextToken = nextResponse.ListOrdersByNextTokenResult.NextToken; } else { nextToken = null; } } } SendReply(info, command, resp => resp.OrderPayments = results.SelectMany(o => o).ToArray()); }
/// <summary> /// Fetches all orders created in the given time period and processes them locally. /// <param name="startTime">The starting time period of orders to fetch.</param> /// <param name="endTime">The ending time period of orders to fetch.</param> public void FetchOrders(DateTime startTime, DateTime endTime) { ListOrdersRequest request = new ListOrdersRequest(); request.CreatedAfter = startTime; if (endTime != DateTime.MinValue) { request.CreatedBefore = endTime; } request.SellerId = mwsSellerId; request.MarketplaceId = new MarketplaceIdList(); request.MarketplaceId.Id = new List <string>(); foreach (string marketplaceId in mwsMarketplaceIdList) { request.MarketplaceId.Id.Add(marketplaceId); } List <Order> orderList = new List <Order>(); ListOrdersResponse response = null; OrderFetcher.InvokeRetriable(LIST_ORDERS_DEFAULT_THROTTLE_LIMIT, delegate() { response = mwsService.ListOrders(request); ProcessOrders(response.ListOrdersResult.Orders.Order); }); String nextTokenString = response.ListOrdersResult.NextToken; while (!string.IsNullOrEmpty(nextTokenString)) { // If NextToken is set, continue looping through the orders. ListOrdersByNextTokenRequest nextRequest = new ListOrdersByNextTokenRequest(); nextRequest.NextToken = nextTokenString; nextRequest.SellerId = mwsSellerId; ListOrdersByNextTokenResponse nextResponse = null; OrderFetcher.InvokeRetriable(LIST_ORDERS_DEFAULT_THROTTLE_LIMIT, delegate() { nextResponse = mwsService.ListOrdersByNextToken(nextRequest); ProcessOrders(nextResponse.ListOrdersByNextTokenResult.Orders.Order); }); nextTokenString = nextResponse.ListOrdersByNextTokenResult.NextToken; } }
public void UpdateOrders() { ListOrdersResponse listOrdersResponse = client.ListOrders(); if (listOrdersResponse.Result == 1 && listOrdersResponse.Orders.Count > 0) { List <Order> unshippedOrders = OrderService.GetOrders(StatusID: (int)Beasts.Model.Status.Processing).ToList(); foreach (Order order in unshippedOrders) { try { ListOrder listOrder = listOrdersResponse.Orders.Where(x => x.OrderId == order.PrintAuraID).FirstOrDefault(); if (listOrder != null) { if (listOrder.Status == Labs.PrintAura.Models.Status.Shipped) { var item = listOrder.Items.First(); Shipment shipment = new Shipment(); shipment.Tracking = item.Tracking; shipment.ShipDate = item.ShippedDate.ToDateTime(); shipment.Service = "USPS"; shipment.OrderID = order.OrderID; ShipmentService.CreateShipment(shipment); order.Status = Beasts.Model.Status.Shipped; OrderService.UpdateOrder(order); Email.SendTracking(OrderService.GetOrders(order.OrderID).FirstOrDefault()); } } } catch (Exception ex) { ExceptionService.CreateException(ex); } } } }
/// <summary> /// ListOrders can be used to find orders that meet the specified criteria. /// /// </summary> /// <param name="service">Instance of MarketplaceWebServiceOrders service</param> /// <param name="request">ListOrdersRequest request</param> public static void InvokeListOrders(MarketplaceWebServiceOrders service, ListOrdersRequest request) { try { ListOrdersResponse response = service.ListOrders(request); Console.WriteLine("Service Response"); Console.WriteLine("============================================================================="); Console.WriteLine(); Console.WriteLine(" ListOrdersResponse"); if (response.IsSetListOrdersResult()) { Console.WriteLine(" ListOrdersResult"); ListOrdersResult listOrdersResult = response.ListOrdersResult; if (listOrdersResult.IsSetNextToken()) { Console.WriteLine(" NextToken"); Console.WriteLine(" {0}", listOrdersResult.NextToken); } if (listOrdersResult.IsSetCreatedBefore()) { Console.WriteLine(" CreatedBefore"); Console.WriteLine(" {0}", listOrdersResult.CreatedBefore); } if (listOrdersResult.IsSetLastUpdatedBefore()) { Console.WriteLine(" LastUpdatedBefore"); Console.WriteLine(" {0}", listOrdersResult.LastUpdatedBefore); } if (listOrdersResult.IsSetOrders()) { Console.WriteLine(" Orders"); OrderList orders = listOrdersResult.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); } }
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 void SyncOrders(ERPContext context, string accountName, DateTime createdAfter, DateTime createdBefore, List <EbayOrderdetail> orderDetails) { if (!sellerIdDictionary.ContainsKey(accountName)) { m_logger.Error(accountName + " does not exist."); return; } m_logger.Info("Sync orders of " + accountName); try { ListOrdersRequest request = new ListOrdersRequest(); request.SellerId = sellerIdDictionary[accountName]; request.MWSAuthToken = mwsAuthTokenDictionary[accountName]; request.LastUpdatedAfter = createdAfter; request.LastUpdatedBefore = createdBefore; request.OrderStatus = new List <string>(); request.OrderStatus.Add("Unshipped"); request.OrderStatus.Add("PartiallyShipped"); List <string> marketplaceIds = new List <string>(); marketplaceIds.Add(marketplaceId); request.MarketplaceId = marketplaceIds; int retryCount = 0; ListOrdersResponse response = null; while (retryCount <= m_maxRetry && response == null) { if (retryCount > 0) { Thread.Sleep(TimeSpan.FromSeconds(retryCount * 2)); } try { response = client.ListOrders(request); } catch (Exception e) { if (retryCount > m_maxRetry) { throw e; } retryCount++; } } ProcessOrders(context, accountName, response.ListOrdersResult.Orders, orderDetails); string nextToken = response.ListOrdersResult.NextToken; while (nextToken != null) { ListOrdersByNextTokenRequest request1 = new ListOrdersByNextTokenRequest(); request1.SellerId = sellerIdDictionary[accountName]; request1.MWSAuthToken = mwsAuthTokenDictionary[accountName]; request1.NextToken = nextToken; retryCount = 0; ListOrdersByNextTokenResponse response1 = null; while (retryCount <= m_maxRetry && response == null) { if (retryCount > 0) { Thread.Sleep(TimeSpan.FromSeconds(retryCount * 2)); } try { response1 = client.ListOrdersByNextToken(request1); } catch (Exception e) { if (retryCount > m_maxRetry) { throw e; } retryCount++; } } ProcessOrders(context, accountName, response1.ListOrdersByNextTokenResult.Orders, orderDetails); nextToken = response1.ListOrdersByNextTokenResult.NextToken; } } catch (Exception e) { m_logger.Error(e.Message); } }
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) //{ //} }
private static void GetOrdersForTimeWindow( OrdersMonitorApp theApp, DateTime updatedAfter, DateTime updatedBefore ) { try { IMWSResponse response; ListOrdersResponse listOrdersResponse = null; ListOrdersByNextTokenResponse listOrdersByNextTokenResponse = null; string nextTokenFromRequest = null; OrderList ordersFromRequest; do { // if this is not the first request, get the rest of the request. if (nextTokenFromRequest != null) { Console.WriteLine("Get the next of the data"); response = theApp.InvokeListOrdersByNextToken(nextTokenFromRequest); listOrdersByNextTokenResponse = (ListOrdersByNextTokenResponse)response; nextTokenFromRequest = listOrdersByNextTokenResponse.ListOrdersByNextTokenResult.NextToken; ordersFromRequest = listOrdersByNextTokenResponse.ListOrdersByNextTokenResult.Orders; } else { // we are making a request for the first time. response = theApp.InvokeListOrders(updatedAfter, updatedBefore); listOrdersResponse = (ListOrdersResponse)response; nextTokenFromRequest = listOrdersResponse.ListOrdersResult.NextToken; ordersFromRequest = listOrdersResponse.ListOrdersResult.Orders; } ResponseHeaderMetadata rhmd = response.ResponseHeaderMetadata; // We recommend logging the request id and timestamp of every call. Console.WriteLine("RequestId: " + rhmd.RequestId + "Timestamp: " + rhmd.Timestamp); using (var db = new OrderContext()) { foreach (Order order in ordersFromRequest.Order) { Console.WriteLine(order.AmazonOrderId + " " + order.PurchaseDate + " " + order.LastUpdateDate); // is this order already in the database ? var queryDuplicateCheck = from o in db.Orders where o.AmazonOrderId == order.AmazonOrderId select o; if (order.ShippingAddress != null) { if (queryDuplicateCheck.Any()) { var dbOrder = queryDuplicateCheck.First(); db.Orders.Remove(dbOrder); db.Orders.Add(order); } else { db.Orders.Add(order); } } if (!queryDuplicateCheck.Any() && order.ShippingAddress != null) { db.Orders.Add(order); } } db.SaveChanges(); } Thread.Sleep(30000); } while (nextTokenFromRequest != null); } 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); } }
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 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(); //} }