Ejemplo n.º 1
0
        public bool IsOrdersReceived( DateTime? dateFrom = null, DateTime? dateTo = null )
        {
            try
            {
                dateFrom = dateFrom ?? DateTime.UtcNow.AddHours( -1 );
                dateTo = dateTo ?? DateTime.UtcNow.AddMinutes( -10 );
                var client = this._factory.CreateOrdersClient( "SkuVault", "1.0" );
                var request = new ListOrdersRequest
                {
                    SellerId = this._credentials.SellerId,
                    LastUpdatedAfter = dateFrom.Value,
                    //LastUpdatedBefore = dateTo,
                    MarketplaceId = this._credentials.AmazonMarketplace.GetMarketplaceIdAsList(),
                    MWSAuthToken = this._credentials.MwsAuthToken
                };

                AmazonLogger.Log.Trace( "[amazon] Checking orders for seller {0}", this._credentials.SellerId );

                var service = new OrdersService( client, request );
                if( service.IsOrdersReceived() )
                {
                    AmazonLogger.Log.Trace( "[amazon] Checking orders for seller {0} finished", this._credentials.SellerId );
                    return true;
                }
                AmazonLogger.Log.Warn( "[amazon] Checking orders for seller {0} failed", this._credentials.SellerId );
                return false;
            }
            catch( Exception ex )
            {
                AmazonLogger.Log.Warn( ex, "[amazon] Checking orders for seller {0} failed", this._credentials.SellerId );
                return false;
            }
        }
Ejemplo n.º 2
0
        public IEnumerable<ComposedOrder> GetOrders( DateTime dateFrom, DateTime dateTo )
        {
            var client = this._factory.CreateOrdersClient( "SkuVault", "1.0" );
            var request = new ListOrdersRequest
            {
                SellerId = this._credentials.SellerId,
                LastUpdatedAfter = dateFrom,
                //LastUpdatedBefore = dateTo,
                MarketplaceId = this._credentials.AmazonMarketplace.GetMarketplaceIdAsList(),
                MWSAuthToken = this._credentials.MwsAuthToken
            };

            AmazonLogger.Log.Trace( "[amazon] Loading orders for seller {0}", this._credentials.SellerId );

            var service = new OrdersService( client, request );
            foreach( var order in service.LoadOrders() )
            {
                yield return order;
            }

            AmazonLogger.Log.Trace( "[amazon] Orders for seller {0} loaded", this._credentials.SellerId );
        }