Fixing more restore connection issues (#488)

This commit is contained in:
Leila Lali
2017-10-10 14:32:45 -07:00
committed by GitHub
parent a4376732ce
commit 284a3e0ee4
3 changed files with 17 additions and 7 deletions

View File

@@ -266,7 +266,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
TrySetConnectionType(connectionParams); TrySetConnectionType(connectionParams);
connectionParams.Connection.ApplicationName = GetApplicationNameWithFeature(connectionParams.Connection.ApplicationName, connectionParams.Type); connectionParams.Connection.ApplicationName = GetApplicationNameWithFeature(connectionParams.Connection.ApplicationName, connectionParams.Purpose);
// If there is no ConnectionInfo in the map, create a new ConnectionInfo, // If there is no ConnectionInfo in the map, create a new ConnectionInfo,
// but wait until later when we are connected to add it to the map. // but wait until later when we are connected to add it to the map.
ConnectionInfo connectionInfo; ConnectionInfo connectionInfo;
@@ -317,7 +317,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
{ {
try try
{ {
if (connectionParams.Type == ConnectionType.ObjectExplorer || connectionParams.Type == ConnectionType.Dashboard || connectionParams.Type == ConnectionType.ConnectionValidation) if (connectionParams.Purpose == ConnectionType.ObjectExplorer || connectionParams.Purpose == ConnectionType.Dashboard || connectionParams.Purpose == ConnectionType.GeneralConnection)
{ {
DbConnection connection; DbConnection connection;
string type = connectionParams.Type; string type = connectionParams.Type;
@@ -344,7 +344,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
string appName = applicationName; string appName = applicationName;
if (index > 0) if (index > 0)
{ {
appName = applicationName.Substring(0, index - 1); appName = applicationName.Substring(0, index);
} }
appNameWithFeature = $"{appName}-{featureName}"; appNameWithFeature = $"{appName}-{featureName}";
} }
@@ -358,13 +358,17 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
{ {
if (connectionParams.OwnerUri.ToLowerInvariant().StartsWith("dashboard://")) if (connectionParams.OwnerUri.ToLowerInvariant().StartsWith("dashboard://"))
{ {
connectionParams.Type = ConnectionType.Dashboard; connectionParams.Purpose = ConnectionType.Dashboard;
} }
else if (connectionParams.OwnerUri.ToLowerInvariant().StartsWith("connection://")) else if (connectionParams.OwnerUri.ToLowerInvariant().StartsWith("connection://"))
{ {
connectionParams.Type = ConnectionType.ConnectionValidation; connectionParams.Purpose = ConnectionType.GeneralConnection;
} }
} }
else if (connectionParams != null)
{
connectionParams.Purpose = connectionParams.Type;
}
} }
private bool IsConnectionChanged(ConnectParams connectionParams, ConnectionInfo connectionInfo) private bool IsConnectionChanged(ConnectParams connectionParams, ConnectionInfo connectionInfo)
@@ -1156,6 +1160,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
{ {
connectionBuilder.TypeSystemVersion = connectionDetails.TypeSystemVersion; connectionBuilder.TypeSystemVersion = connectionDetails.TypeSystemVersion;
} }
connectionBuilder.Pooling = false;
return connectionBuilder; return connectionBuilder;
} }
@@ -1209,7 +1214,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
/// </summary> /// </summary>
private void InvokeOnConnectionActivities(ConnectionInfo connectionInfo, ConnectParams connectParams) private void InvokeOnConnectionActivities(ConnectionInfo connectionInfo, ConnectParams connectParams)
{ {
if (connectParams.Type != ConnectionType.Default && connectParams.Type != ConnectionType.ConnectionValidation) if (connectParams.Type != ConnectionType.Default && connectParams.Type != ConnectionType.GeneralConnection)
{ {
return; return;
} }

View File

@@ -18,6 +18,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
public const string Edit = "Edit"; public const string Edit = "Edit";
public const string ObjectExplorer = "ObjectExplorer"; public const string ObjectExplorer = "ObjectExplorer";
public const string Dashboard = "Dashboard"; public const string Dashboard = "Dashboard";
public const string ConnectionValidation = "ConnectionValidation"; public const string GeneralConnection = "GeneralConnection";
} }
} }

View File

@@ -28,5 +28,10 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.Contracts
/// The type of this connection. By default, this is set to ConnectionType.Default. /// The type of this connection. By default, this is set to ConnectionType.Default.
/// </summary> /// </summary>
public string Type { get; set; } = ConnectionType.Default; public string Type { get; set; } = ConnectionType.Default;
/// <summary>
/// The porpose of the connection to keep track of open connections
/// </summary>
public string Purpose { get; set; } = ConnectionType.GeneralConnection;
} }
} }