private void txtScriptTimeout_Leave(object sender, System.EventArgs e)
        {
            int minValue = EnterpriseConfigHelper.GetMinumumScriptTimeout(this.parentFileName, SqlSync.Properties.Settings.Default.DefaultMinimumScriptTimeout);
            ScriptTimeoutValidationResult result = ScriptSettingValidation.CheckScriptTimeoutValue(txtScriptTimeout.Text, minValue);

            switch (result)
            {
            case ScriptTimeoutValidationResult.TimeOutTooSmall:
                string message = string.Format("The script timeout setting was smaller than the minimum setting of {0} seconds. The value has been increased accordingly.", minValue.ToString());
                txtScriptTimeout.Text = minValue.ToString();
                MessageBox.Show(message, "Timeout value too small", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtScriptTimeout.Focus();

                break;

            case ScriptTimeoutValidationResult.NonIntegerValue:
                MessageBox.Show("The Script Timeout value must be a valid 32 bit integer", "Bad Timeout value", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtScriptTimeout.Focus();
                break;
            }
        }
        public bool ValidateValues(string scriptContents, string scriptName)
        {
            int minValue = EnterpriseConfigHelper.GetMinumumScriptTimeout(this.parentFileName, SqlSync.Properties.Settings.Default.DefaultMinimumScriptTimeout);

            if (ScriptSettingValidation.CheckScriptTimeoutValue(txtScriptTimeout.Text, minValue)
                != ScriptTimeoutValidationResult.Ok)
            {
                txtScriptTimeout_Leave(null, EventArgs.Empty);
                return(false);
            }

            bool showMessage = false;

            if (txtBuildOrder.Enabled == true)
            {
                if (txtBuildOrder.Text.Length != 0)
                {
                    try
                    {
                        Double.Parse(txtBuildOrder.Text);
                    }
                    catch
                    {
                        showMessage = true;
                    }
                }
                else
                {
                    showMessage = true;
                }
            }

            if (ddDatabaseList.Enabled == true)
            {
                if (ddDatabaseList.SelectedDatabase.Length == 0)
                {
                    showMessage = true;
                }
            }

            if (showMessage)
            {
                MessageBox.Show("A Target Database and Build Sequence number are required", "Missing Values", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            if (this.tagRequired && cbTag.Text.Length == 0 && cbTag.SelectedValue == null)
            {
                bool alertOnTag = true;
                if (ddInfer.Text != null && ddInfer.Text.ToString() != "None")
                {
                    TagInferenceSource source;
                    switch (ddInfer.Text)
                    {
                    case "Name/Script":
                        source = TagInferenceSource.NameOverText;
                        break;

                    case "Script Only":
                        source = TagInferenceSource.ScriptText;
                        break;

                    case "Name Only":
                        source = TagInferenceSource.ScriptName;
                        break;

                    case "Script/Name":
                    default:
                        source = TagInferenceSource.TextOverName;
                        break;
                    }
                    List <string> regex = new List <string>(SqlSync.Properties.Settings.Default.TagInferenceRegexList.Cast <string>());
                    string        tag   = ScriptTagProcessing.InferScriptTag(scriptName, scriptContents, regex, source);
                    if (tag.Length > 0)
                    {
                        cbTag.Text = tag;
                        alertOnTag = false;
                    }
                }

                if (alertOnTag)
                {
                    string message = "A Target Database, Build Sequence number and Tag are required";

                    if (SqlSync.Properties.Settings.Default.RequireScriptTagsMessage != null)
                    {
                        message = SqlSync.Properties.Settings.Default.RequireScriptTagsMessage;
                    }

                    MessageBox.Show(message, "Missing Tag Value", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }
            }

            return(true);
        }
Beispiel #3
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            int minTimeout = EnterpriseConfigHelper.GetMinumumScriptTimeout(lblFileName.Text, SqlSync.Properties.Settings.Default.DefaultMinimumScriptTimeout);

            if (txtScriptTimeout.Enabled && ScriptSettingValidation.CheckScriptTimeoutValue(txtScriptTimeout.Text, minTimeout) != ScriptTimeoutValidationResult.Ok)
            {
                txtScriptTimeout_Leave(null, EventArgs.Empty);
                return;
            }

            bool showMessage = false;

            if (txtBuildOrder.Enabled == true)
            {
                if (txtBuildOrder.Text.Length != 0)
                {
                    try
                    {
                        Double.Parse(txtBuildOrder.Text);
                    }
                    catch
                    {
                        showMessage = true;
                    }
                }
                else
                {
                    showMessage = true;
                }
            }

            if (ddDatabaseList.Enabled == true)
            {
                if (ddDatabaseList.SelectedDatabase.Length == 0)
                {
                    showMessage = true;
                }
            }

            if (showMessage)
            {
                MessageBox.Show("A Target Database and Build Sequence number are required", "Missing Values", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (SqlSync.Properties.Settings.Default.RequireScriptTags && cbTag.Text.Length == 0 && cbTag.SelectedValue == null)
            {
                bool passedTagTest = false;
                if (!this.tagSelectionChanged && this.cbTag.BackColor == multipleTagsColor)
                {
                    passedTagTest = true;
                }

                if (this.cbTag.BackColor != multipleTagsColor && ddInfer.Text != "None")
                {
                    passedTagTest = true;
                }

                if (!passedTagTest)
                {
                    string message = "A Target Database, Build Sequence number and Tag are required";
                    if (SqlSync.Properties.Settings.Default.RequireScriptTagsMessage != null)
                    {
                        message = SqlSync.Properties.Settings.Default.RequireScriptTagsMessage;
                    }

                    showMessage = true;
                    MessageBox.Show(message, "Missing Tag Value", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            if (!showMessage)
            {
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }