private async Task ExecuteDebuggerAction(Task debuggerAction) { IsDebuggerControlEnabled = false; var exception = await App.SafeActionAsync(() => debuggerAction); if (ConnectionAdapter.DebuggerSession == null) { IsDebuggerControlVisible = false; SelectDefaultTabIfNeeded(); DocumentPage.Editor.Focus(); } else { await DebuggerViewer.Refresh(_statementExecutionCancellationTokenSource.Token); } IsDebuggerControlEnabled = true; if (exception != null) { Messages.ShowError(exception.Message); } }
private async Task ExecuteDatabaseCommandAsyncInternal(StatementBatchExecutionModel executionModel) { if (executionModel.Statements.Count == 0) { return; } var beforeExecutionText = DocumentPage.Editor.Text; Initialize(); FileResultViewer.Initialize(); ConnectionAdapter.EnableDatabaseOutput = EnableDatabaseOutput; Task <StatementExecutionBatchResult> innerTask = null; var actionResult = await SafeTimedActionAsync(() => innerTask = ConnectionAdapter.ExecuteStatementAsync(executionModel, _statementExecutionCancellationTokenSource.Token)); HasActiveTransaction = ConnectionAdapter.HasActiveTransaction; TransactionIdentifier = ConnectionAdapter.TransanctionIdentifier; if (!actionResult.IsSuccessful) { if (actionResult.Exception is StatementExecutionException executionException) { UpdateExecutionLog(executionException.BatchResult.StatementResults); WriteDatabaseOutput(executionException.BatchResult.DatabaseOutput); var lastStatementResult = executionException.BatchResult.StatementResults.Last(); var errorPosition = lastStatementResult.ErrorPosition; if (errorPosition.HasValue && String.Equals(beforeExecutionText, DocumentPage.Editor.Text)) { DocumentPage.Editor.CaretOffset = lastStatementResult.StatementModel.Statement.RootNode.SourcePosition.IndexStart + errorPosition.Value; } } Messages.ShowError(actionResult.Exception.Message); return; } _executionResult = innerTask.Result; if (ConnectionAdapter.DebuggerSession != null) { DebuggerViewer.Initialize(this, ConnectionAdapter.DebuggerSession); ConnectionAdapter.DebuggerSession.Attached += delegate { Dispatcher.Invoke(DebuggerSessionSynchronizedHandler); }; ConnectionAdapter.DebuggerSession.Detached += DebuggerSessionDetachedHandler; var exception = await App.SafeActionAsync(() => ConnectionAdapter.DebuggerSession.Start(_statementExecutionCancellationTokenSource.Token)); if (exception != null) { Messages.ShowError(exception.Message); } return; } UpdateExecutionLog(_executionResult.StatementResults); UpdateHistoryEntries(); if (_executionResult.StatementResults.Last().ExecutedSuccessfully == false) { NotifyExecutionCanceled(); return; } UpdateTimerMessage(actionResult.Elapsed, false); await DisplayExecutionResult(); }