mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 18:47:57 -05:00
Default to Server level context for all OE nodes (#829)
This commit is contained in:
@@ -73,7 +73,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
|
|||||||
{
|
{
|
||||||
this.bindingQueue = value;
|
this.bindingQueue = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Internal for testing only
|
/// Internal for testing only
|
||||||
@@ -485,7 +485,6 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
|
|||||||
ObjectExplorerSession session = null;
|
ObjectExplorerSession session = null;
|
||||||
connectionDetails.PersistSecurityInfo = true;
|
connectionDetails.PersistSecurityInfo = true;
|
||||||
ConnectParams connectParams = new ConnectParams() { OwnerUri = uri, Connection = connectionDetails, Type = Connection.ConnectionType.ObjectExplorer };
|
ConnectParams connectParams = new ConnectParams() { OwnerUri = uri, Connection = connectionDetails, Type = Connection.ConnectionType.ObjectExplorer };
|
||||||
bool isDefaultOrSystemDatabase = DatabaseUtils.IsSystemDatabaseConnection(connectionDetails.DatabaseName) || string.IsNullOrWhiteSpace(connectionDetails.DatabaseDisplayName);
|
|
||||||
|
|
||||||
ConnectionInfo connectionInfo;
|
ConnectionInfo connectionInfo;
|
||||||
ConnectionCompleteParams connectionResult = await Connect(connectParams, uri);
|
ConnectionCompleteParams connectionResult = await Connect(connectParams, uri);
|
||||||
@@ -507,7 +506,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
|
|||||||
waitForLockTimeout: timeout,
|
waitForLockTimeout: timeout,
|
||||||
bindOperation: (bindingContext, cancelToken) =>
|
bindOperation: (bindingContext, cancelToken) =>
|
||||||
{
|
{
|
||||||
session = ObjectExplorerSession.CreateSession(connectionResult, serviceProvider, bindingContext.ServerConnection, isDefaultOrSystemDatabase);
|
session = ObjectExplorerSession.CreateSession(connectionResult, serviceProvider, bindingContext.ServerConnection);
|
||||||
session.ConnectionInfo = connectionInfo;
|
session.ConnectionInfo = connectionInfo;
|
||||||
|
|
||||||
sessionMap.AddOrUpdate(uri, session, (key, oldSession) => session);
|
sessionMap.AddOrUpdate(uri, session, (key, oldSession) => session);
|
||||||
@@ -526,7 +525,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
|
|||||||
await SendSessionFailedNotification(uri, ex.Message);
|
await SendSessionFailedNotification(uri, ex.Message);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<ConnectionCompleteParams> Connect(ConnectParams connectParams, string uri)
|
private async Task<ConnectionCompleteParams> Connect(ConnectParams connectParams, string uri)
|
||||||
{
|
{
|
||||||
@@ -545,7 +544,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
|
|||||||
await SendSessionFailedNotification(uri, result.ErrorMessage);
|
await SendSessionFailedNotification(uri, result.ErrorMessage);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -585,7 +584,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
|
|||||||
ExpandTask = task;
|
ExpandTask = task;
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
ObjectExplorerTaskResult result = await RunTaskWithTimeout(task,
|
ObjectExplorerTaskResult result = await RunTaskWithTimeout(task,
|
||||||
settings?.ExpandTimeout ?? ObjectExplorerSettings.DefaultExpandTimeout);
|
settings?.ExpandTimeout ?? ObjectExplorerSettings.DefaultExpandTimeout);
|
||||||
|
|
||||||
if (result != null && !result.IsCompleted)
|
if (result != null && !result.IsCompleted)
|
||||||
@@ -654,7 +653,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
|
|||||||
internal static string GenerateUri(ConnectionDetails details)
|
internal static string GenerateUri(ConnectionDetails details)
|
||||||
{
|
{
|
||||||
return ConnectedBindingQueue.GetConnectionContextKey(details);
|
return ConnectedBindingQueue.GetConnectionContextKey(details);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<ChildFactory> GetApplicableChildFactories(TreeNode item)
|
public IEnumerable<ChildFactory> GetApplicableChildFactories(TreeNode item)
|
||||||
{
|
{
|
||||||
@@ -755,7 +754,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
|
|||||||
{
|
{
|
||||||
bindingQueue.OnUnhandledException -= OnUnhandledException;
|
bindingQueue.OnUnhandledException -= OnUnhandledException;
|
||||||
bindingQueue.Dispose();
|
bindingQueue.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void OnUnhandledException(string queueKey, Exception ex)
|
private async void OnUnhandledException(string queueKey, Exception ex)
|
||||||
@@ -810,20 +809,12 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
|
|||||||
|
|
||||||
public string ErrorMessage { get; set; }
|
public string ErrorMessage { get; set; }
|
||||||
|
|
||||||
public static ObjectExplorerSession CreateSession(ConnectionCompleteParams response, IMultiServiceProvider serviceProvider, ServerConnection serverConnection, bool isDefaultOrSystemDatabase)
|
public static ObjectExplorerSession CreateSession(ConnectionCompleteParams response, IMultiServiceProvider serviceProvider, ServerConnection serverConnection)
|
||||||
{
|
{
|
||||||
ServerNode rootNode = new ServerNode(response, serviceProvider, serverConnection);
|
ServerNode rootNode = new ServerNode(response, serviceProvider, serverConnection);
|
||||||
var session = new ObjectExplorerSession(response.OwnerUri, rootNode, serviceProvider, serviceProvider.GetService<ConnectionService>());
|
return new ObjectExplorerSession(response.OwnerUri, rootNode, serviceProvider, serviceProvider.GetService<ConnectionService>());
|
||||||
if (!isDefaultOrSystemDatabase)
|
|
||||||
{
|
|
||||||
// Assuming the databases are in a folder under server node
|
|
||||||
DatabaseTreeNode databaseNode = new DatabaseTreeNode(rootNode, response.ConnectionSummary.DatabaseName);
|
|
||||||
session.Root = databaseNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
return session;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user