private void buttonSelectDatabse_Click(object sender, RoutedEventArgs e) { try { // save settings (to pass to the config tool) DBConfigSettings.Settings.ResetSettings(); DBConfigSettings.Settings.IsNewProfile = true; DBConfigSettings.Settings.ServiceHost = ServiceProxy.Services.ServiceHost; DBConfigSettings.Settings.ServicePort = ServiceProxy.Services.ServicePort; DBConfigSettings.Settings.ServiceUsername = UserSettings.Settings.ServiceUsername; DBConfigSettings.Settings.ServicePassword = UserSettings.Settings.ServicePassword; DBConfigSettings.Settings.ServiceDomain = UserSettings.Settings.ServiceDomain; if (this.ClientLogic.ContextCollection != null) { foreach (DisplayContext settings in this.ClientLogic.ContextCollection) { DBConfigSettings.Settings.ExistingProfileFolders.Add(settings.StackHashContextSettings.ErrorIndexSettings.Folder); DBConfigSettings.Settings.ExistingProfileNames.Add(settings.StackHashContextSettings.ErrorIndexSettings.Name); } } DBConfigSettings.Settings.IsDatabaseInCabFolder = _isDatabaseInCabFolder; DBConfigSettings.Settings.ProfileFolder = _pathLocalStore; DBConfigSettings.Settings.ConnectionString = _connectionString; DBConfigSettings.Settings.Save(); Mouse.OverrideCursor = Cursors.Wait; _dbConfigProcess = Process.Start("StackHashDBConfig.exe"); _dbConfigProcess.EnableRaisingEvents = true; _dbConfigProcess.Exited += new EventHandler(_dbConfigProcess_Exited); } catch (Exception ex) { Mouse.OverrideCursor = null; bool userCancel = false; Win32Exception win32ex = ex as Win32Exception; if (win32ex != null) { userCancel = (win32ex.NativeErrorCode == 1223); } if (!userCancel) { DiagnosticsHelper.LogException(DiagSeverity.ComponentFatal, "Failed to launch StackHashDBConfig.exe", ex); StackHashMessageBox.Show(Window.GetWindow(this), Properties.Resources.DBConfigLaunchFailedMBMessage, Properties.Resources.DBConfigLaunchFailedMBTitle, StackHashMessageBoxType.Ok, StackHashMessageBoxIcon.Error, ex, StackHashMessageBox.ParseServiceErrorFromException(ex)); } } }
private void _worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { // do nothing if the window has closed if (_windowClosed) { return; } this.IsEnabled = true; if (e.Error == null) { _reselectContextId = UserSettings.Settings.CurrentContextId; // update the datacontext with the new StackHashStatus object this.DataContext = e.Result; // try to select the current profile //if (!_initialContextSelected) //{ // if (UserSettings.Settings.CurrentContextId != UserSettings.InvalidContextId) // { // StackHashStatus status = e.Result as StackHashStatus; // if ((status != null) && (status.ContextStatusCollection != null)) // { // foreach (StackHashContextStatus contextStatus in status.ContextStatusCollection) // { // if (contextStatus.ContextId == UserSettings.Settings.CurrentContextId) // { // listViewContexts.SelectedItem = contextStatus; // _reselectContextId = contextStatus.ContextId; // _reselectContextIdIsActive = contextStatus.IsActive; // break; // } // } // } // } // _initialContextSelected = true; //} } else { StackHashServiceErrorCode errorCode = StackHashMessageBox.ParseServiceErrorFromException(e.Error); if (errorCode != StackHashServiceErrorCode.Aborted) { // show error StackHashMessageBox.Show(this, Properties.Resources.Error_ServiceCallFailedMBMessage, Properties.Resources.Error_ServiceCallFailedMBTitle, StackHashMessageBoxType.Ok, StackHashMessageBoxIcon.Error, e.Error, errorCode); } } }
private void RunDBConfigForAdd() { _currentAddSettings = _clientLogic.AdminCollectNewContext(); Debug.Assert(_currentAddSettings != null); if (_currentAddSettings != null) { try { Mouse.OverrideCursor = Cursors.Wait; DBConfigSettings.Settings.ResetSettings(); DBConfigSettings.Settings.IsNewProfile = true; DBConfigSettings.Settings.IsUpgrade = false; DBConfigSettings.Settings.ServiceHost = ServiceProxy.Services.ServiceHost; DBConfigSettings.Settings.ServicePort = ServiceProxy.Services.ServicePort; DBConfigSettings.Settings.ServiceUsername = UserSettings.Settings.ServiceUsername; DBConfigSettings.Settings.ServicePassword = UserSettings.Settings.ServicePassword; DBConfigSettings.Settings.ServiceDomain = UserSettings.Settings.ServiceDomain; if (_clientLogic.ContextCollection != null) { foreach (DisplayContext existingSettings in _clientLogic.ContextCollection) { DBConfigSettings.Settings.ExistingProfileFolders.Add(existingSettings.StackHashContextSettings.ErrorIndexSettings.Folder); DBConfigSettings.Settings.ExistingProfileNames.Add(existingSettings.StackHashContextSettings.ErrorIndexSettings.Name); } } DBConfigSettings.Settings.Save(); _dbConfigProcess = Process.Start("StackHashDBConfig.exe"); _dbConfigProcess.EnableRaisingEvents = true; _dbConfigProcess.Exited += new EventHandler(_dbConfigProcess_Exited); } catch (Exception ex) { Mouse.OverrideCursor = null; bool userCancel = false; Win32Exception win32ex = ex as Win32Exception; if (win32ex != null) { userCancel = (win32ex.NativeErrorCode == 1223); } if (userCancel) { // user cancelled DB config DeleteContextCore(_currentAddSettings.Id); _currentAddSettings = null; } else { DiagnosticsHelper.LogException(DiagSeverity.ComponentFatal, "Failed to launch StackHashDBConfig.exe", ex); StackHashMessageBox.Show(this, Properties.Resources.DBConfigLaunchFailedMBMessage, Properties.Resources.DBConfigLaunchFailedMBTitle, StackHashMessageBoxType.Ok, StackHashMessageBoxIcon.Error, ex, StackHashMessageBox.ParseServiceErrorFromException(ex)); } } } }
private void buttonUpgrade_Click(object sender, RoutedEventArgs e) { StackHashContextSettings settings = listBoxProfiles.SelectedItem as StackHashContextSettings; if (settings != null) { try { Mouse.OverrideCursor = Cursors.Wait; DBConfigSettings.Settings.ResetSettings(); DBConfigSettings.Settings.IsNewProfile = true; DBConfigSettings.Settings.IsUpgrade = true; DBConfigSettings.Settings.ServiceHost = ServiceProxy.Services.ServiceHost; DBConfigSettings.Settings.ServicePort = ServiceProxy.Services.ServicePort; DBConfigSettings.Settings.ServiceUsername = UserSettings.Settings.ServiceUsername; DBConfigSettings.Settings.ServicePassword = UserSettings.Settings.ServicePassword; DBConfigSettings.Settings.ServiceDomain = UserSettings.Settings.ServiceDomain; if (_clientLogic.ContextCollection != null) { foreach (DisplayContext existingSettings in _clientLogic.ContextCollection) { DBConfigSettings.Settings.ExistingProfileFolders.Add(existingSettings.StackHashContextSettings.ErrorIndexSettings.Folder); DBConfigSettings.Settings.ExistingProfileNames.Add(existingSettings.StackHashContextSettings.ErrorIndexSettings.Name); } } DBConfigSettings.Settings.ProfileName = settings.ErrorIndexSettings.Name; DBConfigSettings.Settings.ProfileFolder = null; // not populated as user is required to change this DBConfigSettings.Settings.ConnectionString = null; DBConfigSettings.Settings.Save(); _copyContextId = settings.Id; _copyContextIsActive = settings.IsActive; _dbConfigProcess = Process.Start("StackHashDBConfig.exe"); _dbConfigProcess.EnableRaisingEvents = true; _dbConfigProcess.Exited += new EventHandler(_dbConfigProcess_Exited); } catch (Exception ex) { Mouse.OverrideCursor = null; bool userCancel = false; Win32Exception win32ex = ex as Win32Exception; if (win32ex != null) { userCancel = (win32ex.NativeErrorCode == 1223); } if (!userCancel) { DiagnosticsHelper.LogException(DiagSeverity.ComponentFatal, "Failed to launch StackHashDBConfig.exe", ex); StackHashMessageBox.Show(this, Properties.Resources.DBConfigLaunchFailedMBMessage, Properties.Resources.DBConfigLaunchFailedMBTitle, StackHashMessageBoxType.Ok, StackHashMessageBoxIcon.Error, ex, StackHashMessageBox.ParseServiceErrorFromException(ex)); } } } }