Skip to content

Commit

Permalink
Fixing more restore connection issues (#488)
Browse files Browse the repository at this point in the history
  • Loading branch information
llali authored Oct 10, 2017
1 parent a437673 commit 284a3e0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public virtual async Task<ConnectionCompleteParams> Connect(ConnectParams connec

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,
// but wait until later when we are connected to add it to the map.
ConnectionInfo connectionInfo;
Expand Down Expand Up @@ -317,7 +317,7 @@ private void TryCloseConnectionTemporaryConnection(ConnectParams connectionParam
{
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;
string type = connectionParams.Type;
Expand All @@ -344,7 +344,7 @@ private static string GetApplicationNameWithFeature(string applicationName, stri
string appName = applicationName;
if (index > 0)
{
appName = applicationName.Substring(0, index - 1);
appName = applicationName.Substring(0, index);
}
appNameWithFeature = $"{appName}-{featureName}";
}
Expand All @@ -358,13 +358,17 @@ private void TrySetConnectionType(ConnectParams connectionParams)
{
if (connectionParams.OwnerUri.ToLowerInvariant().StartsWith("dashboard://"))
{
connectionParams.Type = ConnectionType.Dashboard;
connectionParams.Purpose = ConnectionType.Dashboard;
}
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)
Expand Down Expand Up @@ -1156,6 +1160,7 @@ public static SqlConnectionStringBuilder CreateConnectionStringBuilder(Connectio
{
connectionBuilder.TypeSystemVersion = connectionDetails.TypeSystemVersion;
}
connectionBuilder.Pooling = false;

return connectionBuilder;
}
Expand Down Expand Up @@ -1209,7 +1214,7 @@ public void ChangeConnectionDatabaseContext(string ownerUri, string newDatabaseN
/// </summary>
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ public static class ConnectionType
public const string Edit = "Edit";
public const string ObjectExplorer = "ObjectExplorer";
public const string Dashboard = "Dashboard";
public const string ConnectionValidation = "ConnectionValidation";
public const string GeneralConnection = "GeneralConnection";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,10 @@ public class ConnectParams
/// The type of this connection. By default, this is set to ConnectionType.Default.
/// </summary>
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;
}
}

0 comments on commit 284a3e0

Please sign in to comment.