private void linkLabel_modifySender_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     using (Frm_SenderChanged frm = new Frm_SenderChanged())
     {
         frm.UpdateLanguage(HsLangTable);
         EMailNotifyConfig temp = _uc_EMailNotify_VM.NotifyConfig;
         frm.EmailAddr   = temp.EmailAddr;
         frm.Password    = temp.Password;
         frm.SMTPServer  = temp.SmtpServer;
         frm.Port        = temp.Port;
         frm.IsEnableSsl = temp.IsEnableSsl;
         if (frm.ShowDialog(this) != DialogResult.OK)
         {
             return;
         }
         else
         {
             temp             = _uc_EMailNotify_VM.NotifyConfig;
             temp.EmailAddr   = frm.EmailAddr;
             temp.Password    = frm.Password;
             temp.SmtpServer  = frm.SMTPServer;
             temp.Port        = frm.Port;
             temp.IsEnableSsl = frm.IsEnableSsl;
             eMailNotifyConfigBS.ResetCurrentItem();
         }
     }
 }
        private void linkLabel_PeriodicReport_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (checkBox_SystemRefresh.Checked)
            {
                using (Frm_PeriodicReport periodicReport = new Frm_PeriodicReport())
                {
                    periodicReport.UpdateLanguage(HsLangTable);

                    EMailNotifyConfig temp = _uc_EMailNotify_VM.NotifyConfig;
                    periodicReport.SendTimer     = temp.SendTimer;
                    periodicReport.SendModel     = temp.SendMailModel;
                    periodicReport.SendMailWeek  = temp.SendMailWeek;
                    periodicReport.StartPosition = FormStartPosition.CenterScreen;
                    if (periodicReport.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }
                    else
                    {
                        temp               = _uc_EMailNotify_VM.NotifyConfig;
                        temp.SendTimer     = periodicReport.SendTimer;
                        temp.SendMailModel = periodicReport.SendModel;
                        temp.SendMailWeek  = periodicReport.SendMailWeek;
                        eMailNotifyConfigBS.ResetCurrentItem();
                    }
                }
            }
        }
 public void Initialize()
 {
     if (MonitorAllConfig.Instance().NotifyConfig!=null)
     {
         _notifyConfig = (EMailNotifyConfig)MonitorAllConfig.Instance().NotifyConfig.Clone();
     }
 }
        private void crystalButton_useDefault_Click(object sender, EventArgs e)
        {
            EMailNotifyConfig temp = _uc_EMailNotify_VM.NotifyConfig;

            temp.EmailAddr  = EMailNotifyConfig.DEFAULT_EMAIL_ADDR;
            temp.Password   = EMailNotifyConfig.DEFAULT_EMAIL_PW;
            temp.SmtpServer = EMailNotifyConfig.DEFAULT_SMTP_SERVER;
            temp.Port       = EMailNotifyConfig.DEFAULT_EMAIL_PORT;
            eMailNotifyConfigBS.ResetCurrentItem();
        }
        public EMailSendError(EMailNotifyConfig emailConfig, out bool bSucceed)
        {
            _emailConfig = (EMailNotifyConfig)emailConfig.Clone();
            _mailSender = new MailSender(emailConfig.SmtpServer,
                emailConfig.Port,
                emailConfig.EmailAddr,
                emailConfig.Password,
                out bSucceed);
            _mailSender.IsEnableSsl = emailConfig.IsEnableSsl;

            if (bSucceed)
            {
                _mailSender.EmailSendCompleteEvent += new SendCompletedEventHandler(OnMailComplete);
            }
        }
        private void frm_ReceiverChangedEvent(object sender, ReceiverChangedEventArgs e)
        {
            EMailNotifyConfig temp = _uc_EMailNotify_VM.NotifyConfig;

            if (e.DisplayType == DisplayType.Add)
            {
                temp.ReceiveInfoList.Add(new ReceiverInfo(e.Name, e.EmailAddr));
            }
            else
            {
                ReceiverInfo info = temp.ReceiveInfoList[_curSelectReceiverIndex];
                info.Name      = e.Name;
                info.EmailAddr = e.EmailAddr;
            }
            eMailNotifyConfigBS.ResetBindings(false);
        }
        private void crystalButton_modifyRecv_Click(object sender, EventArgs e)
        {
            if (dataGridView_receiver.SelectedRows.Count == 0)
            {
                ShowCustomMessageBox(CommonUI.GetCustomMessage(HsLangTable, "SelectEditReceiver", "请选择要编辑的收件人!"),
                                     "", MessageBoxButtons.OK, MessageBoxIconType.Error);
                return;
            }
            using (Frm_ReceiverChanged frm = new Frm_ReceiverChanged())
            {
                frm.UpdateLanguage(HsLangTable);
                _curSelectReceiverIndex   = dataGridView_receiver.SelectedRows[0].Index;
                frm.ReceiverChangedEvent += new ReceiverChangedEventHandler(frm_ReceiverChangedEvent);

                EMailNotifyConfig temp = _uc_EMailNotify_VM.NotifyConfig;
                ReceiverInfo      info = temp.ReceiveInfoList[_curSelectReceiverIndex];

                frm.DisplayMode = DisplayType.Modify;
                frm.NameChanged = info.Name;
                frm.EmailAddr   = info.EmailAddr;
                frm.ShowDialog();
            }
        }
        /// <summary>
        /// 保存邮件配置参数
        /// </summary>
        /// <returns></returns>
        public bool SaveEMailNotifyConfig(EMailNotifyConfig notifyConfig)
        {
            //_fLogService.Info("开始保存用户的配置...");
            bool res = MonitorDataAccessor.Instance().UpdateEmailCfg(
              CommandTextParser.GetJsonSerialization<EMailNotifyConfig>(notifyConfig),
              SystemHelper.GetUtcTicksByDateTime(DateTime.Now));
            //_fLogService.Info("完成保存用户的配置...");

            if (res && _sendMonitorErrMsg != null)
            {
                _sendMonitorErrMsg.IsNotifyConfigChanged = true;
            }
            if (res)
            {
                NotifyConfig = notifyConfig;
            }
            return res;
        }
 private void ReadEmailConfig()
 {
     ConfigInfo cfg = MonitorDataAccessor.Instance().GetEmailCfg();
     if (NotifyConfig == null)
     {
         NotifyConfig = new EMailNotifyConfig();
     }
     if (string.IsNullOrEmpty(cfg.Content))
     {
         NotifyConfig = new EMailNotifyConfig();
     }
     else
     {
         NotifyConfig = CommandTextParser.GetDeJsonSerialization<EMailNotifyConfig>(cfg.Content);
     }
 }