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); }
private void NewBuildScriptForm_Load(object sender, System.EventArgs e) { if (this.scriptRows == null) { if (EnterpriseConfigHelper.UserHasCustomTimeoutSetting()) { txtScriptTimeout.Enabled = false; txtScriptTimeout.Text = ""; } else { txtScriptTimeout.Text = EnterpriseConfigHelper.GetMinumumScriptTimeout(lblFileName.Text, SqlSync.Properties.Settings.Default.DefaultMinimumScriptTimeout).ToString(); } return; } this.lblFileName.Text = "<bulk>"; //Loop through and find the users... StringDictionary users = new StringDictionary(); for (int i = 0; i < this.scriptRows.Length; i++) { if (!users.ContainsKey(this.scriptRows[i].AddedBy)) { this.lblAddedBy.Text += this.scriptRows[i].AddedBy + "; "; users.Add(this.scriptRows[i].AddedBy, this.scriptRows[i].AddedBy); } } users = null; this.rtbDescription.Enabled = false; this.txtBuildOrder.Enabled = false; //Set the script rollback state this.chkRollBackScript.Checked = this.scriptRows[0].RollBackOnError; for (int i = 1; i < this.scriptRows.Length; i++) { if (this.chkRollBackScript.Checked != this.scriptRows[i].RollBackOnError) { this.chkRollBackScript.CheckState = CheckState.Indeterminate; break; } } //Set the build rollback state this.chkRollBackBuild.Checked = this.scriptRows[0].CausesBuildFailure; for (int i = 1; i < this.scriptRows.Length; i++) { if (this.chkRollBackBuild.Checked != this.scriptRows[i].CausesBuildFailure) { this.chkRollBackBuild.CheckState = CheckState.Indeterminate; break; } } //Set the strip transactions state this.chkStripTransactions.Checked = this.scriptRows[0].StripTransactionText; for (int i = 1; i < this.scriptRows.Length; i++) { if (this.chkStripTransactions.Checked != this.scriptRows[i].StripTransactionText) { this.chkStripTransactions.CheckState = CheckState.Indeterminate; break; } } //this.scriptId = scriptId; this.chkAllowMultipleRuns.Checked = this.scriptRows[0].AllowMultipleRuns; for (int i = 1; i < this.scriptRows.Length; i++) { if (this.chkAllowMultipleRuns.Checked != this.scriptRows[i].AllowMultipleRuns) { this.chkAllowMultipleRuns.CheckState = CheckState.Indeterminate; break; } } //Set the script timeout to the max value //Are there mixed values? var vals = (from t in this.scriptRows select t.ScriptTimeOut).Distinct(); this.txtScriptTimeout.Text = vals.Max().ToString(); if (vals.Count() > 1) { this.txtScriptTimeout.ForeColor = Color.Red; } this.txtScriptTimeout.TextChanged += new System.EventHandler(this.txtScriptTimeout_TextChanged); //Set the database string dbName = this.scriptRows[0].Database; for (int i = 1; i < this.scriptRows.Length; i++) { if (dbName.ToLower() != this.scriptRows[i].Database.ToLower()) { ddDatabaseList.Text = string.Empty; ddDatabaseList.Enabled = false; break; } } if (ddDatabaseList.Enabled) { ddDatabaseList.SelectedDatabase = dbName; } this.ddDatabaseList.SelectionChangeCommitted += new EventHandler(ddDatabaseList_SelectionChangeCommitted); this.ddInfer.SelectionChangeCommitted += new EventHandler(ddInfer_SelectionChangeCommitted); //Set the tag List <string> tmp = new List <string>(); for (int i = 0; i < this.scriptRows.Length; i++) { if (!tmp.Contains(this.scriptRows[i].Tag)) { tmp.Add(this.scriptRows[i].Tag); } } if (tmp.Count > 1) { cbTag.BackColor = multipleTagsColor; } else if (tmp.Count > 0) { for (int i = 0; i < cbTag.Items.Count; i++) { if (cbTag.Items[i].ToString() == tmp[0]) { cbTag.SelectedIndex = i; } } } this.BringToFront(); }
private void SetUp() { string dbName = (scriptConfig != null) ? scriptConfig.Database : string.Empty; this.ddDatabaseList.SetData(this.databaseList, dbName); for (int i = 0; i < this.tagList.Count; i++) { cbTag.Items.Add(this.tagList[i]); if (scriptConfig != null && this.tagList[i].Trim().ToLower() == scriptConfig.Tag.Trim().ToLower()) { cbTag.SelectedIndex = i; } } if (scriptConfig != null) { txtBuildOrder.Text = scriptConfig.BuildOrder.ToString(); txtScriptTimeout.Text = scriptConfig.ScriptTimeOut.ToString(); if (!scriptConfig.IsDescriptionNull()) { rtbDescription.Text = scriptConfig.Description; } chkAllowMultipleRuns.Checked = scriptConfig.AllowMultipleRuns; chkRollBackBuild.Checked = scriptConfig.CausesBuildFailure; chkRollBackScript.Checked = scriptConfig.RollBackOnError; if (this.scriptConfig.FileName.EndsWith(DbObjectType.StoredProcedure, StringComparison.CurrentCultureIgnoreCase) || this.scriptConfig.FileName.EndsWith(DbObjectType.UserDefinedFunction, StringComparison.CurrentCultureIgnoreCase) || this.scriptConfig.FileName.EndsWith(DbObjectType.Trigger, StringComparison.CurrentCultureIgnoreCase)) { chkStripTransactions.Checked = false; chkStripTransactions.Enabled = false; toolTip1.SetToolTip(chkStripTransactions, "Stored Procedures, Functions, and Triggers do not allow stripping of transactions"); if (scriptConfig.StripTransactionText == true) { scriptConfig.StripTransactionText = false; this.hasChanged = true; } } else { chkStripTransactions.Checked = scriptConfig.StripTransactionText; } } if (defaultScript != null) { this.ddDatabaseList.SetData(this.databaseList, defaultScript.DatabaseName); txtBuildOrder.Text = defaultScript.BuildOrder.ToString(); rtbDescription.Text = defaultScript.Description; chkAllowMultipleRuns.Checked = defaultScript.AllowMultipleRuns; chkRollBackBuild.Checked = defaultScript.RollBackBuild; chkRollBackScript.Checked = defaultScript.RollBackScript; chkStripTransactions.Checked = defaultScript.StripTransactions; cbTag.Text = defaultScript.ScriptTag; //txtScriptTimeout.Enabled = false; } this.cbTag.SelectedValueChanged += new EventHandler(SetDirtyFlag); this.cbTag.TextChanged += new EventHandler(SetDirtyFlag); this.ddDatabaseList.SelectionChangeCommitted += new EventHandler(SetDirtyFlag); this.rtbDescription.TextChanged += new System.EventHandler(SetDirtyFlag); this.chkRollBackBuild.CheckedChanged += new System.EventHandler(SetDirtyFlag); this.chkRollBackScript.CheckedChanged += new System.EventHandler(SetDirtyFlag); this.chkStripTransactions.CheckedChanged += new System.EventHandler(SetDirtyFlag); this.chkAllowMultipleRuns.CheckedChanged += new System.EventHandler(SetDirtyFlag); this.txtBuildOrder.TextChanged += new System.EventHandler(SetDirtyFlag); this.txtScriptTimeout.TextChanged += new System.EventHandler(SetDirtyFlag); int minValue = EnterpriseConfigHelper.GetMinumumScriptTimeout(this.parentFileName, SqlSync.Properties.Settings.Default.DefaultMinimumScriptTimeout); int val; if (int.TryParse(txtScriptTimeout.Text, out val)) { if (val < minValue) { txtScriptTimeout_Leave(null, EventArgs.Empty); } } }
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(); } }