Archived
Removing a lot of redundant async/await wrappers (#1486)
* Removing a lot of redundant async/await wrappers * Removing kusto changes
This commit is contained in:
@@ -12,7 +12,7 @@ namespace Microsoft.InsightsGenerator
|
|||||||
public class Workflow
|
public class Workflow
|
||||||
{
|
{
|
||||||
|
|
||||||
public async Task<string> ProcessInputData(DataArray rulesData,
|
public Task<string> ProcessInputData(DataArray rulesData,
|
||||||
CancellationToken cancellationToken = new CancellationToken())
|
CancellationToken cancellationToken = new CancellationToken())
|
||||||
{
|
{
|
||||||
// added cancellationToken just in case for future
|
// added cancellationToken just in case for future
|
||||||
@@ -21,9 +21,7 @@ namespace Microsoft.InsightsGenerator
|
|||||||
//Get the signature result
|
//Get the signature result
|
||||||
SignatureGenerator siggen = new SignatureGenerator(rulesData);
|
SignatureGenerator siggen = new SignatureGenerator(rulesData);
|
||||||
|
|
||||||
string insights = null;
|
return Task.Run(() =>
|
||||||
|
|
||||||
await Task.Run(() =>
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -31,6 +29,8 @@ namespace Microsoft.InsightsGenerator
|
|||||||
transformer.Transform(rulesData);
|
transformer.Transform(rulesData);
|
||||||
SignatureGeneratorResult result = siggen.Learn();
|
SignatureGeneratorResult result = siggen.Learn();
|
||||||
// call the rules engine processor
|
// call the rules engine processor
|
||||||
|
|
||||||
|
string insights = null;
|
||||||
if (result?.Insights == null)
|
if (result?.Insights == null)
|
||||||
{
|
{
|
||||||
// Console.WriteLine("Failure in generating insights, Input not recognized!");
|
// Console.WriteLine("Failure in generating insights, Input not recognized!");
|
||||||
@@ -42,6 +42,7 @@ namespace Microsoft.InsightsGenerator
|
|||||||
// $"Good News! Insights generator has provided you the chart text: \n{insights}\n");
|
// $"Good News! Insights generator has provided you the chart text: \n{insights}\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return insights;
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
@@ -50,8 +51,6 @@ namespace Microsoft.InsightsGenerator
|
|||||||
}
|
}
|
||||||
|
|
||||||
}, cancellationToken);
|
}, cancellationToken);
|
||||||
|
|
||||||
return insights;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,12 +102,9 @@ namespace Microsoft.SqlTools.Credentials
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public async Task<Credential> ReadCredentialAsync(Credential credential)
|
public Task<Credential> ReadCredentialAsync(Credential credential)
|
||||||
{
|
{
|
||||||
return await Task.Factory.StartNew(() =>
|
return Task.Run(() => ReadCredential(credential));
|
||||||
{
|
|
||||||
return ReadCredential(credential);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Credential ReadCredential(Credential credential)
|
public Credential ReadCredential(Credential credential)
|
||||||
@@ -132,12 +129,9 @@ namespace Microsoft.SqlTools.Credentials
|
|||||||
await HandleRequest(doSave, requestContext, "HandleSaveCredentialRequest");
|
await HandleRequest(doSave, requestContext, "HandleSaveCredentialRequest");
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> SaveCredentialAsync(Credential credential)
|
public Task<bool> SaveCredentialAsync(Credential credential)
|
||||||
{
|
{
|
||||||
return await Task.Factory.StartNew(() =>
|
return Task.Run(() => SaveCredential(credential));
|
||||||
{
|
|
||||||
return SaveCredential(credential);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool SaveCredential(Credential credential)
|
public bool SaveCredential(Credential credential)
|
||||||
@@ -155,9 +149,9 @@ namespace Microsoft.SqlTools.Credentials
|
|||||||
await HandleRequest(doDelete, requestContext, "HandleDeleteCredentialRequest");
|
await HandleRequest(doDelete, requestContext, "HandleDeleteCredentialRequest");
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<bool> DeletePasswordAsync(Credential credential)
|
private Task<bool> DeletePasswordAsync(Credential credential)
|
||||||
{
|
{
|
||||||
return await Task.Factory.StartNew(() =>
|
return Task.Run(() =>
|
||||||
{
|
{
|
||||||
Credential.ValidateForLookup(credential);
|
Credential.ValidateForLookup(credential);
|
||||||
return credStore.DeletePassword(credential.CredentialId);
|
return credStore.DeletePassword(credential.CredentialId);
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -238,7 +238,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ownerUri">The URI of the connection</param>
|
/// <param name="ownerUri">The URI of the connection</param>
|
||||||
/// <returns> True if a refreshed was needed and requested, false otherwise </returns>
|
/// <returns> True if a refreshed was needed and requested, false otherwise </returns>
|
||||||
|
|
||||||
internal async Task<bool> TryRequestRefreshAuthToken(string ownerUri)
|
internal async Task<bool> TryRequestRefreshAuthToken(string ownerUri)
|
||||||
{
|
{
|
||||||
ConnectionInfo connInfo;
|
ConnectionInfo connInfo;
|
||||||
@@ -312,6 +311,12 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
|
|||||||
connection.UpdateAuthToken(tokenRefreshedParams.Token, tokenRefreshedParams.ExpiresOn);
|
connection.UpdateAuthToken(tokenRefreshedParams.Token, tokenRefreshedParams.ExpiresOn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Validates the given ConnectParams object.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="connectionParams">The params to validate</param>
|
||||||
|
/// <returns>A ConnectionCompleteParams object upon validation error,
|
||||||
|
/// null upon validation success</returns>
|
||||||
public ConnectionCompleteParams ValidateConnectParams(ConnectParams connectionParams)
|
public ConnectionCompleteParams ValidateConnectParams(ConnectParams connectionParams)
|
||||||
{
|
{
|
||||||
string paramValidationErrorMessage;
|
string paramValidationErrorMessage;
|
||||||
@@ -1395,42 +1400,39 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
|
|||||||
GetConnectionStringParams connStringParams,
|
GetConnectionStringParams connStringParams,
|
||||||
RequestContext<string> requestContext)
|
RequestContext<string> requestContext)
|
||||||
{
|
{
|
||||||
await Task.Run(async () =>
|
string connectionString = string.Empty;
|
||||||
|
ConnectionInfo info;
|
||||||
|
SqlConnectionStringBuilder connStringBuilder;
|
||||||
|
try
|
||||||
{
|
{
|
||||||
string connectionString = string.Empty;
|
// set connection string using connection uri if connection details are undefined
|
||||||
ConnectionInfo info;
|
if (connStringParams.ConnectionDetails == null)
|
||||||
SqlConnectionStringBuilder connStringBuilder;
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
// set connection string using connection uri if connection details are undefined
|
TryFindConnection(connStringParams.OwnerUri, out info);
|
||||||
if (connStringParams.ConnectionDetails == null)
|
connStringBuilder = CreateConnectionStringBuilder(info.ConnectionDetails);
|
||||||
{
|
|
||||||
TryFindConnection(connStringParams.OwnerUri, out info);
|
|
||||||
connStringBuilder = CreateConnectionStringBuilder(info.ConnectionDetails);
|
|
||||||
}
|
|
||||||
// set connection string using connection details
|
|
||||||
else
|
|
||||||
{
|
|
||||||
connStringBuilder = CreateConnectionStringBuilder(connStringParams.ConnectionDetails as ConnectionDetails);
|
|
||||||
}
|
|
||||||
if (!connStringParams.IncludePassword)
|
|
||||||
{
|
|
||||||
connStringBuilder.Password = ConnectionService.PasswordPlaceholder;
|
|
||||||
}
|
|
||||||
// default connection string application name to always be included unless set to false
|
|
||||||
if (!connStringParams.IncludeApplicationName.HasValue || connStringParams.IncludeApplicationName.Value == true)
|
|
||||||
{
|
|
||||||
connStringBuilder.ApplicationName = "sqlops-connection-string";
|
|
||||||
}
|
|
||||||
connectionString = connStringBuilder.ConnectionString;
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
// set connection string using connection details
|
||||||
|
else
|
||||||
{
|
{
|
||||||
await requestContext.SendError(e.ToString());
|
connStringBuilder = CreateConnectionStringBuilder(connStringParams.ConnectionDetails as ConnectionDetails);
|
||||||
}
|
}
|
||||||
|
if (!connStringParams.IncludePassword)
|
||||||
|
{
|
||||||
|
connStringBuilder.Password = ConnectionService.PasswordPlaceholder;
|
||||||
|
}
|
||||||
|
// default connection string application name to always be included unless set to false
|
||||||
|
if (!connStringParams.IncludeApplicationName.HasValue || connStringParams.IncludeApplicationName.Value == true)
|
||||||
|
{
|
||||||
|
connStringBuilder.ApplicationName = "sqlops-connection-string";
|
||||||
|
}
|
||||||
|
connectionString = connStringBuilder.ConnectionString;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
await requestContext.SendError(e.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
await requestContext.SendResult(connectionString);
|
await requestContext.SendResult(connectionString);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -1440,19 +1442,16 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
|
|||||||
string connectionString,
|
string connectionString,
|
||||||
RequestContext<ConnectionDetails> requestContext)
|
RequestContext<ConnectionDetails> requestContext)
|
||||||
{
|
{
|
||||||
await Task.Run(async () =>
|
try
|
||||||
{
|
{
|
||||||
try
|
await requestContext.SendResult(ParseConnectionString(connectionString));
|
||||||
{
|
}
|
||||||
await requestContext.SendResult(ParseConnectionString(connectionString));
|
catch (Exception)
|
||||||
}
|
{
|
||||||
catch (Exception)
|
// If theres an error in the parse, it means we just can't parse, so we return undefined
|
||||||
{
|
// rather than an error.
|
||||||
// If theres an error in the parse, it means we just can't parse, so we return undefined
|
await requestContext.SendResult(null);
|
||||||
// rather than an error.
|
}
|
||||||
await requestContext.SendResult(null);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConnectionDetails ParseConnectionString(string connectionString)
|
public ConnectionDetails ParseConnectionString(string connectionString)
|
||||||
|
|||||||
@@ -110,9 +110,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Formatter
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<TextEdit[]> FormatRangeAndReturnEdits(DocumentRangeFormattingParams docFormatParams)
|
private Task<TextEdit[]> FormatRangeAndReturnEdits(DocumentRangeFormattingParams docFormatParams)
|
||||||
{
|
{
|
||||||
return await Task.Factory.StartNew(() =>
|
return Task.Run(() =>
|
||||||
{
|
{
|
||||||
if (ShouldSkipFormatting(docFormatParams))
|
if (ShouldSkipFormatting(docFormatParams))
|
||||||
{
|
{
|
||||||
@@ -123,7 +123,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Formatter
|
|||||||
ScriptFile scriptFile = GetFile(docFormatParams);
|
ScriptFile scriptFile = GetFile(docFormatParams);
|
||||||
if (scriptFile == null)
|
if (scriptFile == null)
|
||||||
{
|
{
|
||||||
return new TextEdit[0];
|
return Array.Empty<TextEdit>();
|
||||||
}
|
}
|
||||||
TextEdit textEdit = new TextEdit { Range = range };
|
TextEdit textEdit = new TextEdit { Range = range };
|
||||||
string text = scriptFile.GetTextInRange(range.ToBufferRange());
|
string text = scriptFile.GetTextInRange(range.ToBufferRange());
|
||||||
@@ -142,9 +142,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Formatter
|
|||||||
return (LanguageService != null && LanguageService.ShouldSkipNonMssqlFile(docFormatParams.TextDocument.Uri));
|
return (LanguageService != null && LanguageService.ShouldSkipNonMssqlFile(docFormatParams.TextDocument.Uri));
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<TextEdit[]> FormatAndReturnEdits(DocumentFormattingParams docFormatParams)
|
private Task<TextEdit[]> FormatAndReturnEdits(DocumentFormattingParams docFormatParams)
|
||||||
{
|
{
|
||||||
return await Task.Factory.StartNew(() =>
|
return Task.Factory.StartNew(() =>
|
||||||
{
|
{
|
||||||
if (ShouldSkipFormatting(docFormatParams))
|
if (ShouldSkipFormatting(docFormatParams))
|
||||||
{
|
{
|
||||||
@@ -155,7 +155,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Formatter
|
|||||||
if (scriptFile == null
|
if (scriptFile == null
|
||||||
|| scriptFile.FileLines.Count == 0)
|
|| scriptFile.FileLines.Count == 0)
|
||||||
{
|
{
|
||||||
return new TextEdit[0];
|
return Array.Empty<TextEdit>();
|
||||||
}
|
}
|
||||||
TextEdit textEdit = PrepareEdit(scriptFile);
|
TextEdit textEdit = PrepareEdit(scriptFile);
|
||||||
string text = scriptFile.Contents;
|
string text = scriptFile.Contents;
|
||||||
|
|||||||
@@ -201,10 +201,10 @@ namespace Microsoft.SqlTools.ServiceLayer
|
|||||||
IDisposable disposable = service as IDisposable;
|
IDisposable disposable = service as IDisposable;
|
||||||
if (serviceHost != null && disposable != null)
|
if (serviceHost != null && disposable != null)
|
||||||
{
|
{
|
||||||
serviceHost.RegisterShutdownTask(async (shutdownParams, shutdownRequestContext) =>
|
serviceHost.RegisterShutdownTask((_, _) =>
|
||||||
{
|
{
|
||||||
disposable.Dispose();
|
disposable.Dispose();
|
||||||
await Task.FromResult(0);
|
return Task.FromResult(0);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -270,12 +270,12 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
|||||||
serviceHost.SetEventHandler(TokenRefreshedNotification.Type, HandleTokenRefreshedNotification);
|
serviceHost.SetEventHandler(TokenRefreshedNotification.Type, HandleTokenRefreshedNotification);
|
||||||
|
|
||||||
// Register a no-op shutdown task for validation of the shutdown logic
|
// Register a no-op shutdown task for validation of the shutdown logic
|
||||||
serviceHost.RegisterShutdownTask(async (shutdownParams, shutdownRequestContext) =>
|
serviceHost.RegisterShutdownTask((shutdownParams, shutdownRequestContext) =>
|
||||||
{
|
{
|
||||||
Logger.Write(TraceEventType.Verbose, "Shutting down language service");
|
Logger.Write(TraceEventType.Verbose, "Shutting down language service");
|
||||||
DeletePeekDefinitionScripts();
|
DeletePeekDefinitionScripts();
|
||||||
this.Dispose();
|
this.Dispose();
|
||||||
await Task.FromResult(0);
|
return Task.FromResult(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
ServiceHostInstance = serviceHost;
|
ServiceHostInstance = serviceHost;
|
||||||
@@ -399,33 +399,30 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
internal async Task HandleSyntaxParseRequest(SyntaxParseParams param, RequestContext<SyntaxParseResult> requestContext)
|
internal async Task HandleSyntaxParseRequest(SyntaxParseParams param, RequestContext<SyntaxParseResult> requestContext)
|
||||||
{
|
{
|
||||||
await Task.Run(async () =>
|
try
|
||||||
{
|
{
|
||||||
try
|
ParseResult result = Parser.Parse(param.Query);
|
||||||
|
SyntaxParseResult syntaxResult = new SyntaxParseResult();
|
||||||
|
if (result != null && !result.Errors.Any())
|
||||||
{
|
{
|
||||||
ParseResult result = Parser.Parse(param.Query);
|
syntaxResult.Parseable = true;
|
||||||
SyntaxParseResult syntaxResult = new SyntaxParseResult();
|
|
||||||
if (result != null && result.Errors.Count() == 0)
|
|
||||||
{
|
|
||||||
syntaxResult.Parseable = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
syntaxResult.Parseable = false;
|
|
||||||
string[] errorMessages = new string[result.Errors.Count()];
|
|
||||||
for (int i = 0; i < result.Errors.Count(); i++)
|
|
||||||
{
|
|
||||||
errorMessages[i] = result.Errors.ElementAt(i).Message;
|
|
||||||
}
|
|
||||||
syntaxResult.Errors = errorMessages;
|
|
||||||
}
|
|
||||||
await requestContext.SendResult(syntaxResult);
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
else
|
||||||
{
|
{
|
||||||
await requestContext.SendError(ex.ToString());
|
syntaxResult.Parseable = false;
|
||||||
|
string[] errorMessages = new string[result.Errors.Count()];
|
||||||
|
for (int i = 0; i < result.Errors.Count(); i++)
|
||||||
|
{
|
||||||
|
errorMessages[i] = result.Errors.ElementAt(i).Message;
|
||||||
|
}
|
||||||
|
syntaxResult.Errors = errorMessages;
|
||||||
}
|
}
|
||||||
});
|
await requestContext.SendResult(syntaxResult);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await requestContext.SendError(ex.ToString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -674,8 +671,6 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
|||||||
new ScriptFile[] { scriptFile },
|
new ScriptFile[] { scriptFile },
|
||||||
eventContext);
|
eventContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
await Task.FromResult(true);
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -700,8 +695,6 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
|||||||
changedFiles.ToArray(),
|
changedFiles.ToArray(),
|
||||||
eventContext);
|
eventContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
await Task.FromResult(true);
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -933,13 +926,13 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
|||||||
/// it is the last URI connected to a particular connection,
|
/// it is the last URI connected to a particular connection,
|
||||||
/// then remove the cache.
|
/// then remove the cache.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public async Task RemoveAutoCompleteCacheUriReference(IConnectionSummary summary, string ownerUri)
|
public Task RemoveAutoCompleteCacheUriReference(IConnectionSummary summary, string ownerUri)
|
||||||
{
|
{
|
||||||
RemoveScriptParseInfo(ownerUri);
|
RemoveScriptParseInfo(ownerUri);
|
||||||
|
|
||||||
// currently this method is disabled, but we need to reimplement now that the
|
// currently this method is disabled, but we need to reimplement now that the
|
||||||
// implementation of the 'cache' has changed.
|
// implementation of the 'cache' has changed.
|
||||||
await Task.FromResult(0);
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -1049,9 +1042,9 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
|||||||
/// Update the autocomplete metadata provider when the user connects to a database
|
/// Update the autocomplete metadata provider when the user connects to a database
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="info"></param>
|
/// <param name="info"></param>
|
||||||
public async Task UpdateLanguageServiceOnConnection(ConnectionInfo info)
|
public Task UpdateLanguageServiceOnConnection(ConnectionInfo info)
|
||||||
{
|
{
|
||||||
await Task.Run(() =>
|
return Task.Run(() =>
|
||||||
{
|
{
|
||||||
if (ConnectionService.IsDedicatedAdminConnection(info.ConnectionDetails))
|
if (ConnectionService.IsDedicatedAdminConnection(info.ConnectionDetails))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -75,49 +75,42 @@ namespace Microsoft.SqlTools.ServiceLayer.NotebookConvert
|
|||||||
|
|
||||||
internal async Task HandleConvertNotebookToSqlRequest(ConvertNotebookToSqlParams parameters, RequestContext<ConvertNotebookToSqlResult> requestContext)
|
internal async Task HandleConvertNotebookToSqlRequest(ConvertNotebookToSqlParams parameters, RequestContext<ConvertNotebookToSqlResult> requestContext)
|
||||||
{
|
{
|
||||||
await Task.Run(async () =>
|
try
|
||||||
{
|
{
|
||||||
try
|
var notebookDoc = JsonConvert.DeserializeObject<NotebookDocument>(parameters.Content);
|
||||||
{
|
|
||||||
var notebookDoc = JsonConvert.DeserializeObject<NotebookDocument>(parameters.Content);
|
|
||||||
|
|
||||||
var result = new ConvertNotebookToSqlResult
|
var result = new ConvertNotebookToSqlResult
|
||||||
{
|
|
||||||
Content = ConvertNotebookDocToSql(notebookDoc)
|
|
||||||
};
|
|
||||||
await requestContext.SendResult(result);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
{
|
||||||
await requestContext.SendError(e);
|
Content = ConvertNotebookDocToSql(notebookDoc)
|
||||||
}
|
};
|
||||||
});
|
await requestContext.SendResult(result);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
await requestContext.SendError(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal async Task HandleConvertSqlToNotebookRequest(ConvertSqlToNotebookParams parameters, RequestContext<ConvertSqlToNotebookResult> requestContext)
|
internal async Task HandleConvertSqlToNotebookRequest(ConvertSqlToNotebookParams parameters, RequestContext<ConvertSqlToNotebookResult> requestContext)
|
||||||
{
|
{
|
||||||
await Task.Run(async () =>
|
try
|
||||||
{
|
{
|
||||||
|
// This URI doesn't come in escaped - so if it's a file path with reserved characters (such as %)
|
||||||
try
|
// then we'll fail to find it since GetFile expects the URI to be a fully-escaped URI as that's
|
||||||
|
// what the document events are sent in as.
|
||||||
|
var escapedClientUri = Uri.EscapeUriString(parameters.ClientUri);
|
||||||
|
var file = WorkspaceService<SqlToolsSettings>.Instance.Workspace.GetFile(escapedClientUri);
|
||||||
|
// Temporary notebook that we just fill in with the sql until the parsing logic is added
|
||||||
|
var result = new ConvertSqlToNotebookResult
|
||||||
{
|
{
|
||||||
// This URI doesn't come in escaped - so if it's a file path with reserved characters (such as %)
|
Content = JsonConvert.SerializeObject(ConvertSqlToNotebook(file.Contents))
|
||||||
// then we'll fail to find it since GetFile expects the URI to be a fully-escaped URI as that's
|
};
|
||||||
// what the document events are sent in as.
|
await requestContext.SendResult(result);
|
||||||
var escapedClientUri = Uri.EscapeUriString(parameters.ClientUri);
|
}
|
||||||
var file = WorkspaceService<SqlToolsSettings>.Instance.Workspace.GetFile(escapedClientUri);
|
catch (Exception e)
|
||||||
// Temporary notebook that we just fill in with the sql until the parsing logic is added
|
{
|
||||||
var result = new ConvertSqlToNotebookResult
|
await requestContext.SendError(e);
|
||||||
{
|
}
|
||||||
Content = JsonConvert.SerializeObject(ConvertSqlToNotebook(file.Contents))
|
|
||||||
};
|
|
||||||
await requestContext.SendResult(result);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
await requestContext.SendError(e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion // Convert Handlers
|
#endregion // Convert Handlers
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
|
|||||||
{
|
{
|
||||||
Validate.IsNotNull(nameof(connectionDetails), connectionDetails);
|
Validate.IsNotNull(nameof(connectionDetails), connectionDetails);
|
||||||
Validate.IsNotNull(nameof(context), context);
|
Validate.IsNotNull(nameof(context), context);
|
||||||
return await Task.Factory.StartNew(() =>
|
return await Task.Run(() =>
|
||||||
{
|
{
|
||||||
string uri = GenerateUri(connectionDetails);
|
string uri = GenerateUri(connectionDetails);
|
||||||
|
|
||||||
@@ -384,13 +384,11 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal async Task<ExpandResponse> ExpandNode(ObjectExplorerSession session, string nodePath, bool forceRefresh = false)
|
internal Task<ExpandResponse> ExpandNode(ObjectExplorerSession session, string nodePath, bool forceRefresh = false)
|
||||||
{
|
{
|
||||||
return await Task.Factory.StartNew(() =>
|
return Task.Run(() => QueueExpandNodeRequest(session, nodePath, forceRefresh));
|
||||||
{
|
|
||||||
return QueueExpandNodeRequest(session, nodePath, forceRefresh);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal ExpandResponse QueueExpandNodeRequest(ObjectExplorerSession session, string nodePath, bool forceRefresh = false)
|
internal ExpandResponse QueueExpandNodeRequest(ObjectExplorerSession session, string nodePath, bool forceRefresh = false)
|
||||||
{
|
{
|
||||||
NodeInfo[] nodes = null;
|
NodeInfo[] nodes = null;
|
||||||
|
|||||||
@@ -115,59 +115,56 @@ namespace Microsoft.SqlTools.ServiceLayer.Profiler
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal async Task HandleCreateXEventSessionRequest(CreateXEventSessionParams parameters, RequestContext<CreateXEventSessionResult> requestContext)
|
internal async Task HandleCreateXEventSessionRequest(CreateXEventSessionParams parameters, RequestContext<CreateXEventSessionResult> requestContext)
|
||||||
{
|
{
|
||||||
await Task.Run(async () =>
|
try
|
||||||
{
|
{
|
||||||
try
|
ConnectionInfo connInfo;
|
||||||
|
ConnectionServiceInstance.TryFindConnection(
|
||||||
|
parameters.OwnerUri,
|
||||||
|
out connInfo);
|
||||||
|
if (connInfo == null)
|
||||||
{
|
{
|
||||||
ConnectionInfo connInfo;
|
throw new Exception(SR.ProfilerConnectionNotFound);
|
||||||
ConnectionServiceInstance.TryFindConnection(
|
|
||||||
parameters.OwnerUri,
|
|
||||||
out connInfo);
|
|
||||||
if (connInfo == null)
|
|
||||||
{
|
|
||||||
throw new Exception(SR.ProfilerConnectionNotFound);
|
|
||||||
}
|
|
||||||
else if (parameters.SessionName == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("SessionName");
|
|
||||||
}
|
|
||||||
else if (parameters.Template == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Template");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
IXEventSession xeSession = null;
|
|
||||||
|
|
||||||
// first check whether the session with the given name already exists.
|
|
||||||
// if so skip the creation part. An exception will be thrown if no session with given name can be found,
|
|
||||||
// and it can be ignored.
|
|
||||||
try
|
|
||||||
{
|
|
||||||
xeSession = this.XEventSessionFactory.GetXEventSession(parameters.SessionName, connInfo);
|
|
||||||
}
|
|
||||||
catch { }
|
|
||||||
|
|
||||||
if (xeSession == null)
|
|
||||||
{
|
|
||||||
// create a new XEvent session and Profiler session
|
|
||||||
xeSession = this.XEventSessionFactory.CreateXEventSession(parameters.Template.CreateStatement, parameters.SessionName, connInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
// start monitoring the profiler session
|
|
||||||
monitor.StartMonitoringSession(parameters.OwnerUri, xeSession);
|
|
||||||
|
|
||||||
var result = new CreateXEventSessionResult();
|
|
||||||
await requestContext.SendResult(result);
|
|
||||||
|
|
||||||
SessionCreatedNotification(parameters.OwnerUri, parameters.SessionName, parameters.Template.Name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
else if (parameters.SessionName == null)
|
||||||
{
|
{
|
||||||
await requestContext.SendError(new Exception(SR.CreateSessionFailed(e.Message)));
|
throw new ArgumentNullException("SessionName");
|
||||||
}
|
}
|
||||||
});
|
else if (parameters.Template == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Template");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IXEventSession xeSession = null;
|
||||||
|
|
||||||
|
// first check whether the session with the given name already exists.
|
||||||
|
// if so skip the creation part. An exception will be thrown if no session with given name can be found,
|
||||||
|
// and it can be ignored.
|
||||||
|
try
|
||||||
|
{
|
||||||
|
xeSession = this.XEventSessionFactory.GetXEventSession(parameters.SessionName, connInfo);
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
|
||||||
|
if (xeSession == null)
|
||||||
|
{
|
||||||
|
// create a new XEvent session and Profiler session
|
||||||
|
xeSession = this.XEventSessionFactory.CreateXEventSession(parameters.Template.CreateStatement, parameters.SessionName, connInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
// start monitoring the profiler session
|
||||||
|
monitor.StartMonitoringSession(parameters.OwnerUri, xeSession);
|
||||||
|
|
||||||
|
var result = new CreateXEventSessionResult();
|
||||||
|
await requestContext.SendResult(result);
|
||||||
|
|
||||||
|
SessionCreatedNotification(parameters.OwnerUri, parameters.SessionName, parameters.Template.Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
await requestContext.SendError(new Exception(SR.CreateSessionFailed(e.Message)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -175,34 +172,31 @@ namespace Microsoft.SqlTools.ServiceLayer.Profiler
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal async Task HandleStartProfilingRequest(StartProfilingParams parameters, RequestContext<StartProfilingResult> requestContext)
|
internal async Task HandleStartProfilingRequest(StartProfilingParams parameters, RequestContext<StartProfilingResult> requestContext)
|
||||||
{
|
{
|
||||||
await Task.Run(async () =>
|
try
|
||||||
{
|
{
|
||||||
try
|
ConnectionInfo connInfo;
|
||||||
|
ConnectionServiceInstance.TryFindConnection(
|
||||||
|
parameters.OwnerUri,
|
||||||
|
out connInfo);
|
||||||
|
if (connInfo != null)
|
||||||
{
|
{
|
||||||
ConnectionInfo connInfo;
|
// create a new XEvent session and Profiler session
|
||||||
ConnectionServiceInstance.TryFindConnection(
|
var xeSession = this.XEventSessionFactory.GetXEventSession(parameters.SessionName, connInfo);
|
||||||
parameters.OwnerUri,
|
// start monitoring the profiler session
|
||||||
out connInfo);
|
monitor.StartMonitoringSession(parameters.OwnerUri, xeSession);
|
||||||
if (connInfo != null)
|
|
||||||
{
|
|
||||||
// create a new XEvent session and Profiler session
|
|
||||||
var xeSession = this.XEventSessionFactory.GetXEventSession(parameters.SessionName, connInfo);
|
|
||||||
// start monitoring the profiler session
|
|
||||||
monitor.StartMonitoringSession(parameters.OwnerUri, xeSession);
|
|
||||||
|
|
||||||
var result = new StartProfilingResult();
|
var result = new StartProfilingResult();
|
||||||
await requestContext.SendResult(result);
|
await requestContext.SendResult(result);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new Exception(SR.ProfilerConnectionNotFound);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
else
|
||||||
{
|
{
|
||||||
await requestContext.SendError(new Exception(SR.StartSessionFailed(e.Message)));
|
throw new Exception(SR.ProfilerConnectionNotFound);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
await requestContext.SendError(new Exception(SR.StartSessionFailed(e.Message)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -210,47 +204,44 @@ namespace Microsoft.SqlTools.ServiceLayer.Profiler
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal async Task HandleStopProfilingRequest(StopProfilingParams parameters, RequestContext<StopProfilingResult> requestContext)
|
internal async Task HandleStopProfilingRequest(StopProfilingParams parameters, RequestContext<StopProfilingResult> requestContext)
|
||||||
{
|
{
|
||||||
await Task.Run(async () =>
|
try
|
||||||
{
|
{
|
||||||
try
|
ProfilerSession session;
|
||||||
{
|
monitor.StopMonitoringSession(parameters.OwnerUri, out session);
|
||||||
ProfilerSession session;
|
|
||||||
monitor.StopMonitoringSession(parameters.OwnerUri, out session);
|
|
||||||
|
|
||||||
if (session != null)
|
if (session != null)
|
||||||
|
{
|
||||||
|
// Occasionally we might see the InvalidOperationException due to a read is
|
||||||
|
// in progress, add the following retry logic will solve the problem.
|
||||||
|
int remainingAttempts = 3;
|
||||||
|
while (true)
|
||||||
{
|
{
|
||||||
// Occasionally we might see the InvalidOperationException due to a read is
|
try
|
||||||
// in progress, add the following retry logic will solve the problem.
|
|
||||||
int remainingAttempts = 3;
|
|
||||||
while (true)
|
|
||||||
{
|
{
|
||||||
try
|
session.XEventSession.Stop();
|
||||||
|
await requestContext.SendResult(new StopProfilingResult { });
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
catch (InvalidOperationException)
|
||||||
|
{
|
||||||
|
remainingAttempts--;
|
||||||
|
if (remainingAttempts == 0)
|
||||||
{
|
{
|
||||||
session.XEventSession.Stop();
|
throw;
|
||||||
await requestContext.SendResult(new StopProfilingResult { });
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
catch (InvalidOperationException)
|
|
||||||
{
|
|
||||||
remainingAttempts--;
|
|
||||||
if (remainingAttempts == 0)
|
|
||||||
{
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
Thread.Sleep(500);
|
|
||||||
}
|
}
|
||||||
|
Thread.Sleep(500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new Exception(SR.SessionNotFound);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
else
|
||||||
{
|
{
|
||||||
await requestContext.SendError(new Exception(SR.StopSessionFailed(e.Message)));
|
throw new Exception(SR.SessionNotFound);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
await requestContext.SendError(new Exception(SR.StopSessionFailed(e.Message)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -258,19 +249,16 @@ namespace Microsoft.SqlTools.ServiceLayer.Profiler
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal async Task HandlePauseProfilingRequest(PauseProfilingParams parameters, RequestContext<PauseProfilingResult> requestContext)
|
internal async Task HandlePauseProfilingRequest(PauseProfilingParams parameters, RequestContext<PauseProfilingResult> requestContext)
|
||||||
{
|
{
|
||||||
await Task.Run(async () =>
|
try
|
||||||
{
|
{
|
||||||
try
|
monitor.PauseViewer(parameters.OwnerUri);
|
||||||
{
|
|
||||||
monitor.PauseViewer(parameters.OwnerUri);
|
|
||||||
|
|
||||||
await requestContext.SendResult(new PauseProfilingResult { });
|
await requestContext.SendResult(new PauseProfilingResult { });
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
await requestContext.SendError(new Exception(SR.PauseSessionFailed(e.Message)));
|
await requestContext.SendError(new Exception(SR.PauseSessionFailed(e.Message)));
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -278,31 +266,28 @@ namespace Microsoft.SqlTools.ServiceLayer.Profiler
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal async Task HandleGetXEventSessionsRequest(GetXEventSessionsParams parameters, RequestContext<GetXEventSessionsResult> requestContext)
|
internal async Task HandleGetXEventSessionsRequest(GetXEventSessionsParams parameters, RequestContext<GetXEventSessionsResult> requestContext)
|
||||||
{
|
{
|
||||||
await Task.Run(async () =>
|
try
|
||||||
{
|
{
|
||||||
try
|
var result = new GetXEventSessionsResult();
|
||||||
|
ConnectionInfo connInfo;
|
||||||
|
ConnectionServiceInstance.TryFindConnection(
|
||||||
|
parameters.OwnerUri,
|
||||||
|
out connInfo);
|
||||||
|
if (connInfo == null)
|
||||||
{
|
{
|
||||||
var result = new GetXEventSessionsResult();
|
await requestContext.SendError(new Exception(SR.ProfilerConnectionNotFound));
|
||||||
ConnectionInfo connInfo;
|
|
||||||
ConnectionServiceInstance.TryFindConnection(
|
|
||||||
parameters.OwnerUri,
|
|
||||||
out connInfo);
|
|
||||||
if (connInfo == null)
|
|
||||||
{
|
|
||||||
await requestContext.SendError(new Exception(SR.ProfilerConnectionNotFound));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
List<string> sessions = GetXEventSessionList(parameters.OwnerUri, connInfo);
|
|
||||||
result.Sessions = sessions;
|
|
||||||
await requestContext.SendResult(result);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
else
|
||||||
{
|
{
|
||||||
await requestContext.SendError(e);
|
List<string> sessions = GetXEventSessionList(parameters.OwnerUri, connInfo);
|
||||||
|
result.Sessions = sessions;
|
||||||
|
await requestContext.SendResult(result);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
await requestContext.SendError(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -310,18 +295,14 @@ namespace Microsoft.SqlTools.ServiceLayer.Profiler
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal async Task HandleDisconnectSessionRequest(DisconnectSessionParams parameters, RequestContext<DisconnectSessionResult> requestContext)
|
internal async Task HandleDisconnectSessionRequest(DisconnectSessionParams parameters, RequestContext<DisconnectSessionResult> requestContext)
|
||||||
{
|
{
|
||||||
await Task.Run(async () =>
|
try
|
||||||
{
|
{
|
||||||
try
|
monitor.StopMonitoringSession(parameters.OwnerUri, out _);
|
||||||
{
|
}
|
||||||
ProfilerSession session;
|
catch (Exception e)
|
||||||
monitor.StopMonitoringSession(parameters.OwnerUri, out session);
|
{
|
||||||
}
|
await requestContext.SendError(e);
|
||||||
catch (Exception e)
|
}
|
||||||
{
|
|
||||||
await requestContext.SendError(e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -707,7 +707,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
|||||||
/// <param name="scriptFile"></param>
|
/// <param name="scriptFile"></param>
|
||||||
/// <param name="eventContext"></param>
|
/// <param name="eventContext"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task HandleDidCloseTextDocumentNotification(
|
public Task HandleDidCloseTextDocumentNotification(
|
||||||
string uri,
|
string uri,
|
||||||
ScriptFile scriptFile,
|
ScriptFile scriptFile,
|
||||||
EventContext eventContext)
|
EventContext eventContext)
|
||||||
@@ -725,7 +725,8 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
|||||||
{
|
{
|
||||||
Logger.Write(TraceEventType.Error, "Unknown error " + ex.ToString());
|
Logger.Write(TraceEventType.Error, "Unknown error " + ex.ToString());
|
||||||
}
|
}
|
||||||
await Task.FromResult(true);
|
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -143,43 +143,38 @@ namespace Microsoft.SqlTools.ServiceLayer.Security
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal async Task HandleGetCredentialsRequest(GetCredentialsParams parameters, RequestContext<GetCredentialsResult> requestContext)
|
internal async Task HandleGetCredentialsRequest(GetCredentialsParams parameters, RequestContext<GetCredentialsResult> requestContext)
|
||||||
{
|
{
|
||||||
await Task.Run(async () =>
|
var result = new GetCredentialsResult();
|
||||||
|
try
|
||||||
{
|
{
|
||||||
var result = new GetCredentialsResult();
|
ConnectionInfo connInfo;
|
||||||
try
|
ConnectionServiceInstance.TryFindConnection(parameters.OwnerUri, out connInfo);
|
||||||
{
|
CDataContainer dataContainer = CDataContainer.CreateDataContainer(connInfo, databaseExists: true);
|
||||||
ConnectionInfo connInfo;
|
|
||||||
ConnectionServiceInstance.TryFindConnection(parameters.OwnerUri, out connInfo);
|
|
||||||
CDataContainer dataContainer = CDataContainer.CreateDataContainer(connInfo, databaseExists: true);
|
|
||||||
|
|
||||||
var credentials = dataContainer.Server.Credentials;
|
var credentials = dataContainer.Server.Credentials;
|
||||||
int credentialsCount = credentials.Count;
|
int credentialsCount = credentials.Count;
|
||||||
CredentialInfo[] credentialsInfos = new CredentialInfo[credentialsCount];
|
CredentialInfo[] credentialsInfos = new CredentialInfo[credentialsCount];
|
||||||
for (int i = 0; i < credentialsCount; ++i)
|
for (int i = 0; i < credentialsCount; ++i)
|
||||||
{
|
|
||||||
credentialsInfos[i] = new CredentialInfo();
|
|
||||||
credentialsInfos[i].Name = credentials[i].Name;
|
|
||||||
credentialsInfos[i].Identity = credentials[i].Identity;
|
|
||||||
credentialsInfos[i].Id = credentials[i].ID;
|
|
||||||
credentialsInfos[i].DateLastModified = credentials[i].DateLastModified;
|
|
||||||
credentialsInfos[i].CreateDate = credentials[i].CreateDate;
|
|
||||||
credentialsInfos[i].ProviderName = credentials[i].ProviderName;
|
|
||||||
}
|
|
||||||
result.Credentials = credentialsInfos;
|
|
||||||
result.Success = true;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
{
|
||||||
result.Success = false;
|
credentialsInfos[i] = new CredentialInfo();
|
||||||
result.ErrorMessage = ex.ToString();
|
credentialsInfos[i].Name = credentials[i].Name;
|
||||||
|
credentialsInfos[i].Identity = credentials[i].Identity;
|
||||||
|
credentialsInfos[i].Id = credentials[i].ID;
|
||||||
|
credentialsInfos[i].DateLastModified = credentials[i].DateLastModified;
|
||||||
|
credentialsInfos[i].CreateDate = credentials[i].CreateDate;
|
||||||
|
credentialsInfos[i].ProviderName = credentials[i].ProviderName;
|
||||||
}
|
}
|
||||||
|
result.Credentials = credentialsInfos;
|
||||||
|
result.Success = true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
result.Success = false;
|
||||||
|
result.ErrorMessage = ex.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
await requestContext.SendResult(result);
|
await requestContext.SendResult(result);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Disposes the service
|
/// Disposes the service
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -193,13 +188,13 @@ namespace Microsoft.SqlTools.ServiceLayer.Security
|
|||||||
|
|
||||||
#region "Helpers"
|
#region "Helpers"
|
||||||
|
|
||||||
internal async Task<Tuple<bool, string>> ConfigureCredential(
|
internal Task<Tuple<bool, string>> ConfigureCredential(
|
||||||
string ownerUri,
|
string ownerUri,
|
||||||
CredentialInfo credential,
|
CredentialInfo credential,
|
||||||
ConfigAction configAction,
|
ConfigAction configAction,
|
||||||
RunType runType)
|
RunType runType)
|
||||||
{
|
{
|
||||||
return await Task<Tuple<bool, string>>.Run(() =>
|
return Task<Tuple<bool, string>>.Run(() =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TaskServices
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sqlTask">Sql Task</param>
|
/// <param name="sqlTask">Sql Task</param>
|
||||||
/// <returns>Task Result</returns>
|
/// <returns>Task Result</returns>
|
||||||
public static async Task<TaskResult> ExecuteTaskAsync(SqlTask sqlTask)
|
public static Task<TaskResult> ExecuteTaskAsync(SqlTask sqlTask)
|
||||||
{
|
{
|
||||||
sqlTask.AddMessage(SR.TaskInProgress, SqlTaskStatus.InProgress, true);
|
sqlTask.AddMessage(SR.TaskInProgress, SqlTaskStatus.InProgress, true);
|
||||||
ITaskOperation taskOperation = sqlTask.TaskMetadata.TaskOperation as ITaskOperation;
|
ITaskOperation taskOperation = sqlTask.TaskMetadata.TaskOperation as ITaskOperation;
|
||||||
@@ -28,7 +28,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TaskServices
|
|||||||
{
|
{
|
||||||
taskOperation.SqlTask = sqlTask;
|
taskOperation.SqlTask = sqlTask;
|
||||||
|
|
||||||
return await Task.Factory.StartNew(() =>
|
return Task.Run(() =>
|
||||||
{
|
{
|
||||||
TaskResult result = new TaskResult();
|
TaskResult result = new TaskResult();
|
||||||
try
|
try
|
||||||
@@ -66,13 +66,13 @@ namespace Microsoft.SqlTools.ServiceLayer.TaskServices
|
|||||||
taskResult.TaskStatus = SqlTaskStatus.Failed;
|
taskResult.TaskStatus = SqlTaskStatus.Failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
return taskResult;
|
return Task.FromResult(taskResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Async method to cancel the operations
|
/// Async method to cancel the operations
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static async Task<TaskResult> CancelTaskAsync(SqlTask sqlTask)
|
public static Task<TaskResult> CancelTaskAsync(SqlTask sqlTask)
|
||||||
{
|
{
|
||||||
ITaskOperation taskOperation = sqlTask.TaskMetadata.TaskOperation as ITaskOperation;
|
ITaskOperation taskOperation = sqlTask.TaskMetadata.TaskOperation as ITaskOperation;
|
||||||
TaskResult taskResult = null;
|
TaskResult taskResult = null;
|
||||||
@@ -80,7 +80,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TaskServices
|
|||||||
if (taskOperation != null)
|
if (taskOperation != null)
|
||||||
{
|
{
|
||||||
|
|
||||||
return await Task.Factory.StartNew(() =>
|
return Task.Run(() =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -107,7 +107,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TaskServices
|
|||||||
taskResult.TaskStatus = SqlTaskStatus.Failed;
|
taskResult.TaskStatus = SqlTaskStatus.Failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
return taskResult;
|
return Task.FromResult(taskResult);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Workspace
|
|||||||
serviceHost.SetEventHandler(DidChangeConfigurationNotification<TConfig>.Type, HandleDidChangeConfigurationNotification);
|
serviceHost.SetEventHandler(DidChangeConfigurationNotification<TConfig>.Type, HandleDidChangeConfigurationNotification);
|
||||||
|
|
||||||
// Register an initialization handler that sets the workspace path
|
// Register an initialization handler that sets the workspace path
|
||||||
serviceHost.RegisterInitializeTask(async (parameters, contect) =>
|
serviceHost.RegisterInitializeTask((parameters, contect) =>
|
||||||
{
|
{
|
||||||
Logger.Write(TraceEventType.Verbose, "Initializing workspace service");
|
Logger.Write(TraceEventType.Verbose, "Initializing workspace service");
|
||||||
|
|
||||||
@@ -142,11 +142,12 @@ namespace Microsoft.SqlTools.ServiceLayer.Workspace
|
|||||||
{
|
{
|
||||||
Workspace.WorkspacePath = parameters.RootPath;
|
Workspace.WorkspacePath = parameters.RootPath;
|
||||||
}
|
}
|
||||||
await Task.FromResult(0);
|
|
||||||
|
return Task.CompletedTask;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Register a shutdown request that disposes the workspace
|
// Register a shutdown request that disposes the workspace
|
||||||
serviceHost.RegisterShutdownTask(async (parameters, context) =>
|
serviceHost.RegisterShutdownTask((parameters, context) =>
|
||||||
{
|
{
|
||||||
Logger.Write(TraceEventType.Verbose, "Shutting down workspace service");
|
Logger.Write(TraceEventType.Verbose, "Shutting down workspace service");
|
||||||
|
|
||||||
@@ -155,7 +156,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Workspace
|
|||||||
Workspace.Dispose();
|
Workspace.Dispose();
|
||||||
Workspace = null;
|
Workspace = null;
|
||||||
}
|
}
|
||||||
await Task.FromResult(0);
|
|
||||||
|
return Task.CompletedTask;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user