GetStringSetting() public static method

Gets the given setting as a string, or defaultValue if the setting is not set.
public static GetStringSetting ( Hashtable settings, string settingName, string defaultValue ) : string
settings System.Collections.Hashtable The settings collection.
settingName string Name of the setting.
defaultValue string The default value.
return string
        /// <summary>Sends the email.</summary>
        /// <param name="localResourceFile">The local resource file.</param>
        /// <param name="siteUrl">The site URL.</param>
        /// <param name="portalName">Name of the portal.</param>
        /// <param name="senderEmail">The sender email.</param>
        /// <param name="friendsEmail">The friends email.</param>
        /// <param name="senderName">Name of the sender.</param>
        /// <param name="friendName">Name of the friend.</param>
        /// <param name="message">The message.</param>
        /// <param name="portalEmail">The portal administrator's email.</param>
        /// <param name="moduleId">The ID of the module from which this email is being sent.</param>
        /// <param name="tabId">The ID of the tab from which this email is being sent.</param>
        /// <returns>The result of the SendEmail method.</returns>
        public static string SendEmail(string localResourceFile, string siteUrl, string portalName, string senderEmail, string friendsEmail, string senderName, string friendName, string message, string portalEmail, int moduleId, int tabId)
        {
            using (var settingsControl = new Settings())
            {
                settingsControl.ModuleConfiguration = new ModuleController().GetModule(moduleId, tabId);

                var from            = Utility.GetStringSetting(settingsControl.Settings, "From", string.Empty);
                var carbonCopy      = Utility.GetStringSetting(settingsControl.Settings, "CarbonCopy", string.Empty);
                var blindCarbonCopy = Utility.GetStringSetting(settingsControl.Settings, "BlindCarbonCopy", string.Empty);

                var body    = Utility.GetStringSetting(settingsControl.Settings, "Body", Localization.GetString("EmailAFriend", localResourceFile));
                var subject = Utility.GetStringSetting(settingsControl.Settings, "Subject", Localization.GetString("EmailAFriendSubject", localResourceFile));

                body    = ReplaceTokens(body, friendName, siteUrl, senderName, message, portalName, senderEmail, true);
                subject = ReplaceTokens(subject, friendName, siteUrl, senderName, message, portalName, senderEmail, false);

                return(Mail.SendMail(
                           !string.IsNullOrEmpty(from) ? from : portalEmail,
                           friendsEmail,
                           carbonCopy,
                           blindCarbonCopy,
                           senderEmail,
                           MailPriority.Normal,
                           subject,
                           MailFormat.Html,
                           Encoding.UTF8,
                           body,
                           new string[0],
                           string.Empty,
                           string.Empty,
                           string.Empty,
                           string.Empty,
                           Host.EnableSMTPSSL));
            }
        }
        /// <summary>LoadSettings loads the settings from the Database and displays them</summary>
        public override void LoadSettings()
        {
            try
            {
                if (this.IsPostBack)
                {
                    return;
                }

                this.SiteUrlTextBox.Text              = Utility.GetStringSetting(this.Settings, "SiteUrl", string.Empty);
                this.ShowMessageCheckBox.Checked      = Utility.GetBooleanSetting(this.Settings, "ShowMessage", true);
                this.ShowModalCheckBox.Checked        = Utility.GetBooleanSetting(this.Settings, "ShowModal", false);
                this.CarbonCopyTextBox.Text           = Utility.GetStringSetting(this.Settings, "CarbonCopy", string.Empty);
                this.BlindCarbonCopyTextBox.Text      = Utility.GetStringSetting(this.Settings, "BlindCarbonCopy", string.Empty);
                this.FromTextBox.Text                 = Utility.GetStringSetting(this.Settings, "From", string.Empty);
                this.SubjectTextBox.Text              = Utility.GetStringSetting(this.Settings, "Subject", string.Empty);
                this.BodyTextBox.Text                 = Utility.GetStringSetting(this.Settings, "Body", string.Empty);
                this.InvisibleCaptchaCheckBox.Checked = Utility.GetBooleanSetting(this.Settings, "InvisibleCaptcha", true);
                this.TimedCaptchaCheckBox.Checked     = Utility.GetBooleanSetting(this.Settings, "TimedCaptcha", true);
                this.StandardCaptchaCheckBox.Checked  = Utility.GetBooleanSetting(this.Settings, "StandardCaptcha", false);

                this.SetEmailValidation();
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Ejemplo n.º 3
0
 /// <summary>Loads the settings.</summary>
 private void LoadSettings()
 {
     this.ShowInModal         = Utility.GetBooleanSetting(this.Settings, "ShowModal", this.ShowInModal);
     this.Url                 = Utility.GetStringSetting(this.Settings, "SiteUrl", this.Url);
     this.ShowMessage         = Utility.GetBooleanSetting(this.Settings, "ShowMessage", this.ShowMessage);
     this.UseInvisibleCaptcha = Utility.GetBooleanSetting(this.Settings, "InvisibleCaptcha", this.UseInvisibleCaptcha);
     this.UseTimedCaptcha     = Utility.GetBooleanSetting(this.Settings, "TimedCaptcha", this.UseTimedCaptcha);
     this.UseStandardCaptcha  = Utility.GetBooleanSetting(this.Settings, "StandardCaptcha", this.UseStandardCaptcha);
 }
Ejemplo n.º 4
0
        /// <summary>Handles the <see cref="Button.Click" /> event of the <see cref="SubmitButton" /> control.</summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void SubmitButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (!this.Page.IsValid)
                {
                    return;
                }

                var siteUrl  = Utility.GetStringSetting(this.Settings, "SiteUrl", string.Empty);
                var response = EmailService.SendEmail(
                    this.LocalResourceFile,
                    string.IsNullOrEmpty(siteUrl) ? this.GetCurrentUrl() : siteUrl,
                    this.PortalSettings.PortalName,
                    this.SenderEmailTextBox.Text,
                    this.FriendsEmailTextBox.Text,
                    this.SenderNameTextBox.Text,
                    this.FriendNameTextBox.Text,
                    this.MessageTextBox.Text,
                    this.PortalSettings.Email,
                    this.ModuleId,
                    this.TabId);

                var successfullySent = string.IsNullOrEmpty(response);
                this.SuccessPanel.Visible = successfullySent;
                this.ErrorPanel.Visible   = !successfullySent;

                if (!successfullySent)
                {
                    return;
                }

                this.FriendNameTextBox.Text   = string.Empty;
                this.FriendsEmailTextBox.Text = string.Empty;
                this.MessageTextBox.Text      = string.Empty;
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }