Пример #1
0
        private static int UpdateOrCreateSettingsFile()
        {
            var configFile = GetConfigFile();
            var backupSettings = File.Exists(configFile) ? BackupSettings.LoadBackupSettings(configFile) : new BackupSettings();

            var passwordSettingsDialog = new PasswordSettingsDialog();
            if(passwordSettingsDialog.ShowDialog() == DialogResult.OK) {

                if (!string.IsNullOrWhiteSpace(passwordSettingsDialog.ArchivePassword))
                    backupSettings.ArchivePassword = SecurityHelpers.EncodeSecret(passwordSettingsDialog.ArchivePassword);

                if (!string.IsNullOrWhiteSpace(passwordSettingsDialog.FTPPassword))
                    backupSettings.FTPSettings.FTPPassword = SecurityHelpers.EncodeSecret(passwordSettingsDialog.FTPPassword);

                if (!string.IsNullOrWhiteSpace(passwordSettingsDialog.EmailPassword))
                    backupSettings.EmailSettings.EmailPassword = SecurityHelpers.EncodeSecret(passwordSettingsDialog.EmailPassword);

                //Create a backup of the existing config file
                if(File.Exists(configFile)) {
                    File.Copy(configFile, configFile + ".bak", true);
                }

                backupSettings.SaveBackupSettings(configFile);
            }
            return ExitCodeSuccess;
        }
Пример #2
0
        private static int UpdateOrCreateSettingsFile()
        {
            var configFile     = GetConfigFile();
            var backupSettings = File.Exists(configFile) ? BackupSettings.LoadBackupSettings(configFile) : new BackupSettings();

            var passwordSettingsDialog = new PasswordSettingsDialog();

            if (passwordSettingsDialog.ShowDialog() == DialogResult.OK)
            {
                if (!string.IsNullOrWhiteSpace(passwordSettingsDialog.ArchivePassword))
                {
                    backupSettings.ArchivePassword = SecurityHelpers.EncodeSecret(passwordSettingsDialog.ArchivePassword);
                }

                if (!string.IsNullOrWhiteSpace(passwordSettingsDialog.FTPPassword))
                {
                    backupSettings.FTPSettings.FTPPassword = SecurityHelpers.EncodeSecret(passwordSettingsDialog.FTPPassword);
                }

                if (!string.IsNullOrWhiteSpace(passwordSettingsDialog.EmailPassword))
                {
                    backupSettings.EmailSettings.EmailPassword = SecurityHelpers.EncodeSecret(passwordSettingsDialog.EmailPassword);
                }

                //Create a backup of the existing config file
                if (File.Exists(configFile))
                {
                    File.Copy(configFile, configFile + ".bak", true);
                }

                backupSettings.SaveBackupSettings(configFile);
            }
            return(ExitCodeSuccess);
        }