Exemplo n.º 1
0
        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));
            }
        }
Exemplo n.º 2
0
        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));
            }
        }