mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-28 01:25:44 -05:00
added contract to cancel restore plan and close the related connections (#522)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user