/// <summary> /// Connect to Oracle /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void ConnectToOracle_OnExecuted(object sender, ExecutedRoutedEventArgs e) { await DiagramFacade.CloseDiagramsOnDisconnect(this); SessionProvider.Instance.Disconnect(); DatabaseConnectionSidebar.HideDatabaseStackPanels(); ProgressDialogController progressDialogController = null; Func <ProgressDialogController, Task> closeProgress = async t => { if (t != null) { if (t.IsOpen) { await t.CloseAsync(); } } }; try { progressDialogController = await this.ShowProgressAsync("Please wait", "Connecting to server...", false, new MetroDialogSettings() { AnimateShow = false, AnimateHide = false }); progressDialogController.SetIndeterminate(); var db = new OracleDatabase(); await db.BuildSession(OracleServerNameTextBox.Text, OraclePortTextBox.Text, OracleSidTextBox.Text, OracleUsernameTextBox.Text, OraclePasswordBox.Password); //Init work await Task.Factory.StartNew(() => { using (IOracleMapper mapper = new OracleMapper()) { TableModel model = mapper.ListTables().FirstOrDefault(); if (model != null) { mapper.ListForeignKeys(model.Title); } } }); await closeProgress(progressDialogController); await this.ShowMessageAsync("Connected", $"Successfuly connected to {SessionProvider.Instance.ServerName}"); var flyout = Flyouts.Items[2] as Flyout; if (flyout != null) { flyout.IsOpen = !flyout.IsOpen; } await DatabaseConnectionSidebar.LoadOracleData(); } catch (OracleException exception) { await closeProgress(progressDialogController); await this.ShowMessageAsync("Connection error", exception.Message); Output.WriteLine(OutputPanelListener.PrepareException(exception.Message)); SessionProvider.Instance.ConnectionType = ConnectionType.None; } }