Add scripting API implemented by the SqlScriptPublishModel (#316)

Update the ScriptingService to expose new scripting JSON-RPC APIs that use the SqlScriptPublishModel for script generation.

The SqlScriptPublishModel is the model behind the SSMS scripting wizard. To enable scripting for CLI tools, we've ported SqlScriptPublishModel to .NET Core. The SqlScriptPublishModel wraps the SMO scripting APIs for .sql script generation.

1) Added three new requests to the ScriptingService: ScriptingRequest, ScriptingListObjectsRequest, ScriptingCancelRequest.
2) Generating scripts are long running operations, so the ScriptingRequest and ScriptingListObjectsRequest kick off a long running scripting task and return immediately.
3) Long running scripting task reports progress and completion, and can be cancelled by a ScriptingCancelRequest request.
4) Bumped the SMO nuget package to 140.17049.0. This new version contains a signed SSMS_Rel build of SMO with the SqlScriptPublishModel.
5) For testing, adding the Northwind database schema

TODO (in later pull requests)
1) Integrate the new ScriptingService APIs with the ConnectionService
2) Integrate with the metadata support recently added
This commit is contained in:
Brian O'Neill
2017-04-24 16:10:20 -07:00
committed by GitHub
parent e65699ef75
commit 4aac4a4047
42 changed files with 7124 additions and 30 deletions

View File

@@ -0,0 +1,63 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System.Collections.Generic;
using Microsoft.SqlTools.Hosting.Protocol.Contracts;
namespace Microsoft.SqlTools.ServiceLayer.Scripting.Contracts
{
/// <summary>
/// Parameters for a script request.
/// </summary>
public class ScriptingParams
{
/// <summary>
/// Gets or sets the file path used when writing out the script.
/// </summary>
public string FilePath { get; set; }
/// <summary>
/// Gets or sets connection string of the target database the scripting operation will run against.
/// </summary>
public string ConnectionString { get; set; }
/// <summary>
/// Gets or sets a list of scripting objects to script.
/// </summary>
public List<ScriptingObject> ScriptingObjects { get; set; }
/// <summary>
/// Gets or sets a list of scripting object which specify the include criteria of objects to script.
/// </summary>
public List<ScriptingObject> IncludeObjectCriteria { get; set; }
/// <summary>
/// Gets or sets a list of scripting object which specify the exclude criteria of objects to not script.
/// </summary>
public List<ScriptingObject> ExcludeObjectCriteria { get; set; }
/// <summary>
/// Gets or sets the scripting options.
/// </summary>
public ScriptOptions ScriptOptions { get; set; }
}
/// <summary>
/// Parameters returned from a script request.
/// </summary>
public class ScriptingResult
{
public string OperationId { get; set; }
}
/// <summary>
/// Defines the scripting request type.
/// </summary>
public class ScriptingRequest
{
public static readonly RequestType<ScriptingParams, ScriptingResult> Type =
RequestType<ScriptingParams, ScriptingResult>.Create("scripting/script");
}
}