Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="builder"></param>
        /// <returns></returns>
        protected override IDictionary <string, string> ValidateInput(ref StringBuilder builder)
        {
            IDictionary <string, string> values = new Dictionary <string, string>();

            #region Database Combo Box
            if (databaseComboBox.SelectedIndex < 0)
            {
                builder.AppendLine("ERR: Please select the database to Backup");
            }
            else
            {
                values[Constants.DATABASE_NAME] = databaseComboBox.Items[databaseComboBox.SelectedIndex].ToString();
            }
            #endregion

            #region backup path
            if (String.IsNullOrEmpty(backupPathLabel.Text))
            {
                builder.AppendLine("ERR: Backup Path is required");
            }
            else
            {
                values[Constants.BACKUP_DIRECTORY] = backupPathLabel.Text;
            }
            #endregion

            #region QueryExecutionTimeout
            if (timeoutComboBox.SelectedIndex < 0)
            {
                builder.AppendLine("ERR: Please select a valid time value");
            }
            else
            {
                string timeout = timeoutComboBox.Items[timeoutComboBox.SelectedIndex].ToString();
                if (timeout.IndexOf("Minute") != -1)
                {
                    timeout = timeout.Substring(0, timeout.IndexOf("Minute")).Trim();
                }
                values[Constants.EXECUTION_TIMEOUT] = timeout;
            }
            #endregion

            values[Constants.VERIFY_ONLY] = verifyCheckBox.Checked ? "Y" : "N";
            values[Constants.CHECKSUM]    = checksumCheckBox.Checked ? "Y" : "N";
            values[Constants.BACKUP_TYPE] = _backupType;

            #region Scheduling Settings
            if (goButton.Text == "Save Scheduling &Settings")
            {
                // no validation required here as all the settings
                // are validated in the popup windows
                values[Constants.RUN_INTERVAL]    = interval.ToString();
                values[Constants.ADDITIONAL_INFO] = additionalInfo.Trim();
            }
            #endregion

            return(values);
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="builder"></param>
        /// <returns></returns>
        protected override IDictionary <string, string> ValidateInput(ref StringBuilder builder)
        {
            IDictionary <string, string> values = new Dictionary <string, string>();

            #region Database Combo Box
            if (databaseComboBox.SelectedIndex < 0)
            {
                builder.Append("ERR: Please select a Database Name");
                builder.Append(Environment.NewLine);
            }
            else
            {
                values[Constants.DATABASE_NAME] = databaseComboBox.Items[databaseComboBox.SelectedIndex].ToString();
            }
            #endregion

            #region Command Combo Box
            if (commandComboBox.SelectedIndex < 0)
            {
                builder.Append("ERR: Please select a Valid Command");
                builder.Append(Environment.NewLine);
            }
            else
            {
                values[Constants.CHECK_COMMAND] = GetMappedCommand(commandComboBox.Items[commandComboBox.SelectedIndex].ToString());
            }
            #endregion

            if (physicalCheckBox.Checked && extendedChecksCheckBox.Checked)
            {
                builder.AppendLine("ERR: Physical Only and Extended Logical Checks options cannot be selected at the same time");
            }

            values[Constants.PHYSICAL_ONLY]           = physicalCheckBox.Checked ? "Y" : "N";
            values[Constants.EXTENDED_LOGICAL_CHECKS] = extendedChecksCheckBox.Checked ? "Y" : "N";
            values[Constants.EXCLUDE_INDEXES]         = indexesCheckBox.Checked ? "Y" : "N";
            values[Constants.EXECUTION_TIMEOUT]       = GetTimeOutValue(timeoutComboBox).ToString();

            #region Scheduling Settings
            if (okButton.Text == "Save Scheduling &Settings")
            {
                // no validation required here as all the settings
                // are validated in the popup windows
                values[Constants.RUN_INTERVAL]    = interval.ToString();
                values[Constants.ADDITIONAL_INFO] = additionalInfo.Trim();
            }
            #endregion

            return(values);
        }
Beispiel #3
0
        ///
        public static DialogResult ShowDialog(string caption, ref RunInterval interval, ref string additionalInfo)
        {
            ScheduleDialog dialog = new ScheduleDialog();

            // interval = RunInterval.None;
            // additionalInfo = "";
            if (interval != RunInterval.None && !String.IsNullOrEmpty(additionalInfo))
            {
                int index = dialog.intervalComboBox.FindString(interval.ToString());
                if (index != -1)
                {
                    dialog.intervalComboBox.SelectedIndex = index;
                }

                switch (interval)
                {
                case RunInterval.Hourly:
                    dialog.addInfoDateTimePicker1.Value = DateTime.ParseExact(additionalInfo,
                                                                              "mm:ss", CultureInfo.InvariantCulture);
                    break;

                case RunInterval.Daily:
                    dialog.addInfoDateTimePicker1.Value = DateTime.ParseExact(additionalInfo,
                                                                              "HH:mm", CultureInfo.InvariantCulture);

                    // dialog.addInfoComboBox.SelectedIndex = dialog.addInfoComboBox.FindString(additionalInfo);
                    break;

                case RunInterval.Weekly:
                    string day = additionalInfo.Substring(0, additionalInfo.IndexOf(" at "));
                    dialog.addInfoComboBox.SelectedIndex = dialog.addInfoComboBox.FindString("Every " + day.Trim());
                    string time = additionalInfo.Substring(additionalInfo.IndexOf(" at ") + " at ".Length - 1);
                    dialog.addInfoDateTimePicker1.Value = DateTime.ParseExact(time.Trim(),
                                                                              "HH:mm", CultureInfo.InvariantCulture);
                    break;

                case RunInterval.Fortnightly:
                    day = additionalInfo.Substring(0, additionalInfo.IndexOf(" at "));
                    dialog.addInfoComboBox.SelectedIndex = dialog.addInfoComboBox.FindString("Alternate " + day.Trim());
                    time = additionalInfo.Substring(additionalInfo.IndexOf(" at ") + " at ".Length - 1);
                    dialog.addInfoDateTimePicker1.Value = DateTime.ParseExact(time.Trim(),
                                                                              "HH:mm", CultureInfo.InvariantCulture);
                    break;

                case RunInterval.Monthly:
                    // dialog.addInfoComboBox.SelectedIndex = dialog.addInfoComboBox.FindString(additionalInfo);
                    day = additionalInfo.Substring(additionalInfo.IndexOf("On ") + "On ".Length,
                                                   additionalInfo.IndexOf(" @ ") - " @ ".Length);
                    time = additionalInfo.Substring(additionalInfo.IndexOf(" @ ") + " @ ".Length);
                    DateTime t = Convert.ToDateTime(
                        new DateTime(DateTime.Today.Year, DateTime.Today.Month, Convert.ToInt32(day)).ToShortDateString()
                        + " " + time);
                    dialog.addInfoDateTimePicker1.MinDate = DateTime.Now.AddDays(-1);
                    dialog.addInfoDateTimePicker1.Value   = t;
                    dialog.addInfoDateTimePicker1.MaxDate = DateTime.Now.AddDays(1);
                    break;

                case RunInterval.Yearly:
                    dialog.addInfoDateTimePicker1.MinDate = DateTime.Now.AddYears(-1);
                    dialog.addInfoDateTimePicker1.Value   = DateTime.ParseExact(additionalInfo,
                                                                                "dd-MMM @ hh:mm", CultureInfo.InvariantCulture);
                    dialog.addInfoDateTimePicker1.MaxDate = DateTime.Now.AddYears(1);
                    break;

                default:
                    // do nothing
                    break;
                }
            }
            // Set the members of the new instance
            // according to the value of the parameters
            if (string.IsNullOrEmpty(caption))
            {
                dialog.Text = Application.ProductName;
            }
            else
            {
                dialog.Text = caption;
            }

            // Declare a variable to hold the result to be
            // returned on exitting the method
            DialogResult result = DialogResult.None;

            // Loop round until the user enters
            // some valid data, or cancels.
            while (result == DialogResult.None)
            {
                result = dialog.ShowDialog();
                if (result == DialogResult.OK)
                {
                    bool success = dialog.Validate(out interval, out additionalInfo);
                    if (success)
                    {
                        result = DialogResult.OK;
                    }
                    else
                    {
                        result = DialogResult.None;
                    }
                }
                else
                {
                    result = DialogResult.Cancel;
                }
            }

            // Trash the dialog if it is hanging around.
            dialog.Dispose();

            // Send back the result.
            return(result);
        }
Beispiel #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="builder"></param>
        /// <returns></returns>
        protected override IDictionary <string, string> ValidateInput(ref StringBuilder builder)
        {
            IDictionary <string, string> values = new Dictionary <string, string>();

            #region Database Name Combo Box
            if (databaseComboBox.SelectedIndex < 0)
            {
                builder.AppendLine("ERR: Database Name is required to schedule a DB Maintenance");
            }
            else
            {
                values.Add(Constants.DATABASE_NAME,
                           databaseComboBox.Items[databaseComboBox.SelectedIndex].ToString());
            }
            #endregion

            #region Fragmentation Range
            int  fragLevel1 = 5;
            bool success    = Int32.TryParse(frag1TextBox.Text, out fragLevel1);
            if (!success)
            {
                if (String.IsNullOrEmpty(frag1TextBox.Text))
                {
                    builder.AppendLine("WARN: Minimum Fragmentation 1 Level value not entered, setting to default 5%");
                    frag1TextBox.Text = "5";
                }
                else
                {
                    builder.AppendLine("ERR: Please enter numeric value for fragmentation Level 1\n");
                }
            }
            else if (fragLevel1 > 100 || fragLevel1 < 0)
            {
                builder.AppendLine("ERR: Fragmentation Level 1 Percentage should have range from 0 - 100");
            }
            else
            {
                // everything seems ok
                values[Constants.FRAGMENTATION_LEVEL_1] = fragLevel1.ToString();
            }

            int fragLevel2 = 25;
            success = Int32.TryParse(frag2TextBox.Text, out fragLevel2);
            if (!success)
            {
                if (String.IsNullOrEmpty(frag2TextBox.Text))
                {
                    builder.AppendLine("WARN: Minimum Fragmentation 2 Level value not entered, setting to default 25%");
                    frag2TextBox.Text = "25";
                }
                else
                {
                    builder.AppendLine("ERR: Please enter numeric value for fragmentation Level 2");
                }
            }
            else if (fragLevel2 > 100 || fragLevel2 < 0)
            {
                builder.AppendLine("ERR: Fragmentation Level 2 Percentage should have range from 0 - 100");
            }
            else
            {
                // everything seems Ok
                values[Constants.FRAGMENTATION_LEVEL_2] = fragLevel2.ToString();
            }
            #endregion

            #region Operation Sequence
            string lowOperation = "", mediumOperation = "", highOperation = "";
            if (lowCombobox.SelectedIndex < 2)
            {
                builder.AppendLine("ERR: Please select a Value in first operation Sequence Drop Down");
            }
            else if (lowCombobox.SelectedIndex != 2)
            {
                lowOperation = lowCombobox.Items[lowCombobox.SelectedIndex].ToString();
            }

            if (mediumComboBox.SelectedIndex < 2)
            {
                builder.AppendLine("ERR: Please select a Value in second operation Sequence Drop Down");
            }
            else if (mediumComboBox.SelectedIndex != 2)
            {
                mediumOperation = mediumComboBox.Items[mediumComboBox.SelectedIndex].ToString();
            }

            if (highComboBox.SelectedIndex < 2)
            {
                builder.AppendLine("ERR: Please select a Value in third operation Sequence Drop Down");
            }
            else if (highComboBox.SelectedIndex != 2)
            {
                highOperation = highComboBox.Items[highComboBox.SelectedIndex].ToString();
            }

            string operation = "";
            if (!String.IsNullOrEmpty(lowOperation))
            {
                operation += lowOperation;
            }

            if (!String.IsNullOrEmpty(mediumOperation))
            {
                if (String.IsNullOrEmpty(operation))
                {
                    operation += mediumOperation;
                }
                else
                {
                    operation += "," + mediumOperation;
                }
            }

            if (!String.IsNullOrEmpty(highOperation))
            {
                if (String.IsNullOrEmpty(operation))
                {
                    operation += highOperation;
                }
                else
                {
                    operation += "," + highOperation;
                }
            }

            if (String.IsNullOrEmpty(operation))
            {
                builder.AppendLine("ERR: Please select valid Operation Set");
            }
            else
            {
                values[Constants.OPERATION_SEQUENCE] = operation;
            }
            #endregion

            #region Page Count
            int pageCount = 800;
            success = Int32.TryParse(minPageCntTextBox.Text, out pageCount);
            if (!success)
            {
                if (String.IsNullOrEmpty(minPageCntTextBox.Text))
                {
                    builder.AppendLine("WARN: Page Count Level Set to default, 800");
                    minPageCntTextBox.Text = "800";
                }
                else
                {
                    builder.AppendLine("ERR: Please enter a numeric value for Page Count.");
                }
            }
            else if (pageCount <= 0)
            {
                builder.AppendLine("ERR: Minimum Page Count Value should be positive and greater than 0.");
            }
            else
            {
                values[Constants.MINIMUM_PAGE_COUNT] = pageCount.ToString();
            }
            #endregion

            #region Fill Factor
            int fillFactor = 90; // 90%
            success = Int32.TryParse(fillFactorTextBox.Text, out fillFactor);
            if (!success)
            {
                if (String.IsNullOrEmpty(fillFactorTextBox.Text))
                {
                    builder.AppendLine("WARN: Fill Factor value is empty, setting to default, 90.");
                    fillFactorTextBox.Text = "90";
                }
            }
            else if (fillFactor > 100 || fillFactor < 0)
            {
                builder.AppendLine("ERR: Fill Factor Percentage should have range from 0 - 100");
            }
            else
            {
                values[Constants.FILL_FACTOR] = fillFactor.ToString();
            }
            #endregion

            #region Update Statistics
            if (updateStatsComboBox.SelectedIndex < 0)
            {
                builder.AppendLine("ERR: Please select a value for Update Statistics Type. ");
            }
            else
            {
                string text = updateStatsComboBox.Items[updateStatsComboBox.SelectedIndex].ToString();
                values[Constants.UPDATE_STATISTICS] = GetMappedCommand(text);
            }
            #endregion

            values[Constants.EXECUTION_TIMEOUT] = GetTimeOutValue(timeoutComboBox).ToString();

            #region Scheduling Settings
            if (goButton.Text == "Save Scheduling &Settings")
            {
                // no validation required here as all the settings
                // are validated in the popup windows
                values[Constants.RUN_INTERVAL]    = interval.ToString();
                values[Constants.ADDITIONAL_INFO] = additionalInfo.Trim();
            }
            #endregion

            return(values);
        }