public void CallUpdateFulfillmentData(IMarketOrderUpdaterApi api, IList <string> orderNumbers)
 {
     using (var db = _dbFactory.GetRWDb())
     {
         var service = new BaseOrderUpdater(api, _log, _time);
         service.UpdateOrders(db, orderNumbers);
     }
 }
Exemple #2
0
        public void UpdateOrders(GrouponApi api)
        {
            var updater = new BaseOrderUpdater(api, _log, _time);

            using (var db = _dbFactory.GetRWDb())
            {
                updater.UpdateOrders(db);
            }
        }
Exemple #3
0
        public void SendOrdersUpdate(SupplieroasisApi api)
        {
            var updater = new BaseOrderUpdater(api, _log, _time);

            using (var db = _dbFactory.GetRWDb())
            {
                updater.UpdateOrders(db);
            }
        }
        protected override void RunCallback()
        {
            var dbFactory = new DbFactory();

            var log  = GetLogger();
            var time = new TimeService(dbFactory);


            using (var db = dbFactory.GetRWDb())
            {
                var orderIdsToMove = (from o in db.Orders.GetAll()
                                      join sh in db.OrderShippingInfos.GetAll() on o.Id equals sh.OrderId
                                      where o.BatchId.HasValue &&
                                      o.OrderStatus == OrderStatusEnumEx.Unshipped &&
                                      sh.IsActive
                                      //&& !String.IsNullOrEmpty(sh.LabelPurchaseMessage)
                                      && sh.LabelPurchaseResult == (int)LabelPurchaseResultType.Error
                                      select o.Id)
                                     .Distinct()
                                     .ToList();
                var dbOrdersToMove = db.Orders.GetAll().Where(o => orderIdsToMove.Contains(o.Id)).ToList();
                log.Info("Orders to move: " + dbOrdersToMove.Count);
                log.Info("OrderIds to move: " + String.Join(", ", dbOrdersToMove.Select(o => o.AmazonIdentifier).ToList()));
                dbOrdersToMove.ForEach(o => o.BatchId = null);
                db.Commit();
            }


            var marketplaceManager = new MarketplaceKeeper(dbFactory, false);

            marketplaceManager.Init();

            var marketplaces = marketplaceManager.GetAll();
            var factory      = new MarketFactory(marketplaceManager.GetAll(), time, log, dbFactory, null);

            using (var db = dbFactory.GetRWDb())
            {
                foreach (var market in marketplaces)
                {
                    if (market.Market == (int)MarketType.Walmart ||
                        market.Market == (int)MarketType.WalmartCA)
                    {
                        var api = factory.GetApi(CompanyId, (MarketType)market.Market, market.MarketplaceId);
                        if (api is IMarketOrderUpdaterApi)
                        {
                            log.Info("Reset IsFulfilledStatus, for market: " + api.Market + "-" + api.MarketplaceId);

                            var service = new BaseOrderUpdater(api as IMarketOrderUpdaterApi, log, time);
                            service.ResetIsFulfilledStatus(db);
                        }
                    }
                }
            }
        }
Exemple #5
0
 public void CallUpdateFulfillmentData(IMarketOrderUpdaterApi api, string orderString)
 {
     using (var db = _dbFactory.GetRWDb())
     {
         var service = new BaseOrderUpdater(api, _log, _time);
         service.UpdateOrders(db, !String.IsNullOrEmpty(orderString) ? new List <string>()
         {
             orderString
         } : null);
     }
 }
        protected override void RunCallback()
        {
            _api.Connect();

            var dbFactory = new DbFactory();
            var time      = new TimeService(dbFactory);
            var settings  = new SettingsService(dbFactory);

            using (var db = dbFactory.GetRWDb())
            {
                var lastSyncDate = settings.GetOrdersFulfillmentDate(_api.Market, _api.MarketplaceId);

                LogWrite("Last sync date=" + lastSyncDate);

                if (!lastSyncDate.HasValue ||
                    (time.GetUtcTime() - lastSyncDate) > _betweenProcessingInverval)
                {
                    var updater = new BaseOrderUpdater(_api, GetLogger(), time);
                    updater.UpdateOrders(db);
                    settings.SetOrdersFulfillmentDate(time.GetUtcTime(), _api.Market, _api.MarketplaceId);
                }
            }
        }