private void ConnectDatabase() { // first check if database can be reached if (this.connectionManager.CheckConnection(this.Name)) { this.Database = new Database( this.Name, DatabaseSetting.GetDatabaseSetting(this.Id).Path, DatabaseSetting.GetDatabaseSetting(this.Id).IgnoredSchemas, this.connectionManager, this.fileSystemAccess, this.processManager, this.differenceCreator, this.sQLFileTester, initializeData: false); this.Error = false; this.ErrorMessage = string.Empty; } else { // could not connect to the database this.ErrorMessage = $"Connection to Database '{this.Name}' cannot be established!"; this.Error = true; } }
private void Disconnect() { this.ExecuteInTask(() => { try { var name = DatabaseSetting.GetDatabaseSetting(this.Id).Name; this.connectionManager.ExecuteCommandNonQuery(SQLTemplates.DisconnectDatabase(name)); } catch (Exception ex) { Log.Error("Exception while executing Action in Task", ex); } }); }
private void CreateDatabase() { new Task(() => { try { var name = DatabaseSetting.GetDatabaseSetting(this.Id).Name; this.connectionManager.ExecuteCommandNonQuery(SQLTemplates.CreateDatabase(name)); // connect to database and update default data this.ConnectDatabase(); this.UpdateData(); // do not remove this, else the edit mode will be finished when something else calls this this.StartImport(); } catch (Exception ex) { Log.Error("Exception while executing Action in Task", ex); } }).Start(); }