private bool PrecompileMultiDbData() { if (this.connData == null) { MessageBox.Show("Please select a source server and database to execute against", "Connection Needed", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } if (ddDatabase.SelectedItem == null) { MessageBox.Show("Please select a database to execute against", "Database Name Needed", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } connData.DatabaseName = ddDatabase.SelectedItem.ToString(); connData.SQLServerName = lblServer.Text.Trim(); string message; this.multiDbConfig = MultiDbHelper.CreateMultiDbConfigFromQuery(connData, rtbSqlScript.Text, out message); if (this.multiDbConfig == null) { MessageBox.Show("Unable to create a configuration from your query. Please confirm your database settings and query.\r\n\r\nDatabase Message:\r\n" + message, "Unable to create", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } return(true); }
private void runBuildUsingCurrentConfigurationToolStripMenuItem_Click(object sender, EventArgs e) { this.runConfiguration = GetServerDataCollection(); if (this.runConfiguration == null) { return; } if (!MultiDbHelper.ValidateMultiDatabaseData(this.runConfiguration)) { MessageBox.Show("One or more scripts is missing a default or target override database setting.\r\nRun has been halted. Please correct the error and try again", "Missing Database setting", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (this.runConfiguration.Count == 1 && this.runConfiguration[0].OverrideSequence.Count == 0) { MessageBox.Show("Please configure a run order for at least one database item", "Unable to run", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } this.runConfiguration.RunAsTrial = true; this.runAsTrial = true; if (this.valuesChanged && ConfirmSave(ConfirmType.Run)) { this.DialogResult = DialogResult.OK; this.Close(); } else { this.DialogResult = DialogResult.OK; this.Close(); } }
private void saveQueryConfigurationToolStripMenuItem_Click(object sender, EventArgs e) { if (DialogResult.OK == saveFileDialog1.ShowDialog()) { MultiDbQueryConfig cfg = new MultiDbQueryConfig(this.connData.SQLServerName, this.ddDatabase.SelectedItem.ToString(), this.rtbSqlScript.Text); MultiDbHelper.SaveMultiDbQueryConfiguration(saveFileDialog1.FileName, cfg); this.mruManager.Add(saveFileDialog1.FileName); this.savedMultiDbQFile = saveFileDialog1.FileName; this.isDirty = false; } }
private void LoadQueryConfig(string fileName) { MultiDbQueryConfig cfg = MultiDbHelper.LoadMultiDbQueryConfiguration(fileName); if (cfg != null) { lblServer.Text = cfg.SourceServer; this.SetDatabaseList(cfg.SourceServer, cfg.Database); this.mruManager.Add(fileName); rtbSqlScript.Text = cfg.Query; } this.isDirty = false; }
public static MultiDbData CreateMultiDbConfigFromQueryFile(string fileName, out string message) { try { MultiDbQueryConfig cfg = MultiDbHelper.LoadMultiDbQueryConfiguration(fileName); ConnectionData connData = new ConnectionData(cfg.SourceServer, cfg.Database); return(CreateMultiDbConfigFromQuery(connData, cfg.Query, out message)); } catch (Exception exe) { message = exe.Message; return(null); } }
private void bgLoadCfg_DoWork(object sender, DoWorkEventArgs e) { List <ServerData> svrDataList = new List <ServerData>(); MultiDbData data = null; BackgroundWorker bg = (BackgroundWorker)sender; if (e.Argument is string) { bg.ReportProgress(-10, "Initializing"); string fileName = e.Argument.ToString(); bg.ReportProgress(10, "Loading " + Path.GetFileName(fileName) + "..."); data = MultiDbHelper.DeserializeMultiDbConfiguration(fileName); if (data == null) //maybe have a flat .cfg file?? { data = MultiDbHelper.ImportMultiDbTextConfig(fileName); } } else if (e.Argument is MultiDbData) { data = (MultiDbData)e.Argument; } if (data != null) { bg.ReportProgress(0, "Applying configuration... "); foreach (ServerData srv in data) { //We need to get the list of databases for this server if it doesn't match the current connection if (srv.ServerName != this.server) { bg.ReportProgress(10, "Retrieving database list from " + srv.ServerName); ConnectionData tmpC = new ConnectionData(); tmpC.Fill(this.connData); tmpC.SQLServerName = srv.ServerName; tmpC.DatabaseName = "master"; srv.Databases = InfoHelper.GetDatabaseList(tmpC); } else { srv.Databases = this.databaseList; } svrDataList.Add(srv); } e.Result = svrDataList; } }