public MailSender(BacklogMailQueue backlogQueue, InProcessMailQueue inProcessQueue, SuccessMailQueue successQueue, FailureMailQueue failureQueue, RealTimeMailQueue realTimeQueue, MailSettings settings) { BacklogQueue = backlogQueue; InProcessQueue = inProcessQueue; SuccessQueue = successQueue; FailureQueue = failureQueue; RealTimeQueue = realTimeQueue; MailSettings = settings; }
public App(MailSettings settings) { var dataAccessor = new DataAccessor(); Sender = new MailSender(new BacklogMailQueue(dataAccessor), new InProcessMailQueue(dataAccessor), new SuccessMailQueue(dataAccessor), new FailureMailQueue(dataAccessor), new RealTimeMailQueue(dataAccessor), settings); bool scanning = false; //object scanningLock = new object(); ScanningTimer.Elapsed += (o, e) => { if (!scanning) { scanning = true; var task = Sender.Scan(); task.ContinueWith(t => { scanning = false; if (t.IsFaulted) { var eventArgs = new ExceptionEventArgs(t.Exception); OnException?.Invoke(eventArgs); } }); } }; bool sending = false; SendingTimer.Elapsed += (o, e) => { if (!sending) { sending = true; var task = Sender.Send(); task.ContinueWith(t => { sending = false; if (t.IsFaulted) { var eventArgs = new ExceptionEventArgs(t.Exception); OnException?.Invoke(eventArgs); } }); } }; ScanningTimer.Disposed += (o, e) => { Sender.Stop(); }; SendingTimer.Disposed += (o, e) => { Sender.Stop(); }; }
public MailClient(MailSettings settings) { Settings = settings; }
public App() : this(MailSettings.GetSettings()) { }