mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-22 09:35:38 -05:00
Change to pass Schema compare Operation id from ADS (#828)
* Changing that SC Operation id be passed from ADS and some test addition * Fixing typos
This commit is contained in:
@@ -30,7 +30,7 @@ namespace Microsoft.SqlTools.ServiceLayer.SchemaCompare.Contracts
|
||||
/// <summary>
|
||||
/// filepath of scmp
|
||||
/// </summary>
|
||||
public string filePath { get; set; }
|
||||
public string FilePath { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -50,6 +50,11 @@ namespace Microsoft.SqlTools.ServiceLayer.SchemaCompare.Contracts
|
||||
/// </summary>
|
||||
public class SchemaCompareParams
|
||||
{
|
||||
/// <summary>
|
||||
/// Operation id of the schema compare operation
|
||||
/// </summary>
|
||||
public string OperationId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the source endpoint info
|
||||
/// </summary>
|
||||
|
||||
@@ -74,10 +74,10 @@ namespace Microsoft.SqlTools.ServiceLayer.SchemaCompare
|
||||
|
||||
try
|
||||
{
|
||||
SchemaComparison compare = new SchemaComparison(this.Parameters.filePath);
|
||||
SchemaComparison compare = new SchemaComparison(this.Parameters.FilePath);
|
||||
|
||||
// load xml file because some parsing still needs to be done
|
||||
this.scmpInfo = XDocument.Load(this.Parameters.filePath);
|
||||
this.scmpInfo = XDocument.Load(this.Parameters.FilePath);
|
||||
|
||||
this.Result = new SchemaCompareOpenScmpResult()
|
||||
{
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Microsoft.SqlTools.ServiceLayer.SchemaCompare
|
||||
this.Parameters = parameters;
|
||||
this.SourceConnectionString = SchemaCompareUtils.GetConnectionString(sourceConnInfo, parameters.SourceEndpointInfo.DatabaseName);
|
||||
this.TargetConnectionString = SchemaCompareUtils.GetConnectionString(targetConnInfo, parameters.TargetEndpointInfo.DatabaseName);
|
||||
this.OperationId = Guid.NewGuid().ToString();
|
||||
this.OperationId = !string.IsNullOrEmpty(parameters.OperationId) ? parameters.OperationId : Guid.NewGuid().ToString();
|
||||
}
|
||||
|
||||
protected CancellationToken CancellationToken { get { return this.cancellation.Token; } }
|
||||
|
||||
@@ -96,6 +96,10 @@ namespace Microsoft.SqlTools.ServiceLayer.SchemaCompare
|
||||
AreEqual = operation.ComparisonResult.IsEqual,
|
||||
Differences = operation.Differences
|
||||
});
|
||||
|
||||
// clean up cancellation action now that the operation is complete (using try remove to avoid exception)
|
||||
Action cancelAction = null;
|
||||
currentComparisonCancellationAction.Value.TryRemove(operation.OperationId, out cancelAction);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -126,7 +130,7 @@ namespace Microsoft.SqlTools.ServiceLayer.SchemaCompare
|
||||
Action cancelAction = null;
|
||||
if (currentComparisonCancellationAction.Value.TryRemove(parameters.OperationId, out cancelAction))
|
||||
{
|
||||
if(cancelAction != null)
|
||||
if (cancelAction != null)
|
||||
{
|
||||
cancelAction.Invoke();
|
||||
await requestContext.SendResult(new ResultStatus()
|
||||
@@ -136,11 +140,14 @@ namespace Microsoft.SqlTools.ServiceLayer.SchemaCompare
|
||||
});
|
||||
}
|
||||
}
|
||||
await requestContext.SendResult(new ResultStatus()
|
||||
else
|
||||
{
|
||||
Success = false,
|
||||
ErrorMessage = SR.SchemaCompareSessionNotFound
|
||||
});
|
||||
await requestContext.SendResult(new ResultStatus()
|
||||
{
|
||||
Success = false,
|
||||
ErrorMessage = SR.SchemaCompareSessionNotFound
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -183,7 +190,7 @@ namespace Microsoft.SqlTools.ServiceLayer.SchemaCompare
|
||||
{
|
||||
Success = false,
|
||||
ErrorMessage = operation == null ? e.Message : operation.ErrorMessage,
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,7 +347,7 @@ namespace Microsoft.SqlTools.ServiceLayer.SchemaCompare
|
||||
{
|
||||
operation = new SchemaCompareSaveScmpOperation(parameters, sourceConnInfo, targetConnInfo);
|
||||
operation.Execute(parameters.TaskExecutionMode);
|
||||
|
||||
|
||||
await requestContext.SendResult(new ResultStatus()
|
||||
{
|
||||
Success = true,
|
||||
@@ -357,7 +364,7 @@ namespace Microsoft.SqlTools.ServiceLayer.SchemaCompare
|
||||
ErrorMessage = operation == null ? e.Message : operation.ErrorMessage,
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user