Beispiel #1
0
        private System.DateTime TestConnectAndReturnDateTime(EMailModal modal)
        {
            POP3 pop3 = PopMailFactory.GetPopMail(modal);

            System.DateTime time = System.DateTime.MinValue;
            if (pop3 != null)
            {
                string str = pop3.TestConnect();
                this.strMsg = str;
                if (string.IsNullOrEmpty(str))
                {
                    pop3.GetAll();
                }
                else
                {
                    //base.Dispatcher.BeginInvoke(delegate
                    //{
                    //    this.tbkMsg.Text = str;
                    //    this.btnOpen.IsEnabled = false;
                    //}, new object[0]);
                }
            }
            else
            {
                //base.Dispatcher.BeginInvoke(delegate
                //{
                //    this.tbkMsg.Text = "邮件服务地址出错";
                //    this.btnOpen.IsEnabled = false;
                //}, new object[0]);
            }
            return(time);
        }
Beispiel #2
0
 public void GetNewMailCount()
 {
     if (this.Modal != null && !string.IsNullOrEmpty(this.Modal.Server) && !string.IsNullOrEmpty(this.Modal.MailID) && this.Modal.MailID.Contains("@"))
     {
         try
         {
             POP3 pop3 = PopMailFactory.GetPopMail(this.Modal);
             while (true)
             {
                 if (!ServiceUtil.Instance.SessionService.IsLogin)
                 {
                     System.Threading.Thread.CurrentThread.Abort();
                 }
                 if (this.Modal != null && pop3 != null && !string.IsNullOrEmpty(this.Modal.Server) && !string.IsNullOrEmpty(this.Modal.MailID) && Setting.emailList.Contains(this.Modal))
                 {
                     try
                     {
                         int count = pop3.GetMailCount(this.Modal.LastUpdateTime);
                         if (count >= 0)
                         {
                             this.Modal.NewCount = count;
                             this.iNWindow.UpdateMailCount();
                         }
                     }
                     catch (System.Exception ex)
                     {
                         ServiceUtil.Instance.Logger.Error(ex.ToString());
                     }
                     System.Threading.Thread.Sleep(this.Modal.Span * 1000 * 60);
                 }
                 else
                 {
                     System.Threading.Thread.CurrentThread.Abort();
                 }
             }
         }
         catch (System.Threading.ThreadAbortException)
         {
         }
         catch (System.Exception ex)
         {
             ServiceUtil.Instance.Logger.Error(ex.ToString());
         }
     }
 }