mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 10:58:30 -05:00
Returning start/end and elapsed time with batch summaries (#92)
Returning start/end and elapsed timestamps for batches with the batch summary.
This commit is contained in:
@@ -30,6 +30,16 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private bool disposed;
|
private bool disposed;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Local time when the execution and retrieval of files is finished
|
||||||
|
/// </summary>
|
||||||
|
private DateTime executionEndTime;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Local time when the execution starts, specifically when the object is created
|
||||||
|
/// </summary>
|
||||||
|
private readonly DateTime executionStartTime;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Factory for creating readers/writers for the output of the batch
|
/// Factory for creating readers/writers for the output of the batch
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -55,6 +65,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
|||||||
|
|
||||||
// Initialize the internal state
|
// Initialize the internal state
|
||||||
BatchText = batchText;
|
BatchText = batchText;
|
||||||
|
executionStartTime = DateTime.Now;
|
||||||
Selection = new SelectionData(startLine, startColumn, endLine, endColumn);
|
Selection = new SelectionData(startLine, startColumn, endLine, endColumn);
|
||||||
HasExecuted = false;
|
HasExecuted = false;
|
||||||
resultSets = new List<ResultSet>();
|
resultSets = new List<ResultSet>();
|
||||||
@@ -69,6 +80,30 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string BatchText { get; set; }
|
public string BatchText { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Localized timestamp for when the execution completed.
|
||||||
|
/// Stored in UTC ISO 8601 format; should be localized before displaying to any user
|
||||||
|
/// </summary>
|
||||||
|
public string ExecutionEndTimeStamp { get { return executionEndTime.ToString("o"); } }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Localized timestamp for how long it took for the execution to complete
|
||||||
|
/// </summary>
|
||||||
|
public string ExecutionElapsedTime
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
TimeSpan elapsedTime = executionEndTime - executionStartTime;
|
||||||
|
return elapsedTime.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Localized timestamp for when the execution began.
|
||||||
|
/// Stored in UTC ISO 8601 format; should be localized before displaying to any user
|
||||||
|
/// </summary>
|
||||||
|
public string ExecutionStartTimeStamp { get { return executionStartTime.ToString("o"); } }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether or not this batch has an error
|
/// Whether or not this batch has an error
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -218,6 +253,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
|||||||
|
|
||||||
// Mark that we have executed
|
// Mark that we have executed
|
||||||
HasExecuted = true;
|
HasExecuted = true;
|
||||||
|
executionEndTime = DateTime.Now;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,21 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class BatchSummary
|
public class BatchSummary
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Localized timestamp for how long it took for the execution to complete
|
||||||
|
/// </summary>
|
||||||
|
public string ExecutionElapsed { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Localized timestamp for when the execution completed.
|
||||||
|
/// </summary>
|
||||||
|
public string ExecutionEnd { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Localized timestamp for when the execution started.
|
||||||
|
/// </summary>
|
||||||
|
public string ExecutionStart { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether or not the batch was successful. True indicates errors, false indicates success
|
/// Whether or not the batch was successful. True indicates errors, false indicates success
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -132,6 +132,9 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
|||||||
return Batches.Select((batch, index) => new BatchSummary
|
return Batches.Select((batch, index) => new BatchSummary
|
||||||
{
|
{
|
||||||
Id = index,
|
Id = index,
|
||||||
|
ExecutionStart = batch.ExecutionStartTimeStamp,
|
||||||
|
ExecutionEnd = batch.ExecutionEndTimeStamp,
|
||||||
|
ExecutionElapsed = batch.ExecutionElapsedTime,
|
||||||
HasError = batch.HasError,
|
HasError = batch.HasError,
|
||||||
Messages = batch.ResultMessages.ToArray(),
|
Messages = batch.ResultMessages.ToArray(),
|
||||||
ResultSetSummaries = batch.ResultSummaries,
|
ResultSetSummaries = batch.ResultSummaries,
|
||||||
|
|||||||
Reference in New Issue
Block a user