protected override void MessageReceived(object sender, Shared.Communication.Message message) { base.MessageReceived(sender, message); switch (message.Title) { case StringConstants.LOAD_CLIENT_DETAILS: message.Title = StringConstants.CREATE_SETTINGS; message.Contents = ServerBaseControl.ConvertToJson <ServiceSettings>(_serviceSettings); MessageRespond(message); message.Contents = ServerBaseControl.ConvertToJson <ServiceSettings>(_SmtpServer); MessageRespond(message); message.Title = StringConstants.LOAD_CLIENT_DETAILS; break; case StringConstants.Service.SERVICE_SETTINGS_SAVE: SaveServiceSettings(ServerBaseControl.ConvertFromJson <ServiceSettings>(message.Contents)); return; case StringConstants.Service.SERVICE_EMAIL_SETTINGS_SAVE: SaveEmailSettings(ServerBaseControl.ConvertFromJson <ServiceSettings>(message.Contents)); return; } _pluginManager.ProcessMessage(message); }
private void LoadServiceSettings() { string settingFile = Utils.GetPath(PathType.Settings) + Constants.Settings.ServiceSettingsFileName; string fileContents = Utilities.FileRead(settingFile, false); if (String.IsNullOrEmpty(fileContents)) { _serviceSettings = new ServiceSettings(Constants.Settings.Service); _serviceSettings.MessageName = StringConstants.Service.SERVICE_SETTINGS_SAVE; Utilities.FileWrite(settingFile, ServerBaseControl.ConvertToJson <ServiceSettings>(_serviceSettings)); } else { _serviceSettings = ServerBaseControl.ConvertFromJson <ServiceSettings>(fileContents); } if (_serviceSettings.Find(Constants.Settings.UserName) == null) { _serviceSettings.Add(new ServiceSetting(Constants.Settings.UserName, SettingType.String, StringConstants.Service.DefaultUsername) { MaximumLength = 50 }); } if (_serviceSettings.Find(Constants.Settings.Password) == null) { _serviceSettings.Add(new ServiceSetting(Constants.Settings.Password, SettingType.Password, StringConstants.Service.DefaultPassword) { MaximumLength = 50 }); } if (_serviceSettings.Find(Constants.Settings.ConnectionIP) == null) { _serviceSettings.Add(new ServiceSetting(Constants.Settings.ConnectionIP, SettingType.String, Constants.Other.Asterix.ToString()) { MaximumLength = 50 }); } if (_serviceSettings.Find(Constants.Settings.MonitorNetworks) == null) { _serviceSettings.Add(new ServiceSetting(Constants.Settings.MonitorNetworks, SettingType.Bool, Boolean.TrueString)); } if (_serviceSettings.Find(Constants.Settings.MonitorDisks) == null) { _serviceSettings.Add(new ServiceSetting(Constants.Settings.MonitorDisks, SettingType.Bool, Boolean.TrueString)); } }
private void LoadEmailSettings() { string settingFile = Utils.GetPath(PathType.Settings) + Constants.Settings.EmailSettingsFileName; string fileContents = Utilities.FileRead(settingFile, false); if (String.IsNullOrEmpty(fileContents)) { _SmtpServer = new ServiceSettings(Constants.Settings.SmtpSettings); _SmtpServer.MessageName = StringConstants.Service.SERVICE_EMAIL_SETTINGS_SAVE; Utilities.FileWrite(settingFile, ServerBaseControl.ConvertToJson <ServiceSettings>(_SmtpServer)); } else { _SmtpServer = ServerBaseControl.ConvertFromJson <ServiceSettings>(fileContents); } if (_SmtpServer.Find(Constants.Settings.SmtpUsername) == null) { _SmtpServer.Add(new ServiceSetting(Constants.Settings.SmtpUsername, SettingType.String, String.Empty) { MaximumLength = 50 }); } if (_SmtpServer.Find(Constants.Settings.SmtpPassword) == null) { _SmtpServer.Add(new ServiceSetting(Constants.Settings.SmtpPassword, SettingType.Password, String.Empty) { MaximumLength = 50 }); } if (_SmtpServer.Find(Constants.Settings.SmtpHost) == null) { _SmtpServer.Add(new ServiceSetting(Constants.Settings.SmtpHost, SettingType.String, String.Empty) { MaximumLength = 50 }); } if (_SmtpServer.Find(Constants.Settings.SmtpSenderEmail) == null) { _SmtpServer.Add(new ServiceSetting(Constants.Settings.SmtpSenderEmail, SettingType.String, String.Empty)); } if (_SmtpServer.Find(Constants.Settings.SmtpSSL) == null) { _SmtpServer.Add(new ServiceSetting(Constants.Settings.SmtpSSL, SettingType.Bool, Boolean.TrueString)); } }