public void TestProcessSampleReturnRequestEmail() { var smtpSettings = SettingsBuilder.GetSmtpSettingsFromAppSettings(); var emailService = new EmailService(_log, smtpSettings, _addressService); var actionService = new SystemActionService(_log, _time); var rule = new ReturnRequestEmailRule(_log, _time, emailService, actionService, _company, false, true); using (var db = _dbFactory.GetRWDb()) { var email = db.Emails.Get(4687); var matchingResult = new EmailReadingResult() { Email = new EmailDTO() { Subject = email.Subject, Message = email.Message, }, Status = EmailMatchingResultStatus.New, MatchedIdList = new string[] { "002-1602056-5981826" } }; rule.Process(db, matchingResult); } }
public void RecheckAllReturnEmails() { var smtpSettings = SettingsBuilder.GetSmtpSettingsFromAppSettings(); var emailService = new EmailService(_log, smtpSettings, _addressService); var actionService = new SystemActionService(_log, _time); var rule = new ReturnRequestEmailRule(_log, _time, emailService, actionService, _company, enableSendEmail: false, existanceCheck: true); using (var db = _dbFactory.GetRWDb()) { var fromDate = DateTime.Now.AddDays(-35); var emails = db.Emails.GetAll() .Where(e => e.CreateDate > fromDate) .ToList(); var emailToOrderList = db.EmailToOrders.GetAll().ToList(); foreach (var email in emails) { var emailToOrder = emailToOrderList.FirstOrDefault(e => e.EmailId == email.Id); if (emailToOrder == null) { continue; } var matchingResult = new EmailReadingResult() { Email = new EmailDTO() { Subject = email.Subject, Message = email.Message, }, Status = EmailMatchingResultStatus.New, MatchedIdList = new string[] { emailToOrder.OrderId } }; rule.Process(db, matchingResult); } } }