示例#1
0
        private void goButton_Click(object sender, EventArgs e)
        {
            StringBuilder builder = new StringBuilder();
            int           timeout = GetTimeOutValue(timeoutComboBox); // convert to seconds
            bool          success = false;

            if (goButton.Text == "Save Scheduling &Settings")// save scheduling settings
            {
                DoBackupConfig dbConfig      = DoBackupConfig.GetInstance(_backupType);
                string         operationName = "Database Backup";
                success = SaveConfigurations(dbConfig) &&
                          ScheduleOperation(operationName, dbConfig, @"-c DoBackupConfig -type " + _backupType.ToUpper());
                if (success) // All Validation passed.
                {
                    MessageBox.Show("Configuration Saved Successfully. " + operationName
                                    + GetDisplaySchedule(dbConfig.RunInterval, dbConfig.AdditionalInfo),
                                    "Success", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                    scheduleLabel.Text = GetDisplaySchedule(dbConfig.RunInterval, dbConfig.AdditionalInfo) + ". Next Execution @ " + dbConfig.NextExecution;
                }
                return;
            }
            success = SubmitForm(ref builder, "[DatabaseBackup]", timeout);
            SystemConfig sytemConfig    = SystemConfig.GetInstance();
            string       compressedPath = null;

            if (sytemConfig.CompressBackup) // enable Compression by default
            {
                compressedPath = Utility.CompressLastBackup();
            }
            if (success)
            {
                if (!String.IsNullOrEmpty(compressedPath))
                {
                    MessageBox.Show("Backup Completed Successfully. Compressed Backup @ " + compressedPath,
                                    "Backup Successful", MessageBoxButtons.OK, MessageBoxIcon.Information,
                                    MessageBoxDefaultButton.Button1);
                }
                else
                {
                    MessageBox.Show("Backup Completed Successfully. Please check the log file for more details",
                                    "Backup Successful", MessageBoxButtons.OK, MessageBoxIcon.Information,
                                    MessageBoxDefaultButton.Button1);
                }
            }
        }
示例#2
0
        private ScheduleConfig GetConfigFromFileName(string[] args)
        {
            string     _config    = args[1];
            ConfigType configType = (ConfigType)Enum.Parse(typeof(ConfigType), _config);

            switch (configType)
            {
            case ConfigType.DoBackupConfig:
                string type = args[3];
                return(DoBackupConfig.GetInstance(type.ToUpper()));

            case ConfigType.IndexConfig:
                return(IndexConfig.GetInstance());

            case ConfigType.IntegrityCheckConfig:
                return(IntegrityCheckConfig.GetInstance());
            }
            return(null);
        }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="backupType"></param>
        public BackupConfig(string backupType)
        {
            this._backupType = backupType;

            InitializeComponent();

            folderBrowserDialog1.Description = "Select a Backup Directory";
            folderBrowserDialog1.RootFolder  = Environment.SpecialFolder.DesktopDirectory;

            folderBrowserDialog1.SelectedPath = AppDomain.CurrentDomain.BaseDirectory;

            InitializeDatabaseComboBox(databaseComboBox);
            InitializeTimeoutComboBox(timeoutComboBox);

            GetCheckBoxText(verifyCheckBox);
            GetCheckBoxText(checksumCheckBox);

            LogDirectory      = AppDomain.CurrentDomain.BaseDirectory;
            logFileLabel.Text = LogDirectory;

            SystemConfig systenConfig = SystemConfig.GetInstance();

            if (systenConfig.AutomaticScheduling)
            {
                scheduleButton.Visible = true;
            }

            DoBackupConfig config = DoBackupConfig.GetInstance(_backupType);

            if (!String.IsNullOrEmpty(config.DatabaseName))
            {
                int index = databaseComboBox.FindString(config.DatabaseName);
                if (index != -1)
                {
                    databaseComboBox.SelectedIndex = index;
                }
            }

            checksumCheckBox.Checked          = config.ChecksumCheck == "Y";
            verifyCheckBox.Checked            = config.VerifyBackup == "Y";
            folderBrowserDialog1.SelectedPath = config.DatabaseDirectory;
            backupPathLabel.Text = config.DatabaseDirectory;

            int i = timeoutComboBox.FindString((config.QueryExecutionTimeout / 60).ToString() + " minute");

            if (i != -1)
            {
                timeoutComboBox.SelectedIndex = i;
            }
            backupTypeComboBox.Text = GetMappedCommand(_backupType);

            interval       = config.RunInterval;
            additionalInfo = config.AdditionalInfo;
            if (config.NextExecution != null)
            {
                scheduleLabel.Text = "Scheduled to Run " + interval + " at " + additionalInfo
                                     + " i.e. " + config.NextExecution;
                scheduleLabel.Visible = true;
            }
            else
            {
                scheduleLabel.Visible = false;
            }
        }