mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-02 17:24:50 -05:00
Batch Start Notification (#169)
This change is part of the progressive results code. It will submit a notification from the service layer to indicate when execution of a batch has completed. This notification will contain the selection for batch, execution start time, and its ID. This will enable the extension to produce a header for the batch before the batch completes, in order to make it more clear to the user that execution is going on. * Adding new event for batch start * Unit tests * Fixing comments as per @kevcunnane
This commit is contained in:
@@ -75,7 +75,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
||||
this.outputFileFactory = outputFileFactory;
|
||||
}
|
||||
|
||||
#region Properties
|
||||
#region Events
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronous handler for when batches are completed
|
||||
@@ -88,12 +88,21 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
||||
/// </summary>
|
||||
public event BatchAsyncEventHandler BatchCompletion;
|
||||
|
||||
/// <summary>
|
||||
/// Event to call when the batch has started execution
|
||||
/// </summary>
|
||||
public event BatchAsyncEventHandler BatchStart;
|
||||
|
||||
/// <summary>
|
||||
/// Event that will be called when the resultset has completed execution. It will not be
|
||||
/// called from the Batch but from the ResultSet instance
|
||||
/// </summary>
|
||||
public event ResultSet.ResultSetAsyncEventHandler ResultSetCompletion;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// The text of batch that will be executed
|
||||
/// </summary>
|
||||
@@ -175,17 +184,25 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
||||
{
|
||||
get
|
||||
{
|
||||
return new BatchSummary
|
||||
// Batch summary with information available at start
|
||||
BatchSummary summary = new BatchSummary
|
||||
{
|
||||
HasError = HasError,
|
||||
Id = Id,
|
||||
ResultSetSummaries = ResultSummaries,
|
||||
Messages = ResultMessages.ToArray(),
|
||||
Selection = Selection,
|
||||
ExecutionElapsed = ExecutionElapsedTime,
|
||||
ExecutionStart = ExecutionStartTimeStamp,
|
||||
ExecutionEnd = ExecutionEndTimeStamp
|
||||
ExecutionStart = ExecutionStartTimeStamp
|
||||
};
|
||||
|
||||
// Add on extra details if we finished executing it
|
||||
if (HasExecuted)
|
||||
{
|
||||
summary.ResultSetSummaries = ResultSummaries;
|
||||
summary.Messages = ResultMessages.ToArray();
|
||||
summary.ExecutionEnd = ExecutionEndTimeStamp;
|
||||
summary.ExecutionElapsed = ExecutionElapsedTime;
|
||||
}
|
||||
|
||||
return summary;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,6 +228,12 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
||||
throw new InvalidOperationException("Batch has already executed.");
|
||||
}
|
||||
|
||||
// Notify that we've started execution
|
||||
if (BatchStart != null)
|
||||
{
|
||||
await BatchStart(this);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// Register the message listener to *this instance* of the batch
|
||||
|
||||
Reference in New Issue
Block a user