Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scripting API implemented by the SqlScriptPublishModel #316

Merged
merged 34 commits into from Apr 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
30c07eb
Add nuget package SqlScriptPublishModel.
pensivebrian Mar 12, 2017
2e6813a
Initial commit of the scripting service.
pensivebrian Mar 21, 2017
9e2dfe3
Add list object and script object support to the scripter service.
pensivebrian Mar 22, 2017
5b2f86b
Merge dev branch
pensivebrian Mar 26, 2017
b6e5c59
Refresh SMO from SSMS_Rel 14.0.17049.0
pensivebrian Mar 31, 2017
9d9438a
Add scripting include/exclude object filter support
pensivebrian Apr 7, 2017
dba5ed5
Fix null ref in ScriptingObject.GetHashCode()
pensivebrian Apr 7, 2017
81ea9ea
Log object being scripted
pensivebrian Apr 8, 2017
43f4d4b
Fix scripting against SQL running in a docker container.
pensivebrian Apr 9, 2017
4fe577b
Refactor scripting operation to lazily load the server name from SMO
pensivebrian Apr 14, 2017
c1ce933
merging dev
pensivebrian Apr 14, 2017
47db0c9
Format ScriptingOptions.cs
pensivebrian Apr 14, 2017
1c38721
Reformat some of the scripting operations
pensivebrian Apr 14, 2017
5d42466
Merge dev
pensivebrian Apr 14, 2017
562c693
Bump SMO version in doc samples
pensivebrian Apr 14, 2017
6024b0e
Run srgen and fix build and test failures
pensivebrian Apr 14, 2017
4a2a965
Rename the ScriptingService method from HandleExecuteRequest to Handl…
pensivebrian Apr 14, 2017
d32d820
Reuse a shared northwind database to speed up the scripting tests
pensivebrian Apr 15, 2017
b801efb
Docs the ScriptingExtensionMethods class
pensivebrian Apr 15, 2017
9be1640
Add docs to ScriptingObjectMatchProcessor
pensivebrian Apr 15, 2017
ce48e89
Introduce a Cleanup method for the TestDriver.Tests
pensivebrian Apr 15, 2017
83afb81
Actually reuse the same Northwind database for all scripting tests
pensivebrian Apr 15, 2017
e492c32
SMO Urn and code review fixes
pensivebrian Apr 17, 2017
8771009
Misc code review fixes and docs
pensivebrian Apr 19, 2017
327c659
Merging dev
pensivebrian Apr 19, 2017
7f1b685
Code review feedback
pensivebrian Apr 20, 2017
4ad88e9
Misc Fixes
pensivebrian Apr 20, 2017
8df5a61
Use resources for string and rename ScriptingListObjectsCompleteParam…
pensivebrian Apr 20, 2017
a1e56de
Fix test ScriptSchemaInvalidConnectionString and shorten a few test t…
pensivebrian Apr 20, 2017
a596f54
User nullable bools for the ScriptOptions properties
pensivebrian Apr 20, 2017
56f6977
Merge branch 'dev' into feature/scripterService
pensivebrian Apr 21, 2017
d7bbd85
Doc update for ScriptingObjectMatchProcessor
pensivebrian Apr 21, 2017
60b4afd
Rename ScriptingObjectMatchProcessor to ScriptingObjectMatcher
pensivebrian Apr 24, 2017
aeffd07
Merge branch 'dev' into feature/scripterService
pensivebrian Apr 24, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Binary file removed bin/nuget/Microsoft.SqlServer.Smo.14.0.17028.nupkg
Binary file not shown.
Binary file not shown.
6 changes: 3 additions & 3 deletions docs/samples/jsonrpc/netcore/executequery/project.json
Expand Up @@ -4,19 +4,19 @@
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
},
"dependencies": {
"Microsoft.SqlTools.ServiceLayer": {
"target": "project"
},
"Newtonsoft.Json": "9.0.1",
"System.Data.Common": "4.1.0",
"System.Data.SqlClient": "4.4.0-sqltools-24613-04",
"Microsoft.SqlServer.Smo": "14.0.17028",
"Microsoft.SqlServer.Smo": "140.17049.0",
"System.Security.SecureString": "4.0.0",
"System.Collections.Specialized": "4.0.1",
"System.ComponentModel.TypeConverter": "4.1.0",
"System.Diagnostics.Contracts": "4.0.1",
"System.Diagnostics.Contracts": "4.0.1",
"System.Diagnostics.TraceSource": "4.0.0",
"NETStandard.Library": "1.6.0",
"Microsoft.NETCore.Runtime.CoreCLR": "1.0.2",
Expand Down
2 changes: 1 addition & 1 deletion docs/samples/smo/netcore/ModifySetting/project.json
Expand Up @@ -5,7 +5,7 @@
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.SqlServer.Smo": "14.0.17028"
"Microsoft.SqlServer.Smo": "140.17049.0"
},
"frameworks": {
"netcoreapp1.0": {
Expand Down
22 changes: 22 additions & 0 deletions src/Microsoft.SqlTools.Hosting/Utility/Extensions.cs
Expand Up @@ -56,4 +56,26 @@ public static bool HasTrue(this bool? obj)
return obj.HasValue && obj.Value;
}
}

public static class ExceptionExtensions
{
/// <summary>
/// Returns true if the passed exception or any inner exception is an OperationCanceledException instance.
/// </summary>
public static bool IsOperationCanceledException(this Exception e)
{
Exception current = e;
while (current != null)
{
if (current is OperationCanceledException)
{
return true;
}

current = current.InnerException;
}

return false;
}
}
}
33 changes: 33 additions & 0 deletions src/Microsoft.SqlTools.ServiceLayer/Localization/sr.cs
Expand Up @@ -2157,6 +2157,30 @@ public static string SchemaHierarchy_ColumnEncryptionKeys
}
}

public static string ScriptingParams_ConnectionString_Property_Invalid
{
get
{
return Keys.GetString(Keys.ScriptingParams_ConnectionString_Property_Invalid);
}
}

public static string ScriptingParams_FilePath_Property_Invalid
{
get
{
return Keys.GetString(Keys.ScriptingParams_FilePath_Property_Invalid);
}
}

public static string ScriptingListObjectsCompleteParams_ConnectionString_Property_Invalid
{
get
{
return Keys.GetString(Keys.ScriptingListObjectsCompleteParams_ConnectionString_Property_Invalid);
}
}

public static string ConnectionServiceListDbErrorNotConnected(string uri)
{
return Keys.GetString(Keys.ConnectionServiceListDbErrorNotConnected, uri);
Expand Down Expand Up @@ -3075,6 +3099,15 @@ public class Keys
public const string SchemaHierarchy_ColumnEncryptionKeys = "SchemaHierarchy_ColumnEncryptionKeys";


public const string ScriptingParams_ConnectionString_Property_Invalid = "ScriptingParams_ConnectionString_Property_Invalid";


public const string ScriptingParams_FilePath_Property_Invalid = "ScriptingParams_FilePath_Property_Invalid";


public const string ScriptingListObjectsCompleteParams_ConnectionString_Property_Invalid = "ScriptingListObjectsCompleteParams_ConnectionString_Property_Invalid";


private Keys()
{ }

Expand Down
12 changes: 12 additions & 0 deletions src/Microsoft.SqlTools.ServiceLayer/Localization/sr.resx
Expand Up @@ -1251,4 +1251,16 @@
<value>Column Encryption Keys</value>
<comment></comment>
</data>
<data name="ScriptingParams_ConnectionString_Property_Invalid" xml:space="preserve">
<value>Error parsing ScriptingParams.ConnectionString property.</value>
<comment></comment>
</data>
<data name="ScriptingParams_FilePath_Property_Invalid" xml:space="preserve">
<value>Invalid directory specified by the ScriptingParams.FilePath property.</value>
<comment></comment>
</data>
<data name="ScriptingListObjectsCompleteParams_ConnectionString_Property_Invalid" xml:space="preserve">
<value>Error parsing ScriptingListObjectsCompleteParams.ConnectionString property.</value>
<comment></comment>
</data>
</root>
8 changes: 8 additions & 0 deletions src/Microsoft.SqlTools.ServiceLayer/Localization/sr.strings
Expand Up @@ -623,3 +623,11 @@ SchemaHierarchy_ColumnMasterKeys = Column Master Keys

SchemaHierarchy_ColumnEncryptionKeys = Column Encryption Keys

############################################################################
# Scripting Service

ScriptingParams_ConnectionString_Property_Invalid = Error parsing ScriptingParams.ConnectionString property.

ScriptingParams_FilePath_Property_Invalid = Invalid directory specified by the ScriptingParams.FilePath property.

ScriptingListObjectsCompleteParams_ConnectionString_Property_Invalid = Error parsing ScriptingListObjectsCompleteParams.ConnectionString property.
15 changes: 15 additions & 0 deletions src/Microsoft.SqlTools.ServiceLayer/Localization/sr.xlf
Expand Up @@ -1416,6 +1416,21 @@
<target state="new">Server</target>
<note></note>
</trans-unit>
<trans-unit id="ScriptingParams_ConnectionString_Property_Invalid">
<source>Error parsing ScriptingParams.ConnectionString property.</source>
<target state="new">Error parsing ScriptingParams.ConnectionString property.</target>
<note></note>
</trans-unit>
<trans-unit id="ScriptingParams_FilePath_Property_Invalid">
<source>Invalid directory specified by the ScriptingParams.FilePath property.</source>
<target state="new">Invalid directory specified by the ScriptingParams.FilePath property.</target>
<note></note>
</trans-unit>
<trans-unit id="ScriptingListObjectsCompleteParams_ConnectionString_Property_Invalid">
<source>Error parsing ScriptingListObjectsCompleteParams.ConnectionString property.</source>
<target state="new">Error parsing ScriptingListObjectsCompleteParams.ConnectionString property.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
@@ -0,0 +1,28 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//

using Microsoft.SqlTools.Hosting.Protocol.Contracts;

namespace Microsoft.SqlTools.ServiceLayer.Scripting.Contracts
{
/// <summary>
/// Parameters to cancel a scripting request.
/// </summary>
public class ScriptingCancelParams : ScriptingEventParams { }

/// <summary>
/// Parameters returned from a scripting request.
/// </summary>
public class ScriptingCancelResult { }

/// <summary>
/// Defines the scripting cancel request type.
/// </summary>
public class ScriptingCancelRequest
{
public static readonly RequestType<ScriptingCancelParams, ScriptingCancelResult> Type =
RequestType<ScriptingCancelParams, ScriptingCancelResult>.Create("scripting/scriptCancel");
}
}
@@ -0,0 +1,34 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//

using Microsoft.SqlTools.Hosting.Protocol.Contracts;

namespace Microsoft.SqlTools.ServiceLayer.Scripting.Contracts
{
/// <summary>
/// Parameters sent to when a scripting operation has completed.
/// </summary>
public class ScriptingCompleteParams : ScriptingEventParams
{
public string ErrorDetails { get; set; }

public string ErrorMessage { get; set; }

public bool HasError { get; set; }

public bool Canceled { get; set; }

public bool Success { get; set; }
}

/// <summary>
/// Event sent to indicate a scripting operation has completed.
/// </summary>
public class ScriptingCompleteEvent
{
public static readonly EventType<ScriptingCompleteParams> Type =
EventType<ScriptingCompleteParams>.Create("scripting/scriptComplete");
}
}
@@ -0,0 +1,18 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//

namespace Microsoft.SqlTools.ServiceLayer.Scripting.Contracts
{
/// <summary>
/// Base class for all scripting event parameters.
/// </summary>
public abstract class ScriptingEventParams
{
/// <summary>
/// Gets or sets the operation id of the scripting operation this event is associated with.
/// </summary>
public string OperationId { get; set; }
}
}
@@ -0,0 +1,35 @@
//
// 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 sent when a list objects operation has completed.
/// </summary>
public class ScriptingListObjectsCompleteParams : ScriptingCompleteParams
{
/// <summary>
/// Gets or sets the list of database objects returned from the list objects operation.
/// </summary>
public List<ScriptingObject> DatabaseObjects { get; set; }

/// <summary>
/// Gets or sets the count of database object returned from the list objects operation.
/// </summary>
public int Count { get; set; }
}

/// <summary>
/// Event sent to indicate a list objects operation has completed.
/// </summary>
public class ScriptingListObjectsCompleteEvent
{
public static readonly EventType<ScriptingListObjectsCompleteParams> Type =
EventType<ScriptingListObjectsCompleteParams>.Create("scripting/listObjectsComplete");
}
}
@@ -0,0 +1,35 @@
//
// 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 list objects request.
/// </summary>
public class ScriptingListObjectsParams
{
public string ConnectionString { get; set; }
}

/// <summary>
/// Parameters returned from a list objects request.
/// </summary>
public class ScriptingListObjectsResult
{
public string OperationId { get; set; }
}

/// <summary>
/// Defines the scripting list objects request type.
/// </summary>
public class ScriptingListObjectsRequest
{
public static readonly RequestType<ScriptingListObjectsParams, ScriptingListObjectsResult> Type =
RequestType<ScriptingListObjectsParams, ScriptingListObjectsResult>.Create("scripting/listObjects");
}
}