mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-03 17:24:53 -05:00
Schema Compare open SCMP file (#825)
* initial open scmp changes * more open scmp changes and adding tests * moving some common test code * simplify endpoint info parsing * addressing comments and moving more common test code * addressing comments
This commit is contained in:
@@ -10,11 +10,10 @@ using Microsoft.SqlTools.ServiceLayer.TaskServices;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.SqlTools.ServiceLayer.SchemaCompare;
|
||||
using Microsoft.SqlServer.Dac.Compare;
|
||||
using Microsoft.SqlTools.ServiceLayer.Utility;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.SchemaCopmare
|
||||
namespace Microsoft.SqlTools.ServiceLayer.SchemaCompare
|
||||
{
|
||||
/// <summary>
|
||||
/// Main class for SchemaCompare service
|
||||
@@ -27,6 +26,9 @@ namespace Microsoft.SqlTools.ServiceLayer.SchemaCopmare
|
||||
private Lazy<ConcurrentDictionary<string, SchemaComparisonResult>> schemaCompareResults =
|
||||
new Lazy<ConcurrentDictionary<string, SchemaComparisonResult>>(() => new ConcurrentDictionary<string, SchemaComparisonResult>());
|
||||
|
||||
// For testability
|
||||
internal Task CurrentSchemaCompareTask;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the singleton instance object
|
||||
/// </summary>
|
||||
@@ -46,8 +48,11 @@ namespace Microsoft.SqlTools.ServiceLayer.SchemaCopmare
|
||||
serviceHost.SetRequestHandler(SchemaComparePublishChangesRequest.Type, this.HandleSchemaComparePublishChangesRequest);
|
||||
serviceHost.SetRequestHandler(SchemaCompareIncludeExcludeNodeRequest.Type, this.HandleSchemaCompareIncludeExcludeNodeRequest);
|
||||
serviceHost.SetRequestHandler(SchemaCompareGetDefaultOptionsRequest.Type, this.HandleSchemaCompareGetDefaultOptionsRequest);
|
||||
serviceHost.SetRequestHandler(SchemaCompareOpenScmpRequest.Type, this.HandleSchemaCompareOpenScmpRequest);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Handles schema compare request
|
||||
/// </summary>
|
||||
@@ -86,7 +91,7 @@ namespace Microsoft.SqlTools.ServiceLayer.SchemaCopmare
|
||||
Differences = operation.Differences
|
||||
});
|
||||
}
|
||||
catch(Exception e)
|
||||
catch (Exception e)
|
||||
{
|
||||
await requestContext.SendResult(new SchemaCompareResult()
|
||||
{
|
||||
@@ -185,7 +190,7 @@ namespace Microsoft.SqlTools.ServiceLayer.SchemaCopmare
|
||||
operation = new SchemaCompareIncludeExcludeNodeOperation(parameters, compareResult);
|
||||
|
||||
operation.Execute(parameters.TaskExecutionMode);
|
||||
|
||||
|
||||
await requestContext.SendResult(new ResultStatus()
|
||||
{
|
||||
Success = true,
|
||||
@@ -227,6 +232,41 @@ namespace Microsoft.SqlTools.ServiceLayer.SchemaCopmare
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles schema compare open SCMP request
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task HandleSchemaCompareOpenScmpRequest(SchemaCompareOpenScmpParams parameters, RequestContext<SchemaCompareOpenScmpResult> requestContext)
|
||||
{
|
||||
try
|
||||
{
|
||||
CurrentSchemaCompareTask = Task.Run(async () =>
|
||||
{
|
||||
SchemaCompareOpenScmpOperation operation = null;
|
||||
|
||||
try
|
||||
{
|
||||
operation = new SchemaCompareOpenScmpOperation(parameters);
|
||||
operation.Execute(TaskExecutionMode.Execute);
|
||||
|
||||
await requestContext.SendResult(operation.Result);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
await requestContext.SendResult(new SchemaCompareOpenScmpResult()
|
||||
{
|
||||
Success = false,
|
||||
ErrorMessage = operation == null ? e.Message : operation.ErrorMessage,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
await requestContext.SendError(e);
|
||||
}
|
||||
}
|
||||
|
||||
private SqlTaskManager SqlTaskManagerInstance
|
||||
{
|
||||
get
|
||||
|
||||
Reference in New Issue
Block a user