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

@@ -14,6 +14,7 @@ using Microsoft.SqlTools.ServiceLayer.DisasterRecovery.Contracts;
using Microsoft.SqlTools.ServiceLayer.DisasterRecovery.RestoreOperation;
using Microsoft.SqlTools.ServiceLayer.FileBrowser;
using Microsoft.SqlTools.ServiceLayer.TaskServices;
using Microsoft.SqlTools.Utility;
namespace Microsoft.SqlTools.ServiceLayer.DisasterRecovery
{
@@ -114,6 +115,9 @@ namespace Microsoft.SqlTools.ServiceLayer.DisasterRecovery
// Create restore plan
serviceHost.SetRequestHandler(RestorePlanRequest.Type, HandleRestorePlanRequest);
// Cancel restore plan
serviceHost.SetRequestHandler(CancelRestorePlanRequest.Type, HandleCancelRestorePlanRequest);
// Create restore config
serviceHost.SetRequestHandler(RestoreConfigInfoRequest.Type, HandleRestoreConfigInfoRequest);
@@ -164,6 +168,26 @@ namespace Microsoft.SqlTools.ServiceLayer.DisasterRecovery
}
}
/// <summary>
/// Handles a restore request
/// </summary>
internal async Task HandleCancelRestorePlanRequest(
RestoreParams restoreParams,
RequestContext<bool> requestContext)
{
bool result = false;
try
{
result = this.restoreDatabaseService.CancelRestorePlan(restoreParams);
await requestContext.SendResult(result);
}
catch (Exception ex)
{
Logger.Write(LogLevel.Error, "Failed to cancel restore session. error: " + ex.Message);
await requestContext.SendResult(result);
}
}
/// <summary>
/// Handles a restore request
/// </summary>