mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-13 17:23:02 -05:00
fix CMS Service issue (#782)
* fixed issue with add registered servers call * changed server name to alias * fixed issue with adding server group to cms server * remove script file
This commit is contained in:
3
.vscode/launch.json
vendored
3
.vscode/launch.json
vendored
@@ -24,7 +24,8 @@
|
|||||||
"request": "attach",
|
"request": "attach",
|
||||||
"processId": "${command:pickProcess}",
|
"processId": "${command:pickProcess}",
|
||||||
"requireExactSource": false,
|
"requireExactSource": false,
|
||||||
"justMyCode": false
|
"justMyCode": false,
|
||||||
|
"enableStepFiltering": false
|
||||||
}
|
}
|
||||||
,]
|
,]
|
||||||
}
|
}
|
||||||
@@ -13,6 +13,7 @@ using Microsoft.SqlTools.ServiceLayer.Hosting;
|
|||||||
using Microsoft.SqlTools.Utility;
|
using Microsoft.SqlTools.Utility;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Data.Common;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -96,23 +97,18 @@ namespace Microsoft.SqlTools.ServiceLayer.Cms
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ServerConnection serverConn = ValidateAndCreateConnection(cmsCreateParams.ParentOwnerUri);
|
ServerConnection serverConn = ValidateAndCreateConnection(cmsCreateParams.ParentOwnerUri);
|
||||||
if (serverConn != null)
|
if (serverConn != null)
|
||||||
{
|
{
|
||||||
// Get Current Reg Servers
|
// Get Current Reg Servers
|
||||||
RegisteredServersStore store = new RegisteredServersStore(serverConn);
|
RegisteredServersStore store = new RegisteredServersStore(serverConn);
|
||||||
ServerGroup parentGroup = NavigateToServerGroup(store, cmsCreateParams.RelativePath);
|
ServerGroup parentGroup = NavigateToServerGroup(store, cmsCreateParams.RelativePath);
|
||||||
RegisteredServerCollection servers = parentGroup.RegisteredServers;
|
RegisteredServerCollection servers = parentGroup.RegisteredServers;
|
||||||
|
|
||||||
// Add the new server (intentionally not cheching existence to reuse the exception message)
|
// Add the new server (intentionally not cheching existence to reuse the exception message)
|
||||||
RegisteredServer registeredServer = new RegisteredServer(parentGroup, cmsCreateParams.RegisteredServerName);
|
RegisteredServer registeredServer = new RegisteredServer(parentGroup, cmsCreateParams.RegisteredServerName);
|
||||||
if (cmsCreateParams.RegisteredServerConnectionDetails != null)
|
|
||||||
{
|
|
||||||
registeredServer.ServerName = cmsCreateParams.RegisteredServerConnectionDetails.ServerName;
|
|
||||||
registeredServer.Description = cmsCreateParams.RegisteredServerDescription;
|
|
||||||
registeredServer.ConnectionString = ConnectionService.CreateConnectionStringBuilder(cmsCreateParams.RegisteredServerConnectionDetails).ToString();
|
|
||||||
}
|
|
||||||
registeredServer.Description = cmsCreateParams.RegisteredServerDescription;
|
registeredServer.Description = cmsCreateParams.RegisteredServerDescription;
|
||||||
|
registeredServer.ConnectionString = serverConn.ConnectionString;
|
||||||
|
registeredServer.ServerName = cmsCreateParams.RegisteredServerConnectionDetails.ServerName;
|
||||||
registeredServer.Create();
|
registeredServer.Create();
|
||||||
await requestContext.SendResult(true);
|
await requestContext.SendResult(true);
|
||||||
}
|
}
|
||||||
@@ -221,16 +217,31 @@ namespace Microsoft.SqlTools.ServiceLayer.Cms
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
ServerConnection serverConn = ValidateAndCreateConnection(addServerGroupParams.ParentOwnerUri);
|
ServerConnection serverConn = ValidateAndCreateConnection(addServerGroupParams.ParentOwnerUri);
|
||||||
RegisteredServersStore store = new RegisteredServersStore(serverConn);
|
if (serverConn != null)
|
||||||
ServerGroup parentGroup = NavigateToServerGroup(store, addServerGroupParams.RelativePath);
|
|
||||||
|
|
||||||
// Add the new group (intentionally not cheching existence to reuse the exception message)
|
|
||||||
ServerGroup serverGroup = new ServerGroup(parentGroup, addServerGroupParams.GroupName)
|
|
||||||
{
|
{
|
||||||
Description = addServerGroupParams.GroupDescription
|
ServerGroup parentGroup;
|
||||||
};
|
RegisteredServersStore store = new RegisteredServersStore(serverConn);
|
||||||
serverGroup.Create();
|
// It's a CMS server
|
||||||
await requestContext.SendResult(true);
|
if (string.IsNullOrEmpty(addServerGroupParams.RelativePath))
|
||||||
|
{
|
||||||
|
parentGroup = store.DatabaseEngineServerGroup;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
parentGroup = NavigateToServerGroup(store, addServerGroupParams.RelativePath);
|
||||||
|
}
|
||||||
|
// Add the new group (intentionally not cheching existence to reuse the exception message)
|
||||||
|
ServerGroup serverGroup = new ServerGroup(parentGroup, addServerGroupParams.GroupName)
|
||||||
|
{
|
||||||
|
Description = addServerGroupParams.GroupDescription
|
||||||
|
};
|
||||||
|
serverGroup.Create();
|
||||||
|
await requestContext.SendResult(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await requestContext.SendResult(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -359,7 +370,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Cms
|
|||||||
serverResults.Add(new RegisteredServerResult
|
serverResults.Add(new RegisteredServerResult
|
||||||
{
|
{
|
||||||
Name = s.Name,
|
Name = s.Name,
|
||||||
ServerName = s.ServerName,
|
ServerName = string.IsNullOrEmpty(s.ServerName) ? s.Name : s.ServerName,
|
||||||
Description = s.Description,
|
Description = s.Description,
|
||||||
ConnectionDetails = ConnectionServiceInstance.ParseConnectionString(s.ConnectionString),
|
ConnectionDetails = ConnectionServiceInstance.ParseConnectionString(s.ConnectionString),
|
||||||
RelativePath = s.KeyChain.Urn.SafeToString()
|
RelativePath = s.KeyChain.Urn.SafeToString()
|
||||||
|
|||||||
Reference in New Issue
Block a user