public void Initialize(DatabaseOperation databaseOperation, string sql) { InitializeDictionary(); timeTextBox.GotFocus += TimeTextBox_GotFocus; elapsedTimeTimer.Start(); _sw.Reset(); _sw.Start(); _databaseOperation = databaseOperation; if (GenericHelper.IsUserInteractive()) { InitializeWorker(); _worker.RunWorkerAsync(sql); } else { ErrorFormParams errorFormParams = null; if (sql != null) { errorFormParams = DoWork(sql); } RunWorkerCompleted(errorFormParams); } }
private bool UnattendedRunPostScript() { bool success = true; ErrorFormParams errorFormParams = dataViewUserControl1.RunPostScriptFile(_postScriptFileName); if (errorFormParams != null) { success = false; } if (success) { errorFormParams = dataViewUserControl1.RunPostScript(_postScript); if (errorFormParams != null) { success = false; } } if (!success) { ErrorFormHandler errorFormHandler = new ErrorFormHandler(); if (!ConfigHandler.ErrorFormShown) { ConfigHandler.ErrorFormShown = true; errorFormHandler.ErrorOccuredEvent(errorFormParams.OkButtonText, errorFormParams.Message, errorFormParams.Sql); } } return(success); }
private static void ShowErrorForm(object arg) { ErrorFormParams errorFormParams = (ErrorFormParams)arg; ErrorForm form = new ErrorForm(); string message = errorFormParams.Message; if (ConfigHandler.ActiveCustomColumn != "") { string text = "Error in Custom Column"; if (ConfigHandler.UseTranslation) { text = Translator.GetText("errorInCustomColumn"); } message = string.Format("{2}: {1}\r\n{0}", message, ConfigHandler.ActiveCustomColumn, text); } form.SetValues(errorFormParams.OkButtonText, message, errorFormParams.Sql, GenericHelper.InfoText); if (GenericHelper.IsUserInteractive()) { form.ShowDialog(); } OutputHandler.WriteToLog(string.Format("{0}\r\n{1}", message, errorFormParams.Sql)); Application.DoEvents(); }
private static void ShowErrorForm(object arg) { ErrorFormParams errorFormParams = (ErrorFormParams)arg; ErrorForm form = new ErrorForm(errorFormParams.ErrorNumber, errorFormParams.OkButtonText, errorFormParams.Message, errorFormParams.Sql, errorFormParams.Location); form.ShowDialog(); Application.DoEvents(); }
private void HandleError(string message, string sql, int errorNumber) { _success = false; string okButtonText = "Close"; if (ConfigHandler.UseTranslation) { okButtonText = Translator.GetText("Close"); } if (_exitOnError) { okButtonText = "Exit"; if (ConfigHandler.UseTranslation) { okButtonText = Translator.GetText("exit"); } } _errorFormParams = new ErrorFormParams(okButtonText, message, sql); if (_showErrorForm && (ConfigHandler.ErrorNumbersToSkip == null || (ConfigHandler.ErrorNumbersToSkip != null && !ConfigHandler.ErrorNumbersToSkip.Contains(errorNumber)))) { ErrorFormHandler errorFormHandler = new ErrorFormHandler(); if (!ConfigHandler.ErrorFormShown) { ConfigHandler.ErrorFormShown = true; errorFormHandler.ErrorOccuredEvent(okButtonText, message, sql); } if (errorNumber != -1 && ConfigHandler.ErrorNumbersToSkip != null) { ConfigHandler.ErrorNumbersToSkip.Add(errorNumber); } } if (_exitOnError) { Dispose(); Environment.Exit(-1); } }
private static DatabaseMessageObject GetDatabaseMessage(string connectionString, string sql) { string message = ""; bool success = false; DatabaseOperation databaseOperation = new DatabaseOperation(); SqlConnectionStringBuilder tempConnString = new SqlConnectionStringBuilder(connectionString); tempConnString.Password = ConnectionStringSecurity.Decode(tempConnString.Password); databaseOperation.InitializeDal(tempConnString.ToString()); ErrorFormParams errorFormParams = databaseOperation.GetErrorFormParams(); if (errorFormParams != null) { message = errorFormParams.Message; } else { try { DataTable dataTable = databaseOperation.ExecuteDataTable(sql); if (dataTable != null) { message = dataTable.Rows[0]["Message"].ToString(); success = true; } } catch (Exception ex) { message = ex.Message; } } return(new DatabaseMessageObject(success, message)); }
public ErrorFormParams RunPostScript(string postScript) { string sql = null; if (postScript != null) { sql = postScript; OutputHandler.WriteToLog("Running Post Script"); } UnattendedForm form = new UnattendedForm(); form.Initialize(_databaseOperation, sql); if (GenericHelper.IsUserInteractive()) { form.ShowDialog(this); } ErrorFormParams errorFormParams = form.GetErrorFormParams(); return(errorFormParams); }
public ErrorFormParams RunPostScriptFile(string postScriptFileName) { string sql = null; if (postScriptFileName != null) { sql = File.ReadAllText(postScriptFileName); OutputHandler.WriteToLog(string.Format("Running Post Script File \"{0}\"", postScriptFileName)); } UnattendedForm form = new UnattendedForm(); form.Initialize(_databaseOperation, sql); if (GenericHelper.IsUserInteractive()) { form.ShowDialog(this); } ErrorFormParams errorFormParams = form.GetErrorFormParams(); return(errorFormParams); }
private void RunWorkerCompleted(ErrorFormParams resultObject) { _errorFormParams = resultObject; Close(); }
private void Worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { ErrorFormParams resultObject = (ErrorFormParams)e.Result; RunWorkerCompleted(resultObject); }