예제 #1
0
 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;
 }
예제 #2
0
파일: App.cs 프로젝트: niyouzhu/EmailSender
        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();
            };
        }
예제 #3
0
 public MailClient(MailSettings settings)
 {
     Settings = settings;
 }
예제 #4
0
파일: App.cs 프로젝트: niyouzhu/EmailSender
 public App() : this(MailSettings.GetSettings())
 {
 }