Sql Proj Extract from database to Sql files (#949)

* SqlToolsServices changes for  Sql Proj Extract from database to Sql files

* Bumped DacFx version. Addressed comments.
This commit is contained in:
Sakshi Sharma
2020-04-27 18:35:19 -07:00
committed by GitHub
parent 314627f83c
commit 96df91c8fa
11 changed files with 122 additions and 9 deletions

View File

@@ -2,10 +2,11 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System;
using Microsoft.SqlServer.Dac;
using Microsoft.SqlTools.Hosting.Protocol.Contracts;
using Microsoft.SqlTools.ServiceLayer.TaskServices;
using Microsoft.SqlTools.ServiceLayer.Utility;
using System;
namespace Microsoft.SqlTools.ServiceLayer.DacFx.Contracts
{
@@ -23,6 +24,11 @@ namespace Microsoft.SqlTools.ServiceLayer.DacFx.Contracts
/// Gets or sets the version of the DAC application
/// </summary>
public string ApplicationVersion { get; set; }
/// <summary>
/// Gets or sets the target for extraction
/// </summary>
public DacExtractTarget ExtractTarget { get; set; }
}
/// <summary>

View File

@@ -2,6 +2,7 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using Microsoft.SqlServer.Dac;
using Microsoft.SqlTools.Hosting.Protocol;
using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.DacFx.Contracts;
@@ -117,7 +118,8 @@ namespace Microsoft.SqlTools.ServiceLayer.DacFx
// Set connection details database name to ensure the connection string gets created correctly for DW(extract doesn't work if connection is to master)
connInfo.ConnectionDetails.DatabaseName = parameters.DatabaseName;
ExtractOperation operation = new ExtractOperation(parameters, connInfo);
ExecuteOperation(operation, parameters, SR.ExtractDacpacTaskName, requestContext);
string taskName = parameters.ExtractTarget == DacExtractTarget.DacPac ? SR.ExtractDacpacTaskName : SR.ProjectExtractTaskName;
ExecuteOperation(operation, parameters, taskName, requestContext);
}
}
catch (Exception e)

View File

@@ -30,7 +30,8 @@ namespace Microsoft.SqlTools.ServiceLayer.DacFx
public override void Execute()
{
Version version = ParseVersion(this.Parameters.ApplicationVersion);
this.DacServices.Extract(this.Parameters.PackageFilePath, this.Parameters.DatabaseName, this.Parameters.ApplicationName, version, null, null, null, this.CancellationToken);
DacExtractOptions extractOptions = GetExtractOptions(this.Parameters.ExtractTarget);
this.DacServices.Extract(this.Parameters.PackageFilePath, this.Parameters.DatabaseName, this.Parameters.ApplicationName, version, applicationDescription:null, tables:null, extractOptions:extractOptions, cancellationToken:this.CancellationToken);
}
public static Version ParseVersion(string incomingVersion)
@@ -43,5 +44,11 @@ namespace Microsoft.SqlTools.ServiceLayer.DacFx
return parsedVersion;
}
private DacExtractOptions GetExtractOptions(DacExtractTarget extractTarget)
{
DacExtractOptions extractOptions = new DacExtractOptions() { ExtractTarget = extractTarget };
return extractOptions;
}
}
}