mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-17 02:51:45 -05:00
This reverts commit a4b6c300ac.
(cherry picked from commit 7512a2bbe3154e4dd4b63927fcba52db78424994)
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,6 +485,7 @@ 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);
|
||||||
@@ -506,7 +507,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
|
|||||||
waitForLockTimeout: timeout,
|
waitForLockTimeout: timeout,
|
||||||
bindOperation: (bindingContext, cancelToken) =>
|
bindOperation: (bindingContext, cancelToken) =>
|
||||||
{
|
{
|
||||||
session = ObjectExplorerSession.CreateSession(connectionResult, serviceProvider, bindingContext.ServerConnection);
|
session = ObjectExplorerSession.CreateSession(connectionResult, serviceProvider, bindingContext.ServerConnection, isDefaultOrSystemDatabase);
|
||||||
session.ConnectionInfo = connectionInfo;
|
session.ConnectionInfo = connectionInfo;
|
||||||
|
|
||||||
sessionMap.AddOrUpdate(uri, session, (key, oldSession) => session);
|
sessionMap.AddOrUpdate(uri, session, (key, oldSession) => session);
|
||||||
@@ -525,7 +526,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)
|
||||||
{
|
{
|
||||||
@@ -544,7 +545,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)
|
||||||
{
|
{
|
||||||
@@ -584,7 +585,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)
|
||||||
@@ -653,7 +654,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)
|
||||||
{
|
{
|
||||||
@@ -754,7 +755,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)
|
||||||
@@ -809,12 +810,20 @@ 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)
|
public static ObjectExplorerSession CreateSession(ConnectionCompleteParams response, IMultiServiceProvider serviceProvider, ServerConnection serverConnection, bool isDefaultOrSystemDatabase)
|
||||||
{
|
{
|
||||||
ServerNode rootNode = new ServerNode(response, serviceProvider, serverConnection);
|
ServerNode rootNode = new ServerNode(response, serviceProvider, serverConnection);
|
||||||
return new ObjectExplorerSession(response.OwnerUri, rootNode, serviceProvider, serviceProvider.GetService<ConnectionService>());
|
var session = 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