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:
Aditya Bist
2019-03-28 10:36:07 -07:00
committed by GitHub
parent e261d77bb8
commit e0a1df13c6
2 changed files with 31 additions and 19 deletions

3
.vscode/launch.json vendored
View File

@@ -24,7 +24,8 @@
"request": "attach",
"processId": "${command:pickProcess}",
"requireExactSource": false,
"justMyCode": false
"justMyCode": false,
"enableStepFiltering": false
}
,]
}

View File

@@ -13,6 +13,7 @@ using Microsoft.SqlTools.ServiceLayer.Hosting;
using Microsoft.SqlTools.Utility;
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
@@ -103,16 +104,11 @@ namespace Microsoft.SqlTools.ServiceLayer.Cms
RegisteredServersStore store = new RegisteredServersStore(serverConn);
ServerGroup parentGroup = NavigateToServerGroup(store, cmsCreateParams.RelativePath);
RegisteredServerCollection servers = parentGroup.RegisteredServers;
// Add the new server (intentionally not cheching existence to reuse the exception message)
RegisteredServer registeredServer = new RegisteredServer(parentGroup, cmsCreateParams.RegisteredServerName);
if (cmsCreateParams.RegisteredServerConnectionDetails != null)
{
registeredServer.Description = cmsCreateParams.RegisteredServerDescription;
registeredServer.ConnectionString = serverConn.ConnectionString;
registeredServer.ServerName = cmsCreateParams.RegisteredServerConnectionDetails.ServerName;
registeredServer.Description = cmsCreateParams.RegisteredServerDescription;
registeredServer.ConnectionString = ConnectionService.CreateConnectionStringBuilder(cmsCreateParams.RegisteredServerConnectionDetails).ToString();
}
registeredServer.Description = cmsCreateParams.RegisteredServerDescription;
registeredServer.Create();
await requestContext.SendResult(true);
}
@@ -221,9 +217,19 @@ namespace Microsoft.SqlTools.ServiceLayer.Cms
try
{
ServerConnection serverConn = ValidateAndCreateConnection(addServerGroupParams.ParentOwnerUri);
if (serverConn != null)
{
ServerGroup parentGroup;
RegisteredServersStore store = new RegisteredServersStore(serverConn);
ServerGroup parentGroup = NavigateToServerGroup(store, addServerGroupParams.RelativePath);
// It's a CMS server
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)
{
@@ -232,6 +238,11 @@ namespace Microsoft.SqlTools.ServiceLayer.Cms
serverGroup.Create();
await requestContext.SendResult(true);
}
else
{
await requestContext.SendResult(false);
}
}
catch (Exception e)
{
await requestContext.SendError(e);
@@ -359,7 +370,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Cms
serverResults.Add(new RegisteredServerResult
{
Name = s.Name,
ServerName = s.ServerName,
ServerName = string.IsNullOrEmpty(s.ServerName) ? s.Name : s.ServerName,
Description = s.Description,
ConnectionDetails = ConnectionServiceInstance.ParseConnectionString(s.ConnectionString),
RelativePath = s.KeyChain.Urn.SafeToString()