public void AutoBuyOverdueOrders() { var orderHistoryService = new OrderHistoryService(_log, _time, _dbFactory); var batchManager = new BatchManager(_log, _time, orderHistoryService, _weightService); var actionService = new SystemActionService(_log, _time); var serviceFactory = new ServiceFactory(); var labelBatchService = new LabelBatchService(_dbFactory, actionService, _log, _time, _weightService, serviceFactory, _emailService, batchManager, _pdfMaker, AddressService.Default, orderHistoryService, AppSettings.DefaultCustomType, AppSettings.LabelDirectory, AppSettings.ReserveDirectory, AppSettings.TemplateDirectory, new LabelBatchService.Config(), AppSettings.IsSampleLabels); var autoPurchaseService = new LabelAutoBuyService(_dbFactory, _log, _time, batchManager, labelBatchService, actionService, _emailService, _weightService, _company.Id); autoPurchaseService.PurchaseForOverdue(); }
protected override void RunCallback() { CompanyDTO company = null; var dbFactory = new DbFactory(); var time = new TimeService(dbFactory); var log = GetLogger(); var now = time.GetAppNowTime(); if (!time.IsBusinessDay(now)) { return; } using (var db = dbFactory.GetRDb()) { company = db.Companies.GetByIdWithSettingsAsDto(CompanyId); } var addressService = AddressService.Default; var serviceFactory = new ServiceFactory(); var pdfMaker = new PdfMakerByIText(GetLogger()); var actionService = new SystemActionService(log, time); var emailSmtpSettings = SettingsBuilder.GetSmtpSettingsFromCompany(company, AppSettings.IsDebug, AppSettings.IsSampleLabels); var emailService = new EmailService(GetLogger(), emailSmtpSettings, addressService); var weightService = new WeightService(); var orderHistoryService = new OrderHistoryService(log, time, dbFactory); var batchManager = new BatchManager(log, time, orderHistoryService, weightService); var labelBatchService = new LabelBatchService(dbFactory, actionService, log, time, weightService, serviceFactory, emailService, batchManager, pdfMaker, AddressService.Default, orderHistoryService, AppSettings.DefaultCustomType, AppSettings.LabelDirectory, AppSettings.ReserveDirectory, AppSettings.TemplateDirectory, new LabelBatchService.Config() { PrintErrorsToEmails = new[] { company.SellerEmail, company.SellerWarehouseEmailAddress }, PrintErrorsCCEmails = new[] { EmailHelper.RaananEmail, EmailHelper.SupportDgtexEmail }, }, AppSettings.IsSampleLabels); var autoPurchaseService = new LabelAutoBuyService(dbFactory, log, time, batchManager, labelBatchService, actionService, emailService, weightService, company.Id); autoPurchaseService.PurchaseForOverdue(); }