public void Initialize(DatabaseOperation databaseOperation, List <ImportTraceFileInfo> importTraceFileInfoList) { InitializeDictionary(); timeTextBox.GotFocus += TimeTextBox_GotFocus; progressBar1.Value = 0; elapsedTimeTimer.Start(); _sw.Reset(); _sw.Start(); RunWorkerArgument arg = new RunWorkerArgument(); arg.DatabaseOperation = databaseOperation; arg.ImportTraceFileInfoList = importTraceFileInfoList; if (GenericHelper.IsUserInteractive()) { InitializeWorker(); _worker.RunWorkerAsync(arg); } else { RunWorkerCompleted(DoWork(arg)); } }
private void DoWork(RunWorkerArgument arg) { string connectionString = arg.ConnectionString; if (_databaseOperation == null) // new connection, no connection has been made { _databaseOperation = new DatabaseOperation(); _databaseOperation.InitializeDal(connectionString); } else // a connection has already been made, but should be changed { ConnectionChanged = _databaseOperation.ChangeConnection(connectionString); } if (_databaseOperation.Connected) { ConnectionChanged = true; } else { ConnectionChanged = false; } if (ConnectionChanged) { ConfigHandler.ConnectionString = connectionString; } if (saveValuesCheckBox.Checked && ConnectionChanged) { ConfigHandler.ConnectionStringToSave = connectionString; ConfigHandler.SaveConnection(); } }
public void OkButtonClick() { if (ModifierKeys == Keys.Shift) { ShiftPressed = true; } if (saveValuesCheckBox.Checked) { ConfigHandler.SaveConnection(); } if (saveValuesCheckBox.Checked) { ConfigHandler.SaveConnectionString = "True"; } else { ConfigHandler.SaveConnectionString = "False"; } if (ConfigHandler.RegistryModifyAccess) { RegistryHandler.SaveToRegistry("SaveConnectionString", ConfigHandler.SaveConnectionString); } if (!VerifyFields()) { return; } BeginConnect(); RunWorkerArgument arg = new RunWorkerArgument(); arg.ConnectionString = GetConnectionString(); _runWorkerActive = true; if (GenericHelper.IsUserInteractive()) { _worker.RunWorkerAsync(arg); } else { DoWork(arg); RunWorkerCompleted(); } }
public void Initialize(DatabaseOperation databaseOperation, IWin32Window owner, DatabaseOperation previousConnection, bool shiftPressed, bool manuallyUseSession, string previousSessionId) { InitializeDictionary(); Text = GenericHelper.ApplicationName; _showHandleCLRFormInTaskBar = false; _shiftPressed = shiftPressed; _manuallyUseSession = manuallyUseSession; RunWorkerArgument arg = new RunWorkerArgument(databaseOperation, previousConnection, previousSessionId); InitializeWorker(); _worker.RunWorkerAsync(arg); ShowDialog(owner); }
private void OkButton_Click(object sender, System.EventArgs e) { if (!VerifyFields()) { return; } BeginConnect(); RunWorkerArgument arg = new RunWorkerArgument(); arg.ConnectionString = GetConnectionString(); _runWorkerActive = true; _worker.RunWorkerAsync(arg); }
private void OkButton_Click(object sender, EventArgs e) { _okButtonClicked = true; if (Convert.ToBoolean(ConfigHandler.OfflineMode) != offlineCheckBox.Checked) { ConnectionChanged = true; } if (offlineCheckBox.Checked) { ConfigHandler.OfflineMode = "True"; } else { ConfigHandler.OfflineMode = "False"; } if (saveValuesCheckBox.Checked) { ConfigHandler.OfflineModeToSave = ConfigHandler.OfflineMode; ConfigHandler.SaveConnection(); } if (offlineCheckBox.Checked) { Close(); } else { ConfigHandler.OfflineMode = "False"; GenericHelper.ShowErrorMessageForm = true; if (!VerifyFields()) { return; } BeginConnect(); RunWorkerArgument arg = new RunWorkerArgument(); arg.ConnectionString = GetConnectionString(); _runWorkerActive = true; _worker.RunWorkerAsync(arg); } }
public void Initialize(DatabaseOperation databaseOperation, IWin32Window owner) { InitializeDictionary(); Text = GenericHelper.ApplicationName; _showHandleCLRFormInTaskBar = true; RunWorkerArgument arg = new RunWorkerArgument(databaseOperation, null, GenericHelper.GetSessionIdFromTableName()); if (GenericHelper.IsUserInteractive()) { InitializeWorker(); _worker.RunWorkerAsync(arg); ShowDialog(owner); } else { DoWork(arg); RunWorkerCompleted(); } }
private void DoWork(RunWorkerArgument arg) { if (arg.PreviousConnection != null) { if (ConfigHandler.EnableCLRTemporary) { arg.PreviousConnection.DisableCLR(); } if (!_shiftPressed && !ConfigHandler.KeepSessionOnExit) { if (!_manuallyUseSession || (_manuallyUseSession && GenericHelper.ConfirmDropTempTable(arg.SessionnId))) { arg.PreviousConnection.DropTempTable(string.Format("TraceData_{0}", arg.SessionnId.Replace("'", "''"))); } } } DatabaseOperation databaseOperation = arg.DatabaseOperation; bool enableCLR = HandleCLREnabled(databaseOperation); if (enableCLR) { databaseOperation.HandleCLR(); } GenericHelper.SqlServerName = databaseOperation.GetSqlServerName(); GenericHelper.SqlServerVersion = databaseOperation.GetSqlServerVersion(); databaseOperation.InitializeDatabaseActions(); if (enableCLR) { databaseOperation.DeployCLR(); } ConfigHandler.ClrDeployed = databaseOperation.IsCLREnabled(); ConfigHandler.SetRecordTraceFileDirectory(databaseOperation); }
private void Worker_DoWork(object sender, DoWorkEventArgs e) { RunWorkerArgument arg = (RunWorkerArgument)e.Argument; string connectionString = arg.ConnectionString; if (_databaseOperation == null) // new connection, no connection has been made { _databaseOperation = new DatabaseOperation(connectionString); } else // a connection has already been made, but should be changed { ConnectionChanged = _databaseOperation.ChangeConnection(connectionString); } if (_databaseOperation.Connected) { ConnectionChanged = true; } if (!saveValuesCheckBox.Checked) { ConfigHandler.SaveConnectionString = "false"; ConfigHandler.SaveConfig(); } if (ConnectionChanged) { ConfigHandler.ConnectionString = connectionString; } if (saveValuesCheckBox.Checked && ConnectionChanged) { ConfigHandler.ConnectionStringToSave = connectionString; ConfigHandler.SaveConnectionString = "true"; ConfigHandler.SaveConfig(); } }
private void BackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { RunWorkerArgument arg = (RunWorkerArgument)e.Argument; for (int run = 1; run <= arg.Runs; run++) { if (!_backgroundWorker.CancellationPending) { _backgroundWorker.ReportProgress(-1, run); RunTest(run); if (!_backgroundWorker.CancellationPending && run < arg.Runs && arg.Delay > 0) { GenericHelper.Sleep(arg.Delay); } } } if (_backgroundWorker.CancellationPending) { e.Cancel = true; } }
private void Start() { if (CheckAndSaveValues()) { runProgressBar.Maximum = Convert.ToInt32(runsTextBox.Text); runProgressBar.Value = 0; timeElapsedLabel.Text = "00:00:00"; _running = true; DisableItems(); startButton.Text = "Stop"; statusLabel.Text = "Running..."; executionTimeTimer.Start(); _sw.Reset(); _sw.Start(); RunWorkerArgument arg = new RunWorkerArgument(); arg.Runs = Convert.ToInt32(runsTextBox.Text); arg.Delay = Convert.ToInt32(timeBetweenRunsTextBox.Text); _backgroundWorker.RunWorkerAsync(arg); } }
private bool DoWork(RunWorkerArgument arg) { if (GenericHelper.IsUserInteractive()) { if (ConfigHandler.UseTranslation) { _worker.ReportProgress(-2, Translator.GetText("preparing")); } else { _worker.ReportProgress(-2, "Preparing..."); } } arg.DatabaseOperation.CreateTempTable(); ConfigHandler.TempTableCreated = true; if (GenericHelper.IsUserInteractive()) { if (ConfigHandler.UseTranslation) { _worker.ReportProgress(-2, Translator.GetText("importingFiles")); } else { _worker.ReportProgress(-2, "Importing file(s)..."); } } OutputHandler.WriteToLog("Importing file(s)..."); arg.DatabaseOperation.DisableColumnStoreIndex(); arg.DatabaseOperation.StopFullTextPopulation(); bool success = true; for (int i = 0; i < arg.ImportTraceFileInfoList.Count; i++) { if (GenericHelper.IsUserInteractive()) { _worker.ReportProgress(-1, new ProgressObject(i + 1, arg.ImportTraceFileInfoList.Count, arg.ImportTraceFileInfoList[i])); } OutputHandler.WriteToLog(string.Format("{0}/{1} ({2} - {3})", i + 1, arg.ImportTraceFileInfoList.Count, Path.GetFileName(arg.ImportTraceFileInfoList[i].FileName), GetSizeValue(arg.ImportTraceFileInfoList[i].FileSize))); success = TraceFileHandler.ImportTraceFile(arg.DatabaseOperation, arg.ImportTraceFileInfoList[i].FileName); if (!success) { break; } } if (success) { OutputHandler.WriteToLog("Importing file(s): Completed"); } if (GenericHelper.IsUserInteractive()) { if (ConfigHandler.UseTranslation) { _worker.ReportProgress(-2, Translator.GetText("creatingIndexes")); } else { _worker.ReportProgress(-2, "Creating indexes..."); } } OutputHandler.WriteToLog("Creating indexes..."); arg.DatabaseOperation.CreateIndexes(); if (GenericHelper.IsUserInteractive()) { if (ConfigHandler.UseTranslation) { _worker.ReportProgress(-2, Translator.GetText("populatingFullText")); } else { _worker.ReportProgress(-2, "Populating full text catalog..."); } } OutputHandler.WriteToLog("Populating full text catalog..."); arg.DatabaseOperation.StartFullTextPopulation(); return(success); }
private void Worker_DoWork(object sender, DoWorkEventArgs e) { RunWorkerArgument arg = (RunWorkerArgument)e.Argument; e.Result = DoWork(arg); }
private bool DoWork(RunWorkerArgument arg) { if (GenericHelper.IsUserInteractive()) { if (ConfigHandler.UseTranslation) { _worker.ReportProgress(-2, Translator.GetText("importingSessions")); } else { _worker.ReportProgress(-2, "Importing session(s)..."); } } OutputHandler.WriteToLog("Importing session(s)..."); arg.DatabaseOperation.DisableColumnStoreIndex(); arg.DatabaseOperation.StopFullTextPopulation(); bool success = false; for (int i = 0; i < arg.ImportSessionInfoList.Count; i++) { if (GenericHelper.IsUserInteractive()) { _worker.ReportProgress(-1, new ProgressObject(i + 1, arg.ImportSessionInfoList.Count, arg.ImportSessionInfoList[i])); } List <string> nonDefaultColumns = GetNonDefaultColumns(arg.DatabaseOperation, arg.ImportSessionInfoList[i].SessionId); success = SessionHandler.ImportSession(arg.DatabaseOperation, arg.ImportSessionInfoList[i].SessionId, nonDefaultColumns); if (!success) { break; } } if (success) { OutputHandler.WriteToLog("Importing session(s): Completed"); } if (!ConfigHandler.TempTableCreated) { if (GenericHelper.IsUserInteractive()) { if (ConfigHandler.UseTranslation) { _worker.ReportProgress(-2, Translator.GetText("creatingIndexes")); } else { _worker.ReportProgress(-2, "Creating indexes..."); } } OutputHandler.WriteToLog("Creating indexes..."); arg.DatabaseOperation.CreateIndexes(); ConfigHandler.TempTableCreated = true; } if (arg.DatabaseOperation.GetSqlServerVersion() >= 11 && arg.DatabaseOperation.IsColumnStoreSupported()) { if (GenericHelper.IsUserInteractive()) { if (ConfigHandler.UseTranslation) { _worker.ReportProgress(-2, Translator.GetText("enableColumnStoreIndex")); } else { _worker.ReportProgress(-2, "Creating Column Store Index..."); } } OutputHandler.WriteToLog("Creating Column Store Index..."); arg.DatabaseOperation.EnableColumnStoreIndex(); OutputHandler.WriteToLog("Creating Column Store Index: Completed"); } if (GenericHelper.IsUserInteractive()) { if (ConfigHandler.UseTranslation) { _worker.ReportProgress(-2, Translator.GetText("populatingFullText")); } else { _worker.ReportProgress(-2, "Populating full text catalog..."); } } OutputHandler.WriteToLog("Populating full text catalog..."); arg.DatabaseOperation.StartFullTextPopulation(); return(success); }