added contract to cancel restore plan and close the related connections (#522)

This commit is contained in:
Leila Lali
2017-10-25 10:24:19 -07:00
committed by GitHub
parent 09dd0579d0
commit f80fd8a458
4 changed files with 85 additions and 0 deletions

View File

@@ -66,6 +66,26 @@ namespace Microsoft.SqlTools.ServiceLayer.DisasterRecovery.RestoreOperation
}
/// <summary>
/// Cancels existing restore plan
/// </summary>
public bool CancelRestorePlan(RestoreParams restoreParams)
{
RestoreDatabaseTaskDataObject restoreTaskObject = null;
string sessionId = restoreParams.SessionId;
if (!string.IsNullOrEmpty(sessionId) && sessions.TryGetValue(sessionId, out restoreTaskObject))
{
ServerConnection connection = restoreTaskObject?.Server?.ConnectionContext;
if (connection != null && connection.IsOpen)
{
connection.Disconnect();
}
sessions.TryRemove(sessionId, out restoreTaskObject);
return true;
}
return false;
}
/// <summary>
/// Creates a restore plan, The result includes the information about the backup set,
/// the files and the database to restore to