public void CallRedistributeQuantity(IList <string> styleIdList) { var settings = new SettingsService(_dbFactory); var quantityManager = new QuantityManager(_log, _time); var qtyDistributionService = new QuantityDistributionService(_dbFactory, quantityManager, _log, _time, QuantityDistributionHelper.GetDistributionMarkets(), DistributeMode.None); using (var db = _dbFactory.GetRWDb()) { db.DisableValidation(); if (!styleIdList.Any()) { qtyDistributionService.Redistribute(db); } else { var style = db.Styles.GetAllActiveAsDto().Where(st => styleIdList.Contains(st.StyleID)).ToList(); var styleIds = style.Select(st => st.Id).ToList(); qtyDistributionService.RedistributeForStyle(db, styleIds); } } }
public virtual JsonResult Redistribute(long styleId) { LogI("Redistribute, styleId=" + styleId); try { var quantityManager = new QuantityManager(LogService, Time); var service = new QuantityDistributionService(DbFactory, quantityManager, LogService, Time, QuantityDistributionHelper.GetDistributionMarkets(), DistributeMode.None); var listings = service.RedistributeForStyle(Db, styleId); return(new JsonResult() { Data = ValueResult <IList <ListingQuantityDTO> > .Success("Quantity was redistributed", listings), JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } catch (Exception ex) { LogE("Redistribute, styleId=" + styleId, ex); return(new JsonResult() { Data = MessageResult.Error(ex.Message), JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } }
protected override void RunCallback() { var dbFactory = new DbFactory(); var time = new TimeService(dbFactory); var log = GetLogger(); CompanyDTO company; using (var db = dbFactory.GetRDb()) { company = db.Companies.GetByIdWithSettingsAsDto(CompanyId); } var weightService = new WeightService(); var messageService = new SystemMessageService(log, time, dbFactory); var serviceFactory = new ServiceFactory(); var quantityManager = new QuantityManager(log, time); var rateProviders = serviceFactory.GetShipmentProviders(log, time, dbFactory, weightService, company.ShipmentProviderInfoList, null, null, null, null); var actionService = new SystemActionService(log, time); var commentService = new OrderCommentService(dbFactory, log, time, actionService); commentService.ProcessSystemAction(); var rateService = new RateService(dbFactory, log, time, weightService, messageService, company, actionService, rateProviders); rateService.ProcessSystemAction(CancellationToken); var quantityDistribution = new QuantityDistributionService(dbFactory, quantityManager, log, time, QuantityDistributionHelper.GetDistributionMarkets(), DistributeMode.None); quantityDistribution.ProcessSystemAction(actionService); }
protected override void RunCallback() { var dbFactory = new DbFactory(); var time = new TimeService(dbFactory); var settings = new SettingsService(dbFactory); var quantityManager = new QuantityManager(GetLogger(), time); using (var db = dbFactory.GetRWDb()) { var service = new QuantityDistributionService(dbFactory, quantityManager, GetLogger(), time, QuantityDistributionHelper.GetDistributionMarkets(), DistributeMode.None); service.Redistribute(db); settings.SetQuantityDistributeDate(time.GetAppNowTime()); } }