Пример #1
0
        /// <summary>
        ///
        /// </summary>
        public Main()
            : base()
        {
            InitializeComponent();

            Assembly assembly = Assembly.GetExecutingAssembly();

            string[] resourceNames = { "UserConfig.InstallConfig.sql",
                                       "UserConfig.InstallDBMaintenance.sql" };

            DBUtils.SetupDatabase(assembly, resourceNames);
            _config = SystemConfig.GetInstance();

            ToolStripItem[] items = menuStrip.Items.Find("enableMailAlertsToolStripMenuItem", true);
            foreach (ToolStripItem item in items)
            {
                ToogleMenuItem(item, _config.MailAlerts, "mailSetupParametersToolStripMenuItem");
            }

            items = menuStrip.Items.Find("schedulingToolStripMenuItem", true);
            foreach (ToolStripItem item in items)
            {
                ToogleMenuItem(item, _config.AutomaticScheduling);
            }

            items = menuStrip.Items.Find("compressBackupToolStripMenuItem", true);
            foreach (ToolStripItem item in items)
            {
                ToogleMenuItem(item, _config.CompressBackup);
            }
        }
        /// <summary>
        ///
        /// </summary>
        public MailConfig()
        {
            InitializeComponent();

            config = SystemConfig.GetInstance();

            fromTextBox.Text        = config.EmailFrom;
            displayNameTextBox.Text = config.DisplayName;
            mailServerTextBox.Text  = config.MailServer;
            portTextBox.Text        = config.MailServerPort.ToString();
            userNameTextBox.Text    = config.UserName;
            passwordTextBox.Text    = config.Password;
            string mailTo = config.MailTo;

            string[] parts = mailTo.Split(',');
            foreach (string part in parts)
            {
                if (!String.IsNullOrEmpty(part))
                {
                    mailToListBox.Items.Add(part);
                }
            }

            if (String.IsNullOrEmpty(config.MailServer) || String.IsNullOrEmpty(config.EmailFrom))
            {
                // config is not saved yet.
                testButton.Visible = false;
            }
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        public IntegrityConfig()
        {
            InitializeComponent();

            InitializeDatabaseComboBox(databaseComboBox);

            InitializeTimeoutComboBox(timeoutComboBox);

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

            SystemConfig systemConfig = SystemConfig.GetInstance();

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

            IntegrityCheckConfig config = IntegrityCheckConfig.GetInstance();

            if (!String.IsNullOrEmpty(config.DatabaseName))
            {
                int index = databaseComboBox.FindString(config.DatabaseName);
                if (index != -1)
                {
                    databaseComboBox.SelectedIndex = index;
                }
            }
            physicalCheckBox.Checked = config.PhysicalOnly.Equals("Y") ? true : false;
            GetCheckBoxText(physicalCheckBox);

            indexesCheckBox.Checked = config.ExcludeIndexes.Equals("Y") ? true : false;
            GetCheckBoxText(indexesCheckBox);

            extendedChecksCheckBox.Checked = config.ExtendedLogicalChecks.Equals("Y") ? true : false;
            GetCheckBoxText(extendedChecksCheckBox);

            interval       = config.RunInterval;
            additionalInfo = config.AdditionalInfo;

            if (!String.IsNullOrEmpty(config.CheckCommand))
            {
                int index = commandComboBox.FindString(GetMappedCommand(config.CheckCommand));
                if (index != -1)
                {
                    commandComboBox.SelectedIndex = index;
                }
            }

            commandComboBox.SelectedIndex = commandComboBox.FindString(GetMappedCommand(config.CheckCommand));
        }
Пример #4
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);
                }
            }
        }
Пример #5
0
        /// <summary>
        ///
        /// </summary>
        public RunConfig()
        {
            InitializeComponent();

            InitializeDatabaseComboBox(databaseComboBox);
            InitializeTimeoutComboBox(timeoutComboBox);

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

            SystemConfig systemConfig = SystemConfig.GetInstance();

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

            IndexConfig config = IndexConfig.GetInstance();

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

            frag1TextBox.Text = config.FragmentationLevel1.ToString();
            frag2TextBox.Text = config.FragmentationLevel2.ToString();

            if (config.OperationSequence != null)
            {
                string[] parts = config.OperationSequence.Split(',');
                if (parts.Length > 0)
                {
                    lowCombobox.SelectedIndex = lowCombobox.FindString(parts[0]);
                }
                if (parts.Length > 1)
                {
                    mediumComboBox.SelectedIndex = mediumComboBox.FindString(parts[1]);
                }
                if (parts.Length > 2)
                {
                    highComboBox.SelectedIndex = highComboBox.FindString(parts[2]);
                }
            }

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

            if (i != -1)
            {
                timeoutComboBox.SelectedIndex = i;
            }
            fillFactorTextBox.Text   = config.FillFactor.ToString();
            updateStatsComboBox.Text = GetMappedCommand(config.UpdateStatistics);
            interval       = config.RunInterval;
            additionalInfo = config.AdditionalInfo;
            if (config.NextExecution != null)
            {
                scheduleLabel.Text = GetDisplaySchedule(interval, additionalInfo)
                                     + ". Next Execution @ " + config.NextExecution;
                scheduleLabel.Visible = true;
            }
        }
Пример #6
0
        private void Process(string[] args)
        {
            try
            {
                ScheduleConfig config = GetConfigFromFileName(args);

                string logFileName = config.GetCommandOperation();
                logFileName  = logFileName.Replace("[", "");
                logFileName  = logFileName.Replace("]", "");
                logFileName += "_" + DateTime.Now.ToString("ddMMyyyyhhmmss") + ".log";

                LogFilePath = logFileName;

                StringBuilder commandPrintOutput = new StringBuilder();

                if (config is IndexConfig)
                {
                    // get the before screenshot
                    Log("*****************************************************");
                    Log("Before Snapshot for the fragmenation levels");
                    Log("*****************************************************");
                    LogDBFragLevel(config as IndexConfig);
                }

                DatabaseManager manager = new DatabaseManager();
                manager.ExecuteQuery(config.GetCommandOperation(),
                                     QueryMode.Update,
                                     config.GetCommandParameters(),
                                     commandPrintOutput,
                                     config.QueryExecutionTimeout);

                Log("Execution Completed Successfully...");

                if (!String.IsNullOrEmpty(commandPrintOutput.ToString()))
                {
                    Log("*************************************************************");
                    Log(config.GetCommandOperation() + " started @ " + DateTime.Now.ToShortDateString()
                        + " " + DateTime.Now.ToShortTimeString());
                    Log("*************************************************************");
                    Log(commandPrintOutput.ToString());

                    Log("*************************************************************");
                    Log("Execution successful @ " + DateTime.Now.ToShortDateString()
                        + " " + DateTime.Now.ToShortTimeString());
                    Log("*************************************************************");
                }

                if (config is IndexConfig)
                {
                    // get the post screenshot
                    Log("*****************************************************");
                    Log("After Snapshot for the fragmenation levels");
                    Log("*****************************************************");
                    LogDBFragLevel(config as IndexConfig);
                }

                // Mail Reports
                SystemConfig systemConfig = SystemConfig.GetInstance();

                if (systemConfig.CompressBackup && config is DoBackupConfig)
                {
                    // compression logic here
                    string compressedPath = Utility.CompressLastBackup();
                    Log("Backup File Successfully Compressed @ " + compressedPath);
                    compressedPath = null;
                }

                if (systemConfig.MailAlerts)
                {
                    StringBuilder builder = new StringBuilder();
                    builder.Append("<p>Hi,</p>");
                    builder.Append("<p>Scheduled [IndexOptimize] on database completed Successfully @ ");
                    builder.Append(DateTime.Now.ToString());
                    builder.Append("<br />The complete log of execution is attached. For any issues concerns please write");
                    builder.Append(" to us @ <a href=\"mailTo:[email protected]\" title=\"Write to Us\">");
                    builder.Append("[email protected]</a> or visit ");
                    builder.Append("<a href=\"http://www.footstepsinfotech.com/\" title=\"Footsteps Infotech Inc.\">");
                    builder.Append("www.footstepsinfotech.com</a></p><p>");
                    builder.Append("You can check the full execution log @ IndexOptimize_05052015020336.log</p>");
                    builder.Append("~<br />Thanks,<br />DB Health Check<br />© Footsteps Infotech Inc.");
                    MailUtility mailUtils = new MailUtility(systemConfig);
                    mailUtils.SendMail(builder.ToString(), "DB Health Check : "
                                       + config.GetCommandOperation() + " execution completed successfully", LogFilePath, false);

                    builder.Clear();
                    builder   = null;
                    mailUtils = null;
                }
            }
            catch (Exception e)
            {
                if (args.Length < 2)
                {
                    Log("Please pass the configuration name for execution");
                    Log("Execute the program as Program -c <configName>");
                    throw new ArgumentException("Please pass the configuration name for execution");
                }
                Log("Program invoked successfully... " + args);
                Log(e);
            }
        }
Пример #7
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;
            }
        }