Ejemplo n.º 1
0
        /// <summary>
        /// Handles the Click event of the btnSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try {
            if (mailSettings == null) {
              mailSettings = new MailSettings();
            }
            mailSettings.From = txtFrom.Text.Trim();
            mailSettings.Host = txtHost.Text.Trim();
            mailSettings.RequireAuthentication = chkRequireAuthentication.Checked;
            mailSettings.UserName = txtUserName.Text.Trim();
            mailSettings.Password = txtPassword.Text.Trim();
            int port = 25;
            bool isParsed = int.TryParse(txtPort.Text.Trim(), out port);
            mailSettings.Port = (isParsed) ? port : 25;
            mailSettings.RequireSsl = chkRequireSsl.Checked;

            DatabaseConfigurationProvider databaseConfigurationProvider = new DatabaseConfigurationProvider();
            int id = databaseConfigurationProvider.SaveConfiguration(MailSettings.SECTION_NAME, mailSettings, WebUtility.GetUserName());
            MessagingCache.RemoveMailSettings();
            if (id > 0) {
              Master.MessageCenter.DisplaySuccessMessage(LocalizationUtility.GetText("lblMailSettingsSaved"));
            }
            else {
              Master.MessageCenter.DisplayFailureMessage(LocalizationUtility.GetText("lblMailSettingsNotSaved"));
            }
              }
              catch (Exception ex) {
            Logger.Error(typeof(mailconfiguration).Name + ".btnSave_Click", ex);
            Master.MessageCenter.DisplayCriticalMessage(ex.Message);
              }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Loads this instance.
        /// </summary>
        /// <returns></returns>
        public static MailSettings Load()
        {
            DatabaseConfigurationProvider databaseConfigurationprovider = new DatabaseConfigurationProvider();
            MailSettings mailSettings = databaseConfigurationprovider.FetchConfigurationByName(MailSettings.SECTION_NAME) as MailSettings;

            return(mailSettings);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Handles the Load event of the Page control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
 protected void Page_Load(object sender, EventArgs e)
 {
     try {
     SetMailSettingsProperties();
     mailSettings = MailSettings.Load();
     if (!Page.IsPostBack) {
       if (mailSettings != null) {
     txtFrom.Text = mailSettings.From;
     txtHost.Text = mailSettings.Host;
     chkRequireAuthentication.Checked = mailSettings.RequireAuthentication;
     txtUserName.Text = mailSettings.UserName;
     txtPassword.Text = mailSettings.Password;
     chkRequireSsl.Checked = mailSettings.RequireSsl;
     txtPort.Text = mailSettings.Port.ToString();
       }
     }
       }
       catch (Exception ex) {
     Logger.Error(typeof(mailconfiguration).Name + ".Page_Load", ex);
     Master.MessageCenter.DisplayCriticalMessage(ex.Message);
       }
 }