mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-13 17:23:02 -05:00
58 lines
2.1 KiB
C#
58 lines
2.1 KiB
C#
//
|
|
// Copyright (c) Microsoft. All rights reserved.
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
//
|
|
|
|
#nullable disable
|
|
|
|
using System;
|
|
using System.Threading;
|
|
using Microsoft.SqlServer.Dac;
|
|
using Microsoft.SqlServer.Dac.Compare;
|
|
using Microsoft.SqlTools.ServiceLayer.SchemaCompare.Contracts;
|
|
using Microsoft.SqlTools.ServiceLayer.TaskServices;
|
|
using Microsoft.SqlTools.Utility;
|
|
|
|
namespace Microsoft.SqlTools.ServiceLayer.SchemaCompare
|
|
{
|
|
/// <summary>
|
|
/// Class to represent an in-progress schema compare publish project changes operation
|
|
/// </summary>
|
|
class SchemaComparePublishProjectChangesOperation: SchemaComparePublishChangesOperation
|
|
{
|
|
public SchemaComparePublishProjectChangesParams Parameters { get; }
|
|
|
|
public SchemaComparePublishProjectResult PublishResult { get; set; }
|
|
|
|
public SchemaComparePublishProjectChangesOperation(SchemaComparePublishProjectChangesParams parameters, SchemaComparisonResult comparisonResult) : base(comparisonResult)
|
|
{
|
|
Validate.IsNotNull(nameof(parameters), parameters);
|
|
Parameters = parameters;
|
|
}
|
|
|
|
public override void Execute(TaskExecutionMode mode)
|
|
{
|
|
if (CancellationToken.IsCancellationRequested)
|
|
{
|
|
throw new OperationCanceledException(CancellationToken);
|
|
}
|
|
|
|
try
|
|
{
|
|
PublishResult = ComparisonResult.PublishChangesToProject(Parameters.TargetProjectPath, Parameters.TargetFolderStructure);
|
|
|
|
if (!PublishResult.Success)
|
|
{
|
|
ErrorMessage = PublishResult.ErrorMessage;
|
|
throw new DacServicesException(ErrorMessage);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
ErrorMessage = e.Message;
|
|
Logger.Error(string.Format("Schema compare publish project changes operation {0} failed with exception {1}", OperationId, e.Message));
|
|
throw;
|
|
}
|
|
}
|
|
}
|
|
} |