internal static SystemSettings GetSystemSettingsInternal(string settingsName, bool decryptPassword) { // create settings object SystemSettings settings = new SystemSettings(); // get service settings IDataReader reader = null; try { // get service settings reader = DataProvider.GetSystemSettings(settingsName); while (reader.Read()) { string name = (string)reader["PropertyName"]; string val = (string)reader["PropertyValue"]; if (name.ToLower().IndexOf("password") != -1 && decryptPassword) val = CryptoUtils.Decrypt(val); settings[name] = val; } } finally { if (reader != null && !reader.IsClosed) reader.Close(); } return settings; }
public int SetSystemSettings(string settingsName, SystemSettings settings) { return SystemController.SetSystemSettings( settingsName, settings ); }
private void SaveSettings() { try { WSP.SystemSettings settings = new WSP.SystemSettings(); // SMTP settings[SMTP_SERVER] = txtSmtpServer.Text.Trim(); settings[SMTP_PORT] = txtSmtpPort.Text.Trim(); settings[SMTP_USERNAME] = txtSmtpUser.Text.Trim(); settings[SMTP_PASSWORD] = txtSmtpPassword.Text; settings[SMTP_ENABLE_SSL] = chkEnableSsl.Checked.ToString(); // SMTP int result = ES.Services.System.SetSystemSettings( WSP.SystemSettings.SMTP_SETTINGS, settings); if (result < 0) { ShowResultMessage(result); return; } // BACKUP settings = new WSP.SystemSettings(); settings[BACKUPS_PATH] = txtBackupsPath.Text.Trim(); // BACKUP result = ES.Services.System.SetSystemSettings( WSP.SystemSettings.BACKUP_SETTINGS, settings); if (result < 0) { ShowResultMessage(result); return; } } catch (Exception ex) { ShowErrorMessage("SYSTEM_SETTINGS_SAVE", ex); return; } ShowSuccessMessage("SYSTEM_SETTINGS_SAVE"); }
private void LoadSettings() { // SMTP WSP.SystemSettings settings = ES.Services.System.GetSystemSettings( WSP.SystemSettings.SMTP_SETTINGS); if (settings != null) { txtSmtpServer.Text = settings[SMTP_SERVER]; txtSmtpPort.Text = settings[SMTP_PORT]; txtSmtpUser.Text = settings[SMTP_USERNAME]; chkEnableSsl.Checked = Utils.ParseBool(settings[SMTP_ENABLE_SSL], false); } // BACKUP settings = ES.Services.System.GetSystemSettings( WSP.SystemSettings.BACKUP_SETTINGS); if (settings != null) { txtBackupsPath.Text = settings["BackupsPath"]; } }
/// <remarks/> public void SetSystemSettingsAsync(string settingsName, SystemSettings settings, object userState) { if ((this.SetSystemSettingsOperationCompleted == null)) { this.SetSystemSettingsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSetSystemSettingsOperationCompleted); } this.InvokeAsync("SetSystemSettings", new object[] { settingsName, settings}, this.SetSystemSettingsOperationCompleted, userState); }
/// <remarks/> public void SetSystemSettingsAsync(string settingsName, SystemSettings settings) { this.SetSystemSettingsAsync(settingsName, settings, null); }
/// <remarks/> public System.IAsyncResult BeginSetSystemSettings(string settingsName, SystemSettings settings, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("SetSystemSettings", new object[] { settingsName, settings}, callback, asyncState); }
public int SetSystemSettings(string settingsName, SystemSettings settings) { object[] results = this.Invoke("SetSystemSettings", new object[] { settingsName, settings}); return ((int)(results[0])); }
private void LoadSettings() { // SMTP WSP.SystemSettings settings = ES.Services.System.GetSystemSettings( WSP.SystemSettings.SMTP_SETTINGS); if (settings != null) { txtSmtpServer.Text = settings[SMTP_SERVER]; txtSmtpPort.Text = settings[SMTP_PORT]; txtSmtpUser.Text = settings[SMTP_USERNAME]; chkEnableSsl.Checked = Utils.ParseBool(settings[SMTP_ENABLE_SSL], false); } // BACKUP settings = ES.Services.System.GetSystemSettings( WSP.SystemSettings.BACKUP_SETTINGS); if (settings != null) { txtBackupsPath.Text = settings["BackupsPath"]; } // WPI settings = ES.Services.System.GetSystemSettings(WSP.SystemSettings.WPI_SETTINGS); /* * if (settings != null) * { * wpiMicrosoftFeed.Checked = Utils.ParseBool(settings[FEED_ENABLE_MICROSOFT],true); * wpiHeliconTechFeed.Checked = Utils.ParseBool(settings[FEED_ENABLE_HELICON],true); * } * else * { * wpiMicrosoftFeed.Checked = true; * wpiHeliconTechFeed.Checked = true; * } */ if (null != settings) { wpiEditFeedsList.Value = settings[WSP.SystemSettings.FEED_ULS_KEY]; string mainFeedUrl = settings[WSP.SystemSettings.WPI_MAIN_FEED_KEY]; if (string.IsNullOrEmpty(mainFeedUrl)) { mainFeedUrl = WebPlatformInstaller.MAIN_FEED_URL; } txtMainFeedUrl.Text = mainFeedUrl; } // FILE MANAGER settings = ES.Services.System.GetSystemSettings(WSP.SystemSettings.FILEMANAGER_SETTINGS); if (settings != null && !String.IsNullOrEmpty(settings[FILE_MANAGER_EDITABLE_EXTENSIONS])) { txtFileManagerEditableExtensions.Text = settings[FILE_MANAGER_EDITABLE_EXTENSIONS].Replace(",", System.Environment.NewLine); } else { // Original WebsitePanel Extensions txtFileManagerEditableExtensions.Text = FileManager.ALLOWED_EDIT_EXTENSIONS.Replace(",", System.Environment.NewLine); } // RDS var services = ES.Services.RDS.GetRdsServices(); foreach (var service in services) { ddlRdsController.Items.Add(new ListItem(service.ServiceName, service.ServiceId.ToString())); } settings = ES.Services.System.GetSystemSettings(WSP.SystemSettings.RDS_SETTINGS); if (settings != null && !string.IsNullOrEmpty(settings[RDS_MAIN_CONTROLLER])) { ddlRdsController.SelectedValue = settings[RDS_MAIN_CONTROLLER]; } else if (ddlRdsController.Items.Count > 0) { ddlRdsController.SelectedValue = ddlRdsController.Items[0].Value; } // Webdav portal settings = ES.Services.System.GetSystemSettings(WSP.SystemSettings.WEBDAV_PORTAL_SETTINGS); if (settings != null) { chkEnablePasswordReset.Checked = Utils.ParseBool(settings[WSP.SystemSettings.WEBDAV_PASSWORD_RESET_ENABLED_KEY], false); txtWebdavPortalUrl.Text = settings[WEBDAV_PORTAL_URL]; txtPasswordResetLinkLifeSpan.Text = settings[WSP.SystemSettings.WEBDAV_PASSWORD_RESET_LINK_LIFE_SPAN]; chkEnableOwa.Checked = Utils.ParseBool(settings[WSP.SystemSettings.WEBDAV_OWA_ENABLED_KEY], false); txtOwaUrl.Text = settings[WSP.SystemSettings.WEBDAV_OWA_URL]; } // Twilio portal settings = ES.Services.System.GetSystemSettings(WSP.SystemSettings.TWILIO_SETTINGS); if (settings != null) { txtAccountSid.Text = settings.GetValueOrDefault(WSP.SystemSettings.TWILIO_ACCOUNTSID_KEY, string.Empty); txtAuthToken.Text = settings.GetValueOrDefault(WSP.SystemSettings.TWILIO_AUTHTOKEN_KEY, string.Empty); txtPhoneFrom.Text = settings.GetValueOrDefault(WSP.SystemSettings.TWILIO_PHONEFROM_KEY, string.Empty); } }
private void SaveSettings() { try { WSP.SystemSettings settings = new WSP.SystemSettings(); // SMTP settings[SMTP_SERVER] = txtSmtpServer.Text.Trim(); settings[SMTP_PORT] = txtSmtpPort.Text.Trim(); settings[SMTP_USERNAME] = txtSmtpUser.Text.Trim(); settings[SMTP_PASSWORD] = txtSmtpPassword.Text; settings[SMTP_ENABLE_SSL] = chkEnableSsl.Checked.ToString(); // SMTP int result = ES.Services.System.SetSystemSettings( WSP.SystemSettings.SMTP_SETTINGS, settings); if (result < 0) { ShowResultMessage(result); return; } // BACKUP settings = new WSP.SystemSettings(); settings[BACKUPS_PATH] = txtBackupsPath.Text.Trim(); result = ES.Services.System.SetSystemSettings( WSP.SystemSettings.BACKUP_SETTINGS, settings); if (result < 0) { ShowResultMessage(result); return; } // WPI /* * settings[FEED_ENABLE_MICROSOFT] = wpiMicrosoftFeed.Checked.ToString(); * settings[FEED_ENABLE_HELICON] = wpiHeliconTechFeed.Checked.ToString(); */ settings[WSP.SystemSettings.FEED_ULS_KEY] = wpiEditFeedsList.Value; string mainFeedUrl = txtMainFeedUrl.Text; if (string.IsNullOrEmpty(mainFeedUrl)) { mainFeedUrl = WebPlatformInstaller.MAIN_FEED_URL; } settings[WSP.SystemSettings.WPI_MAIN_FEED_KEY] = mainFeedUrl; result = ES.Services.System.SetSystemSettings(WSP.SystemSettings.WPI_SETTINGS, settings); if (result < 0) { ShowResultMessage(result); return; } // FILE MANAGER settings = new WSP.SystemSettings(); settings[FILE_MANAGER_EDITABLE_EXTENSIONS] = Regex.Replace(txtFileManagerEditableExtensions.Text, @"[\r\n]+", ","); result = ES.Services.System.SetSystemSettings( WSP.SystemSettings.FILEMANAGER_SETTINGS, settings); if (result < 0) { ShowResultMessage(result); return; } settings = new WSP.SystemSettings(); settings[RDS_MAIN_CONTROLLER] = ddlRdsController.SelectedValue; result = ES.Services.System.SetSystemSettings(WSP.SystemSettings.RDS_SETTINGS, settings); settings = new WSP.SystemSettings(); settings[WEBDAV_PORTAL_URL] = txtWebdavPortalUrl.Text; settings[WSP.SystemSettings.WEBDAV_PASSWORD_RESET_ENABLED_KEY] = chkEnablePasswordReset.Checked.ToString(); settings[WSP.SystemSettings.WEBDAV_PASSWORD_RESET_LINK_LIFE_SPAN] = txtPasswordResetLinkLifeSpan.Text; settings[WSP.SystemSettings.WEBDAV_OWA_ENABLED_KEY] = chkEnableOwa.Checked.ToString(); settings[WSP.SystemSettings.WEBDAV_OWA_URL] = txtOwaUrl.Text; result = ES.Services.System.SetSystemSettings(WSP.SystemSettings.WEBDAV_PORTAL_SETTINGS, settings); if (result < 0) { ShowResultMessage(result); return; } // Twilio portal settings = new WSP.SystemSettings(); settings[WSP.SystemSettings.TWILIO_ACCOUNTSID_KEY] = txtAccountSid.Text; settings[WSP.SystemSettings.TWILIO_AUTHTOKEN_KEY] = txtAuthToken.Text; settings[WSP.SystemSettings.TWILIO_PHONEFROM_KEY] = txtPhoneFrom.Text; result = ES.Services.System.SetSystemSettings(WSP.SystemSettings.TWILIO_SETTINGS, settings); if (result < 0) { ShowResultMessage(result); return; } } catch (Exception ex) { ShowErrorMessage("SYSTEM_SETTINGS_SAVE", ex); return; } ShowSuccessMessage("SYSTEM_SETTINGS_SAVE"); }
public static int SetSystemSettings(string settingsName, SystemSettings settings) { // check account int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsAdmin | DemandAccount.IsActive); if (accountCheck < 0) return accountCheck; XmlDocument xmldoc = new XmlDocument(); XmlElement root = xmldoc.CreateElement("properties"); foreach (string[] pair in settings.SettingsArray) { string name = pair[0]; string val = pair[1]; if (name.ToLower().IndexOf("password") != -1) val = CryptoUtils.Encrypt(val); XmlElement property = xmldoc.CreateElement("property"); property.SetAttribute("name", name); property.SetAttribute("value", val); root.AppendChild(property); } DataProvider.SetSystemSettings(settingsName, root.OuterXml); return 0; }
public static int SendMessage(string from, string to, string bcc, string subject, string body, MailPriority priority, bool isHtml, Attachment[] attachments) { // Command line argument must the the SMTP host. SmtpClient client = new SmtpClient(); // load SMTP client settings SystemSettings settings = SystemController.GetSystemSettingsInternal( SystemSettings.SMTP_SETTINGS, true ); client.Host = settings["SmtpServer"]; client.Port = settings.GetInt("SmtpPort"); if (!String.IsNullOrEmpty(settings["SmtpUsername"])) { client.Credentials = new NetworkCredential( settings["SmtpUsername"], settings["SmtpPassword"] ); } if (!String.IsNullOrEmpty(settings["SmtpEnableSsl"])) { client.EnableSsl = Utils.ParseBool(settings["SmtpEnableSsl"], false); } // create message MailMessage message = new MailMessage(from, to); message.Body = body; message.BodyEncoding = System.Text.Encoding.UTF8; message.IsBodyHtml = isHtml; message.Subject = subject; message.SubjectEncoding = System.Text.Encoding.UTF8; if (!String.IsNullOrEmpty(bcc)) { message.Bcc.Add(bcc); } message.Priority = priority; if (attachments != null) { foreach (Attachment current in attachments) { message.Attachments.Add(current); } } // send message try { client.Send(message); return(0); } catch (SmtpException ex) { switch (ex.StatusCode) { case SmtpStatusCode.BadCommandSequence: return(BusinessErrorCodes.SMTP_BAD_COMMAND_SEQUENCE); case SmtpStatusCode.CannotVerifyUserWillAttemptDelivery: return(BusinessErrorCodes.SMTP_CANNOT_VERIFY_USER_WILL_ATTEMPT_DELIVERY); case SmtpStatusCode.ClientNotPermitted: return(BusinessErrorCodes.SMTP_CLIENT_NOT_PERMITTED); case SmtpStatusCode.CommandNotImplemented: return(BusinessErrorCodes.SMTP_COMMAND_NOT_IMPLEMENTED); case SmtpStatusCode.CommandParameterNotImplemented: return(BusinessErrorCodes.SMTP_COMMAND_PARAMETER_NOT_IMPLEMENTED); case SmtpStatusCode.CommandUnrecognized: return(BusinessErrorCodes.SMTP_COMMAND_UNRECOGNIZED); case SmtpStatusCode.ExceededStorageAllocation: return(BusinessErrorCodes.SMTP_EXCEEDED_STORAGE_ALLOCATION); case SmtpStatusCode.GeneralFailure: return(BusinessErrorCodes.SMTP_GENERAL_FAILURE); case SmtpStatusCode.InsufficientStorage: return(BusinessErrorCodes.SMTP_INSUFFICIENT_STORAGE); case SmtpStatusCode.LocalErrorInProcessing: return(BusinessErrorCodes.SMTP_LOCAL_ERROR_IN_PROCESSING); case SmtpStatusCode.MailboxBusy: return(BusinessErrorCodes.SMTP_MAILBOX_BUSY); case SmtpStatusCode.MailboxNameNotAllowed: return(BusinessErrorCodes.SMTP_MAILBOX_NAME_NOTALLOWED); case SmtpStatusCode.MailboxUnavailable: return(BusinessErrorCodes.SMTP_MAILBOX_UNAVAILABLE); case SmtpStatusCode.MustIssueStartTlsFirst: return(BusinessErrorCodes.SMTP_MUST_ISSUE_START_TLS_FIRST); case SmtpStatusCode.ServiceClosingTransmissionChannel: return(BusinessErrorCodes.SMTP_SERVICE_CLOSING_TRANSMISSION_CHANNEL); case SmtpStatusCode.ServiceNotAvailable: return(BusinessErrorCodes.SMTP_SERVICE_NOT_AVAILABLE); case SmtpStatusCode.SyntaxError: return(BusinessErrorCodes.SMTP_SYNTAX_ERROR); case SmtpStatusCode.TransactionFailed: return(BusinessErrorCodes.SMTP_TRANSACTION_FAILED); case SmtpStatusCode.UserNotLocalTryAlternatePath: return(BusinessErrorCodes.SMTP_USER_NOT_LOCAL_TRY_ALTERNATE_PATH); case SmtpStatusCode.UserNotLocalWillForward: return(BusinessErrorCodes.SMTP_USER_NOT_LOCAL_WILL_FORWARD); default: return(BusinessErrorCodes.SMTP_UNKNOWN_ERROR); } } finally { // Clean up. message.Dispose(); } }
private void SaveSettings() { try { WSP.SystemSettings settings = new WSP.SystemSettings(); // SMTP settings[SMTP_SERVER] = txtSmtpServer.Text.Trim(); settings[SMTP_PORT] = txtSmtpPort.Text.Trim(); settings[SMTP_USERNAME] = txtSmtpUser.Text.Trim(); settings[SMTP_PASSWORD] = txtSmtpPassword.Text; settings[SMTP_ENABLE_SSL] = chkEnableSsl.Checked.ToString(); // SMTP int result = ES.Services.System.SetSystemSettings( WSP.SystemSettings.SMTP_SETTINGS, settings); if (result < 0) { ShowResultMessage(result); return; } // BACKUP settings = new WSP.SystemSettings(); settings[BACKUPS_PATH] = txtBackupsPath.Text.Trim(); result = ES.Services.System.SetSystemSettings( WSP.SystemSettings.BACKUP_SETTINGS, settings); if (result < 0) { ShowResultMessage(result); return; } // WPI /* settings[FEED_ENABLE_MICROSOFT] = wpiMicrosoftFeed.Checked.ToString(); settings[FEED_ENABLE_HELICON] = wpiHeliconTechFeed.Checked.ToString(); */ settings[WSP.SystemSettings.FEED_ULS_KEY] = wpiEditFeedsList.Value; string mainFeedUrl = txtMainFeedUrl.Text; if (string.IsNullOrEmpty(mainFeedUrl)) { mainFeedUrl = WebPlatformInstaller.MAIN_FEED_URL; } settings[WSP.SystemSettings.WPI_MAIN_FEED_KEY] = mainFeedUrl; result = ES.Services.System.SetSystemSettings(WSP.SystemSettings.WPI_SETTINGS, settings); if (result < 0) { ShowResultMessage(result); return; } // FILE MANAGER settings = new WSP.SystemSettings(); settings[FILE_MANAGER_EDITABLE_EXTENSIONS] = Regex.Replace(txtFileManagerEditableExtensions.Text, @"[\r\n]+", ","); result = ES.Services.System.SetSystemSettings( WSP.SystemSettings.FILEMANAGER_SETTINGS, settings); if (result < 0) { ShowResultMessage(result); return; } settings = new WSP.SystemSettings(); settings[RDS_MAIN_CONTROLLER] = ddlRdsController.SelectedValue; result = ES.Services.System.SetSystemSettings(WSP.SystemSettings.RDS_SETTINGS, settings); settings = new WSP.SystemSettings(); settings[WEBDAV_PORTAL_URL] = txtWebdavPortalUrl.Text; settings[WSP.SystemSettings.WEBDAV_PASSWORD_RESET_ENABLED_KEY] = chkEnablePasswordReset.Checked.ToString(); settings[WSP.SystemSettings.WEBDAV_PASSWORD_RESET_LINK_LIFE_SPAN] = txtPasswordResetLinkLifeSpan.Text; settings[WSP.SystemSettings.WEBDAV_OWA_ENABLED_KEY] = chkEnableOwa.Checked.ToString(); settings[WSP.SystemSettings.WEBDAV_OWA_URL] = txtOwaUrl.Text; result = ES.Services.System.SetSystemSettings(WSP.SystemSettings.WEBDAV_PORTAL_SETTINGS, settings); if (result < 0) { ShowResultMessage(result); return; } // Twilio portal settings = new WSP.SystemSettings(); settings[WSP.SystemSettings.TWILIO_ACCOUNTSID_KEY] = txtAccountSid.Text; settings[WSP.SystemSettings.TWILIO_AUTHTOKEN_KEY] = txtAuthToken.Text; settings[WSP.SystemSettings.TWILIO_PHONEFROM_KEY] = txtPhoneFrom.Text; result = ES.Services.System.SetSystemSettings(WSP.SystemSettings.TWILIO_SETTINGS, settings); if (result < 0) { ShowResultMessage(result); return; } } catch (Exception ex) { ShowErrorMessage("SYSTEM_SETTINGS_SAVE", ex); return; } ShowSuccessMessage("SYSTEM_SETTINGS_SAVE"); }