コード例 #1
0
        private void btnSendTestMessage_Click(object sender, EventArgs e)
        {
            using (var Dbconnection = new MCDEntities())
            {
                SMTPSetting EmailSettings = (from a in Dbconnection.SMTPSettings
                                             select a).FirstOrDefault <SMTPSetting>();
                CustomMailMessage NewMessage = new CustomMailMessage(
                    EmailSettings.FromAddress,
                    this.txtTestingToAddress.Text,
                    this.txtTestSubject.Text,
                    this.txtTestMessage.Text);

                NewMessage.DisplayName           = EmailSettings.DisplayName;
                NewMessage.PortNumber            = EmailSettings.PortNumber;
                NewMessage.Host                  = EmailSettings.SMTPHost;
                NewMessage.UserName              = EmailSettings.UserName;
                NewMessage.Password              = EmailSettings.Password;
                NewMessage.RequireAuthentication = EmailSettings.RequireAuthentication;
                NewMessage.RequireSSL            = EmailSettings.RequiresSSL;
                foreach (string path in lstAttachments.Items)
                {
                    NewMessage.AddAttachment(new EmailAttachmentMetaData(path));
                }
                NewMessage.sendMessage();
            };
        }
コード例 #2
0
        public SMTPSetting GetSMTPSetting()
        {
            try
            {
                var settings           = _siteSettingRepository.GetSettings();
                var serverPort         = settings.First(s => s.SettingName == "SMTPServerAndPort").SettingValue;
                var ssl                = settings.First(s => s.SettingName == "SMTPEnableSSL").SettingValue;
                var authenticationType = settings.First(s => s.SettingName == "SMTPAuthentication").SettingValue;
                var userName           = settings.First(s => s.SettingName == "SMTPUsername").SettingValue;
                var password           = settings.First(s => s.SettingName == "SMTPPassword").SettingValue;

                var result = new SMTPSetting()
                {
                    Server             = !string.IsNullOrEmpty(serverPort.Split(':')[0]) ? serverPort.Split(':')[0] : "",
                    Port               = !string.IsNullOrEmpty(serverPort.Split(':')[1]) ? int.Parse(serverPort.Split(':')[1]) : 25,
                    EnableSSL          = !string.IsNullOrEmpty(ssl) ? bool.Parse(ssl) : false,
                    AuthenticationType = authenticationType,
                    Username           = userName,
                    Password           = password
                };
                return(result);
            }
            catch (Exception ex)
            {
                _logger.LogError("Error occured while calling Get", ex);
            }
            return(null);
        }
コード例 #3
0
        public static IServiceCollection AddDefaults(this IServiceCollection services, IConfiguration configuration)
        {
            var protocolSetting = new ProtocolSetting();
            var protocolSection = configuration.GetSection("ProtocolSetting");

            if (protocolSection != null)
            {
                protocolSection.Bind(protocolSetting);
            }
            services.Configure <ProtocolSetting>(protocolSection);

            var smtpSetting = new SMTPSetting();
            var smtpSection = configuration.GetSection("SmtpSetting");

            if (smtpSection != null)
            {
                smtpSection.Bind(smtpSetting);
            }
            services.Configure <SMTPSetting>(smtpSection);

            var ldapSetting = new LDAPSetting();
            var ldapSection = configuration.GetSection("LdapSetting");

            if (ldapSection != null)
            {
                ldapSection.Bind(ldapSetting);
            }
            services.Configure <SMTPSetting>(ldapSection);

            services.AddControllers(options =>
            {
                options.CacheProfiles.Add("Never", new CacheProfile()
                {
                    Location = ResponseCacheLocation.None,
                    NoStore  = true,
                    Duration = 0
                });
                options.SuppressOutputFormatterBuffering = true;
                options.OutputFormatters.Insert(0, new DBItemOutputFormatter());
            }).AddJsonOptions(options =>
            {
                options.JsonSerializerOptions.InitDefaults();
            });


            foreach (var validator in services.Where(s => s.ServiceType == typeof(IObjectModelValidator)).ToList())
            {
                services.Remove(validator);
            }
            services.AddSingleton <IObjectModelValidator>(new DBItemValidator());
            return(services);
        }
コード例 #4
0
        public StandardEmailMessage()
        {
            using (var Dbconnection = new MCDEntities())
            {
                SMTPSetting EmailSettings = (from a in Dbconnection.SMTPSettings
                                             select a).FirstOrDefault <SMTPSetting>();

                this.DisplayName           = EmailSettings.DisplayName;
                this.PortNumber            = EmailSettings.PortNumber;
                this.Host                  = EmailSettings.SMTPHost;
                this.UserName              = EmailSettings.UserName;
                this.Password              = EmailSettings.Password;
                this.RequireAuthentication = EmailSettings.RequireAuthentication;
                this.RequireSSL            = EmailSettings.RequiresSSL;
            };
        }
コード例 #5
0
ファイル: Form1.cs プロジェクト: Lirababe/Impendulo
        private void btnEmailFile_Click(object sender, EventArgs e)
        {
            using (var Dbconnection = new MCDEntities())
            {
                //////// SMTPSetting EmailSettings = (from a in Dbconnection.SMTPSettings
                ////////                              select a).FirstOrDefault<SMTPSetting>();
                //////// CustomMailMessage NewMessage = new CustomMailMessage(
                ////////    "*****@*****.**",
                ////////     "*****@*****.**",
                ////////     "Attachment Form Database",
                ////////     "This Is A Test Message With Attachment Form Database");

                //////// NewMessage.DisplayName = EmailSettings.DisplayName;
                //////// NewMessage.PortNumber = EmailSettings.PortNumber;
                //////// NewMessage.Host = EmailSettings.SMTPHost;
                //////// NewMessage.UserName = EmailSettings.UserName;
                //////// NewMessage.Password = EmailSettings.Password;
                //////// NewMessage.RequireAuthentication = EmailSettings.RequireAuthentication;
                //////// NewMessage.RequireSSL = EmailSettings.RequiresSSL;

                ////////// NewMessage.AddAttachment(new EmailAttachmentMetaData(1032));

                //////// NewMessage.sendMessage();

                SMTPSetting EmailSettings = (from a in Dbconnection.SMTPSettings
                                             select a).FirstOrDefault <SMTPSetting>();
                CustomMailMessage NewMessage = new CustomMailMessage(
                    EmailSettings.FromAddress,
                    "*****@*****.**",
                    "Test Message",
                    "Content");

                NewMessage.DisplayName           = EmailSettings.DisplayName;
                NewMessage.PortNumber            = EmailSettings.PortNumber;
                NewMessage.Host                  = EmailSettings.SMTPHost;
                NewMessage.UserName              = EmailSettings.UserName;
                NewMessage.Password              = EmailSettings.Password;
                NewMessage.RequireAuthentication = EmailSettings.RequireAuthentication;
                NewMessage.RequireSSL            = EmailSettings.RequiresSSL;

                //add an attachment that is linked to the data base
                NewMessage.AddAttachment(new EmailAttachmentMetaData(((Data.Models.File)fileBindingSource.Current).FileID));


                NewMessage.sendMessage();
            };
        }
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SMTPNotificationProvider"/> class.
 /// </summary>
 /// <param name="emailAccountManager"> IEmailAccountManager.</param>
 /// <param name="logger"> ILogger.</param>
 /// <param name="configuration"> IConfiguration.</param>
 /// <param name="emailManager"> IEmailManager.</param>
 public SMTPNotificationProvider(
     IEmailAccountManager emailAccountManager,
     ILogger logger,
     IConfiguration configuration,
     IEmailManager emailManager)
 {
     this.emailAccountManager = emailAccountManager;
     this.logger              = logger;
     this.configuration       = configuration;
     this.smtpSetting         = this.configuration?.GetSection(ConfigConstants.SMTPSettingConfigSectionKey).Get <SMTPSetting>();
     this.applicationAccounts = JsonConvert.DeserializeObject <List <ApplicationAccounts> >(this.configuration?[ConfigConstants.ApplicationAccountsConfigSectionKey]);
     _ = int.TryParse(this.configuration[$"{ConfigConstants.RetrySettingConfigSectionKey}:{ConfigConstants.RetrySettingMaxRetryCountConfigKey}"], out this.maxTryCount);
     if (this.configuration?[ConfigConstants.MailSettingsConfigKey] != null)
     {
         this.mailSettings = JsonConvert.DeserializeObject <List <MailSettings> >(this.configuration?[ConfigConstants.MailSettingsConfigKey]);
     }
     this.emailManager = emailManager;
 }
コード例 #7
0
        private void Form1_Load(object sender, EventArgs e)
        {
            SMTPSetting CurrentSettings = null;

            using (var Dbconnection = new MCDEntities())
            {
                CurrentSettings = (from a in Dbconnection.SMTPSettings
                                   select a).FirstOrDefault <SMTPSetting>();
            };
            if (CurrentSettings != null)
            {
                txtDisdplayName.Text              = CurrentSettings.DisplayName;
                txtFromAddress.Text               = CurrentSettings.FromAddress;
                txtPortNumber.Text                = CurrentSettings.PortNumber.ToString();
                txtSMTPHostAddress.Text           = CurrentSettings.SMTPHost;
                chkUseSSLConnection.Checked       = CurrentSettings.RequiresSSL;
                chkAuthenticationRequired.Checked = CurrentSettings.RequireAuthentication;
                setAuthenticationControls();
                txtUserName.Text = CurrentSettings.UserName;
                txtPassword.Text = CurrentSettings.Password;
            }
        }
コード例 #8
0
        private void btnSendMessage_Click(object sender, EventArgs e)
        {
            if (txtTestingToAddress.Text.Length > 0 && txtTestSubject.Text.Length > 0)
            {
                using (var Dbconnection = new MCDEntities())
                {
                    SMTPSetting EmailSettings = (from a in Dbconnection.SMTPSettings
                                                 select a).FirstOrDefault <SMTPSetting>();
                    CustomMailMessage NewMessage = new CustomMailMessage(
                        EmailSettings.FromAddress,
                        this.txtTestingToAddress.Text,
                        this.txtTestSubject.Text,
                        this.txtTestMessage.Text);

                    NewMessage.DisplayName           = EmailSettings.DisplayName;
                    NewMessage.PortNumber            = EmailSettings.PortNumber;
                    NewMessage.Host                  = EmailSettings.SMTPHost;
                    NewMessage.UserName              = EmailSettings.UserName;
                    NewMessage.Password              = EmailSettings.Password;
                    NewMessage.RequireAuthentication = EmailSettings.RequireAuthentication;
                    NewMessage.RequireSSL            = EmailSettings.RequiresSSL;

                    foreach (string path in AttachmentsUsingFilePaths)
                    {
                        NewMessage.AddAttachment(new EmailAttachmentMetaData(path));
                        // NewMessage.AddAttachment(new System.Net.Mail.Attachment(path));
                    }
                    NewMessage.sendMessage();
                    this.IsSent = true;
                    this.Close();
                };
            }
            else
            {
                MessageBox.Show("Ensure that To Address and Subject Is Completed!!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
コード例 #9
0
        private void saveEmailSettings()
        {
            using (var Dbconnection = new MCDEntities())
            {
                SMTPSetting EmailSettings;
                EmailSettings = (from a in Dbconnection.SMTPSettings
                                 select a).FirstOrDefault <SMTPSetting>();
                if (EmailSettings == null)
                {
                    SMTPSetting NewSettings = new SMTPSetting
                    {
                        FromAddress           = txtFromAddress.Text,
                        PortNumber            = Convert.ToInt32(txtPortNumber.Text),
                        RequiresSSL           = chkUseSSLConnection.Checked,
                        UserName              = txtUserName.Text,
                        Password              = txtPassword.Text,
                        RequireAuthentication = chkAuthenticationRequired.Checked,
                        SMTPHost              = txtSMTPHostAddress.Text
                    };
                    Dbconnection.SMTPSettings.Add(NewSettings);
                    Dbconnection.SaveChanges();
                }
                else
                {
                    EmailSettings.FromAddress           = txtFromAddress.Text;
                    EmailSettings.PortNumber            = Convert.ToInt32(txtPortNumber.Text);
                    EmailSettings.RequiresSSL           = chkUseSSLConnection.Checked;
                    EmailSettings.UserName              = txtUserName.Text;
                    EmailSettings.Password              = txtPassword.Text;
                    EmailSettings.RequireAuthentication = chkAuthenticationRequired.Checked;
                    EmailSettings.SMTPHost              = txtSMTPHostAddress.Text;

                    Dbconnection.SaveChanges();
                }
            };
        }
コード例 #10
0
ファイル: LogAPI(1).cs プロジェクト: Jackjet/ECOSingle
        private static int emailNewLog(string logKey, params string[] logPrar)
        {
            SMTPSetting sMTPSetting = new SMTPSetting();

            string[] array = sMTPSetting.Receiver.Split(new string[]
            {
                "\r\n",
                ";",
                ",",
                " "
            }, StringSplitOptions.RemoveEmptyEntries);
            List <string> list = new List <string>();

            string[] array2 = array;
            for (int i = 0; i < array2.Length; i++)
            {
                string item = array2[i];
                list.Add(item);
            }
            if (sMTPSetting.Status <= 0 || list.Count <= 0)
            {
                return(0);
            }
            string  str     = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            string  msg     = EventLogLang.getMsg("L" + logKey, logPrar);
            string  msg2    = EventLogLang.getMsg("SL" + logKey, logPrar);
            string  value   = str + "<br/>" + msg;
            MailMsg mailMsg = new MailMsg(sMTPSetting.ServerIP, sMTPSetting.Port, sMTPSetting.Sender, list, sMTPSetting.AuthenticationFlag, sMTPSetting.AccountName, sMTPSetting.AccountPwd);

            mailMsg.Subject  = "eco Sensors Event Notification - " + msg2;
            mailMsg.Body     = new StringBuilder().AppendLine(value).ToString();
            mailMsg.Receiver = sMTPSetting.Receiver;
            if (logKey.Equals("0230002") || logKey.Equals("0110100") || logKey.Equals("0110090") || logKey.Equals("0130001"))
            {
                LogAPI.sendMailThread(mailMsg);
                return(ErrorCode.SUCCESS);
            }
            lock (LogAPI._lockEmail)
            {
                if (LogAPI._mergedMail != null)
                {
                    if (mailMsg.Subject.Equals(LogAPI._mergedMail.Subject, StringComparison.InvariantCultureIgnoreCase) && mailMsg.Receiver.Equals(LogAPI._mergedMail.Receiver, StringComparison.InvariantCultureIgnoreCase))
                    {
                        LogAPI._mergedMail._ItemsInBody++;
                        LogAPI._mergedMail._mergedBody.Append("<br /><br />");
                        LogAPI._mergedMail._mergedBody.Append(mailMsg.Body);
                        LogAPI._lastEmailMerge = DateTime.Now;
                    }
                    else
                    {
                        LogAPI._emailQueue.Enqueue(LogAPI._mergedMail);
                        LogAPI._emailEvent.Set();
                        LogAPI._mergedMail = null;
                    }
                }
                if (LogAPI._mergedMail == null)
                {
                    LogAPI._mergedMail           = mailMsg;
                    LogAPI._mergedMail._SerialNo = LogAPI._NextEmailSerialNo++;
                    LogAPI._mergedMail._ItemsInBody++;
                    LogAPI._mergedMail._mergedBody.Append(mailMsg.Body);
                    LogAPI._lastEmailMerge = DateTime.Now;
                }
            }
            if (LogAPI._threadEmail == null)
            {
                LogAPI._waitEmailHandles[0]        = LogAPI._stopMailEvent;
                LogAPI._waitEmailHandles[1]        = LogAPI._emailEvent;
                LogAPI._threadEmail                = new Thread(new ParameterizedThreadStart(LogAPI.MailThreadScheduler));
                LogAPI._threadEmail.Name           = "Email Scheduler Thread";
                LogAPI._threadEmail.CurrentCulture = CultureInfo.InvariantCulture;
                LogAPI._threadEmail.IsBackground   = true;
                LogAPI._threadEmail.Start();
            }
            return(ErrorCode.SUCCESS);
        }
コード例 #11
0
        /// <summary>
        /// Sends the notification.
        /// </summary>
        /// <param name="environment">The environment.</param>
        /// <param name="alarm">The alarm.</param>
        /// <param name="globalProperties">The global properties.</param>
        /// <param name="notifications">The notifications.</param>
        /// <returns></returns>
        public bool SendNotification(BizTalkEnvironment environment, Common.Alarm alarm, string globalProperties, Dictionary <MonitorGroupTypeName, MonitorGroupData> notifications)
        {
            try
            {
                LoggingHelper.Info("DESCRIPTION " + alarm.Description);
                XDocument globalDocument = XDocument.Parse(globalProperties);
                XDocument alarmDocument  = XDocument.Parse(alarm.AlarmProperties);

                //Read configured properties
                XNamespace bsd              = XNamespace.Get("http://www.biztalk360.com/alarms/notification/basetypes");
                string     email            = string.Empty;
                string     emailTo          = string.Empty;
                string     ccEmail          = string.Empty;
                string     upAlert          = string.Empty;
                string     autoCorrectAlert = string.Empty;

                //Global Properties
                XDocument globalProps = XDocument.Load(new StringReader(globalProperties));

                foreach (XElement element in globalProps.Descendants(bsd + "TextArea"))
                {
                    XAttribute xAttribute = element.Attribute("Name");
                    if (element.Attribute("Name").Value == "Email-To")
                    {
                        emailTo = element.Attribute("Value").Value;
                    }
                    if (element.Attribute("Name").Value == "C-C")
                    {
                        ccEmail = element.Attribute("Value").Value;
                    }
                    if (element.Attribute("Name").Value == "Up-Alert")
                    {
                        upAlert = element.Attribute("Value").Value;
                    }
                    if (element.Attribute("Name").Value == "AutoCorrect-Alert")
                    {
                        autoCorrectAlert = element.Attribute("Value").Value;
                    }
                }
                bool useEmailTo = Convert.ToBoolean(globalDocument.XPathSelectElement(
                                                        "/*[local-name() = 'GlobalProperties']/*[local-name() = 'Section']/*[local-name() = 'CheckBox' and @Name = 'use-Email-To']")
                                                    ?.Attribute("Value")?.Value);

                BT360Helper helper = new BT360Helper(notifications, environment, alarm, MessageType.ConsolidatedMessage, MessageFormat.Text);

                EmailMessageBody emailMessageBody = (EmailMessageBody)helper.ConvertDictionaryToObject <EmailMessageBody>(alarm.AdditionalProperties, SMTPConfigurationInfo.EmailMessageBody);
                EmailAttachments emailAttachments = (EmailAttachments)helper.ConvertDictionaryToObject <EmailAttachments>(alarm.AdditionalProperties, SMTPConfigurationInfo.EmailAttachments);
                SMTPSetting      smtpSetting      = (SMTPSetting)helper.ConvertDictionaryToObject <SMTPSetting>(alarm.AdditionalProperties, SMTPConfigurationInfo.SMTPSetting);
                if (smtpSetting == null)
                {
                    throw new Exception("SMTP Setting is not present in the database. Please use the UI to update the correct setting.");
                }

                //When installed first time, these values will be blank
                if (smtpSetting.serverName == "" || smtpSetting.adminEmailAddress == "")
                {
                    //SK: 4th Feb 2012, replaced returning null with exception, since we can't proceed further.
                    throw new Exception("SMTP Setting is not configured (admin email or server name is blank). Please use the UI to update the correct setting.");
                    //return null;
                }
                switch (emailMessageBody.notificationType)
                {
                case NotificationType.UpAlert:
                    if (upAlert != "" && useEmailTo)
                    {
                        email = upAlert;
                    }
                    else
                    {
                        email = emailTo;
                    }
                    break;

                case NotificationType.AutoCorrectAlert:
                    if (autoCorrectAlert != "" && useEmailTo)
                    {
                        email = autoCorrectAlert;
                    }
                    else
                    {
                        email = emailTo;
                    }
                    break;

                default:
                    email = emailTo;
                    break;
                }

                string strFrom    = emailMessageBody.fromEmailAddress;
                string strName    = emailMessageBody.fromDisplayName;
                string strTo      = email;
                string strCC      = ccEmail;
                string strSubject = emailMessageBody.subject;
                string strBody    = emailMessageBody.xmlData;
                LoggingHelper.Info("SUBJECT " + strSubject);
                try
                {
                    SmtpClient smtp = new SmtpClient();

                    smtp.DeliveryMethod        = SmtpDeliveryMethod.Network;
                    smtp.Host                  = smtpSetting.serverName;
                    smtp.Port                  = Convert.ToInt32(smtpSetting.port);
                    smtp.EnableSsl             = (smtpSetting.sslMode == SMTPSSLMode.DedicatedSSLPort) ? true : false;
                    smtp.UseDefaultCredentials = (smtpSetting.authentication == SMTPAuthentication.IntegratedWindowsAuthOverNtlm) ? true : false;
                    smtp.Credentials           = (smtpSetting.authentication == SMTPAuthentication.Anonymous) ? null : new NetworkCredential(smtpSetting.userName, smtpSetting.password);

                    ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
                    string      htmlData    = Helper.TransformXMLToHTML(emailMessageBody.xslt, emailMessageBody.xmlData);
                    MailMessage mailMessage = new MailMessage();
                    mailMessage.From       = new MailAddress(strFrom, strName);
                    mailMessage.Subject    = strSubject;
                    mailMessage.Body       = htmlData;
                    mailMessage.IsBodyHtml = true;
                    //Adding multiple To Addresses
                    foreach (string sTo in strTo.Split(";".ToCharArray()))
                    {
                        mailMessage.To.Add(sTo);
                    }

                    //Adding multiple CC Addresses
                    if (strCC != string.Empty)
                    {
                        foreach (string sCC in strCC.Split(";".ToCharArray()))
                        {
                            mailMessage.CC.Add(sCC);
                        }
                    }
                    int    attachementCount = 0;
                    double totalSizeInMB    = 0;
                    var    attachmentsOrderedByImportance = emailAttachments.OrderByDescending(issue => issue.importance);

                    foreach (EmailAttachment attachment in attachmentsOrderedByImportance)
                    {
                        string fileName = Path.Combine(emailMessageBody.attachmentFolder, attachment.name);
                        if (File.Exists(fileName))
                        {
                            //Apply maximum size restriction rule
                            FileInfo f        = new FileInfo(fileName);
                            long     filesize = f.Length;
                            double   sizeInMB = (filesize / 1024f) / 1024f;

                            if ((totalSizeInMB + sizeInMB) >= emailMessageBody.maxAttachmentsSizeInMb)
                            {
                                LoggingHelper.Warn(string.Format("The size of the attachment is above the configured limit. Alarm {0}. FileName :{1}. Configured Value :{2}. Current Limit: {3}", alarm.Name, attachment.name, emailMessageBody.maxAttachmentsSizeInMb, totalSizeInMB));
                            }
                            else if (attachementCount >= emailMessageBody.maxAttachments)  //Apply Maximum attachments/email rule
                            {
                                LoggingHelper.Warn(string.Format("Maximum attachments count reached for alarm {0}. Configured Value :{1}. Current Limit: {2}", alarm.Name, emailMessageBody.maxAttachments, attachementCount));
                            }
                            else
                            {
                                mailMessage.Attachments.Add(new Attachment(fileName));
                                totalSizeInMB += sizeInMB; // Attachment Size
                                attachementCount++;        // Attachement Count
                            }
                        }
                        else
                        {
                            LoggingHelper.Warn(string.Format(" Attachment file {0} cannot be found.", attachment));
                        }
                    }


                    MailPriority mailPriority = MailPriority.Normal;
                    switch (alarm.EmailPriority)
                    {
                    case "1":
                        mailPriority = MailPriority.High;
                        break;

                    case "0":
                        mailPriority = MailPriority.Low;
                        break;
                    }
                    mailMessage.Priority = mailPriority;
                    smtp.Send(mailMessage);
                    LoggingHelper.Info("SMTP Notification channel posted the message successfully");
                    return(true);
                }
                catch (Exception ex)
                {
                    LoggingHelper.Error("SMTP Notification channel failed. Error " + ex.Message);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                LoggingHelper.Error("SMTP Notification channel failed. Error " + ex.Message);
                return(false);
            }
        }
コード例 #12
0
        public void pageInit()
        {
            this.m_pSMTPpara     = new SMTPSetting();
            this.txtserver.Text  = this.m_pSMTPpara.ServerIP;
            this.txtport.Text    = System.Convert.ToString(this.m_pSMTPpara.Port);
            this.txtfrom.Text    = this.m_pSMTPpara.Sender;
            this.txtto.Text      = this.m_pSMTPpara.Receiver;
            this.txtaccount.Text = this.m_pSMTPpara.AccountName;
            this.txtpwd.Text     = this.m_pSMTPpara.AccountPwd;
            string eVENT = this.m_pSMTPpara.EVENT;

            if (eVENT == "")
            {
                this.cboevent.SelectedIndex = 0;
            }
            else
            {
                if (eVENT == "All")
                {
                    this.cboevent.SelectedIndex = 0;
                }
                else
                {
                    if (eVENT == "Event")
                    {
                        this.cboevent.SelectedIndex = 1;
                    }
                    else
                    {
                        if (eVENT == "Severity")
                        {
                            this.cboevent.SelectedIndex = 2;
                        }
                    }
                }
            }
            if (this.m_pSMTPpara.Status != 1)
            {
                this.chkenablesmtp.Checked = false;
                this.txtserver.Enabled     = false;
                this.txtport.Enabled       = false;
                this.txtfrom.Enabled       = false;
                this.txtto.Enabled         = false;
                this.cboevent.Enabled      = false;
                this.chkauth.Enabled       = false;
                this.chkauth.Checked       = false;
                this.txtaccount.Enabled    = false;
                this.txtpwd.Enabled        = false;
                return;
            }
            this.chkenablesmtp.Checked = true;
            this.txtserver.Enabled     = true;
            this.txtport.Enabled       = true;
            this.txtfrom.Enabled       = true;
            this.txtto.Enabled         = true;
            this.cboevent.Enabled      = true;
            this.chkauth.Enabled       = true;
            if (this.m_pSMTPpara.AuthenticationFlag == 1)
            {
                this.chkauth.Checked    = true;
                this.txtaccount.Enabled = true;
                this.txtpwd.Enabled     = true;
                return;
            }
            this.chkauth.Checked    = false;
            this.txtaccount.Enabled = false;
            this.txtpwd.Enabled     = false;
        }
コード例 #13
0
 public SMTPSettingItemViewModel(SMTPSetting model)
 {
     _item = model;
 }
コード例 #14
0
 public SMTPSettingItemViewModel()
 {
     _item = new SMTPSetting();
 }
コード例 #15
0
ファイル: SMTPSettingService.cs プロジェクト: xrdevaf/polar
 private static SMTPSettingItemViewModel Convert(SMTPSetting r)
 {
     return(new SMTPSettingItemViewModel(r));
 }