mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-13 17:23:02 -05:00
Add ServerPrototypes for different server versions to fix unsupported property errors (#2261)
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -6,6 +6,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.SqlServer.Management.Common;
|
||||||
using Microsoft.SqlServer.Management.Smo;
|
using Microsoft.SqlServer.Management.Smo;
|
||||||
using Microsoft.SqlTools.ServiceLayer.Connection;
|
using Microsoft.SqlTools.ServiceLayer.Connection;
|
||||||
using Microsoft.SqlTools.ServiceLayer.Management;
|
using Microsoft.SqlTools.ServiceLayer.Management;
|
||||||
@@ -38,29 +39,22 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
|
|||||||
ConnectionInfo connInfo = this.GetConnectionInfo(requestParams.ConnectionUri);
|
ConnectionInfo connInfo = this.GetConnectionInfo(requestParams.ConnectionUri);
|
||||||
CDataContainer dataContainer = CDataContainer.CreateDataContainer(connInfo, databaseExists: true);
|
CDataContainer dataContainer = CDataContainer.CreateDataContainer(connInfo, databaseExists: true);
|
||||||
|
|
||||||
ServerPrototype prototype = new ServerPrototype(dataContainer);
|
ServerPrototype prototype = CreateServerPrototype(dataContainer.Server, dataContainer.ServerConnection);
|
||||||
|
|
||||||
if (prototype != null)
|
if (prototype != null)
|
||||||
{
|
{
|
||||||
this.serverViewInfo.ObjectInfo = new ServerInfo()
|
var serverObjInfo = new ServerInfo()
|
||||||
{
|
{
|
||||||
Name = prototype.Name,
|
Name = prototype.Name,
|
||||||
HardwareGeneration = prototype.HardwareGeneration,
|
|
||||||
Language = prototype.Language,
|
Language = prototype.Language,
|
||||||
MemoryInMB = prototype.MemoryInMB,
|
MemoryInMB = prototype.MemoryInMB,
|
||||||
OperatingSystem = prototype.OperatingSystem,
|
|
||||||
Platform = prototype.Platform,
|
|
||||||
Processors = prototype.Processors,
|
Processors = prototype.Processors,
|
||||||
IsClustered = prototype.IsClustered,
|
IsClustered = prototype.IsClustered,
|
||||||
IsHadrEnabled = prototype.IsHadrEnabled,
|
IsHadrEnabled = prototype.IsHadrEnabled,
|
||||||
IsPolyBaseInstalled = prototype.IsPolyBaseInstalled,
|
|
||||||
IsXTPSupported = prototype.IsXTPSupported,
|
IsXTPSupported = prototype.IsXTPSupported,
|
||||||
Product = prototype.Product,
|
Product = prototype.Product,
|
||||||
ReservedStorageSizeMB = prototype.ReservedStorageSizeMB,
|
|
||||||
RootDirectory = prototype.RootDirectory,
|
RootDirectory = prototype.RootDirectory,
|
||||||
ServerCollation = prototype.ServerCollation,
|
ServerCollation = prototype.ServerCollation,
|
||||||
ServiceTier = prototype.ServiceTier,
|
|
||||||
StorageSpaceUsageInMB = prototype.StorageSpaceUsageInMB,
|
|
||||||
Version = prototype.Version,
|
Version = prototype.Version,
|
||||||
MinServerMemory = prototype.MinServerMemory,
|
MinServerMemory = prototype.MinServerMemory,
|
||||||
MaxServerMemory = prototype.MaxServerMemory,
|
MaxServerMemory = prototype.MaxServerMemory,
|
||||||
@@ -89,6 +83,24 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
|
|||||||
MaxDegreeParallelism = prototype.MaxDegreeParallelism,
|
MaxDegreeParallelism = prototype.MaxDegreeParallelism,
|
||||||
QueryWait = prototype.QueryWait
|
QueryWait = prototype.QueryWait
|
||||||
};
|
};
|
||||||
|
if (prototype is ServerPrototypeMI sMI)
|
||||||
|
{
|
||||||
|
serverObjInfo.HardwareGeneration = sMI.HardwareGeneration;
|
||||||
|
serverObjInfo.ServiceTier = sMI.ServiceTier;
|
||||||
|
serverObjInfo.ReservedStorageSizeMB = sMI.ReservedStorageSizeMB;
|
||||||
|
serverObjInfo.StorageSpaceUsageInMB = sMI.StorageSpaceUsageInMB;
|
||||||
|
}
|
||||||
|
if (prototype is ServerPrototype140 s140)
|
||||||
|
{
|
||||||
|
serverObjInfo.OperatingSystem = s140.OperatingSystem;
|
||||||
|
serverObjInfo.Platform = s140.Platform;
|
||||||
|
}
|
||||||
|
if (prototype is ServerPrototype130 s130)
|
||||||
|
{
|
||||||
|
serverObjInfo.IsPolyBaseInstalled = s130.IsPolyBaseInstalled;
|
||||||
|
}
|
||||||
|
|
||||||
|
serverViewInfo.ObjectInfo = serverObjInfo;
|
||||||
serverViewInfo.LanguageOptions = (LanguageUtils.GetDefaultLanguageOptions(dataContainer)).Select(element => element.Language.Alias).ToArray();
|
serverViewInfo.LanguageOptions = (LanguageUtils.GetDefaultLanguageOptions(dataContainer)).Select(element => element.Language.Alias).ToArray();
|
||||||
serverViewInfo.FullTextUpgradeOptions = Enum.GetNames(typeof(FullTextCatalogUpgradeOption)).ToArray();
|
serverViewInfo.FullTextUpgradeOptions = Enum.GetNames(typeof(FullTextCatalogUpgradeOption)).ToArray();
|
||||||
}
|
}
|
||||||
@@ -119,7 +131,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ServerPrototype prototype = new ServerPrototype(dataContainer);
|
ServerPrototype prototype = CreateServerPrototype(dataContainer.Server, dataContainer.ServerConnection);
|
||||||
prototype.ApplyInfoToPrototype(serverInfo);
|
prototype.ApplyInfoToPrototype(serverInfo);
|
||||||
return ConfigureServer(dataContainer, ConfigAction.Update, runType, prototype);
|
return ConfigureServer(dataContainer, ConfigAction.Update, runType, prototype);
|
||||||
}
|
}
|
||||||
@@ -149,5 +161,27 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
|
|||||||
return sqlScript;
|
return sqlScript;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ServerPrototype CreateServerPrototype(Server server, ServerConnection connection)
|
||||||
|
{
|
||||||
|
ServerPrototype prototype;
|
||||||
|
if (server.EngineEdition == Edition.SqlManagedInstance)
|
||||||
|
{
|
||||||
|
prototype = new ServerPrototypeMI(server, connection);
|
||||||
|
}
|
||||||
|
else if (server.VersionMajor >= 14)
|
||||||
|
{
|
||||||
|
prototype = new ServerPrototype140(server, connection);
|
||||||
|
}
|
||||||
|
else if (server.VersionMajor == 13)
|
||||||
|
{
|
||||||
|
prototype = new ServerPrototype130(server, connection);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
prototype = new ServerPrototype(server, connection);
|
||||||
|
}
|
||||||
|
return prototype;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14,7 +14,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class ServerInfo : SqlObject
|
public class ServerInfo : SqlObject
|
||||||
{
|
{
|
||||||
public string? HardwareGeneration { get; set; }
|
public string HardwareGeneration { get; set; }
|
||||||
public string Language { get; set; }
|
public string Language { get; set; }
|
||||||
public int MemoryInMB { get; set; }
|
public int MemoryInMB { get; set; }
|
||||||
public string OperatingSystem { get; set; }
|
public string OperatingSystem { get; set; }
|
||||||
@@ -22,13 +22,13 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
|
|||||||
public int Processors { get; set; }
|
public int Processors { get; set; }
|
||||||
public bool IsClustered { get; set; }
|
public bool IsClustered { get; set; }
|
||||||
public bool IsHadrEnabled { get; set; }
|
public bool IsHadrEnabled { get; set; }
|
||||||
public bool IsPolyBaseInstalled { get; set; }
|
public bool? IsPolyBaseInstalled { get; set; }
|
||||||
public bool? IsXTPSupported { get; set; }
|
public bool? IsXTPSupported { get; set; }
|
||||||
public string Product { get; set; }
|
public string Product { get; set; }
|
||||||
public int? ReservedStorageSizeMB { get; set; }
|
public int? ReservedStorageSizeMB { get; set; }
|
||||||
public string RootDirectory { get; set; }
|
public string RootDirectory { get; set; }
|
||||||
public string ServerCollation { get; set; }
|
public string ServerCollation { get; set; }
|
||||||
public string? ServiceTier { get; set; }
|
public string ServiceTier { get; set; }
|
||||||
public int? StorageSpaceUsageInMB { get; set; }
|
public int? StorageSpaceUsageInMB { get; set; }
|
||||||
public string Version { get; set; }
|
public string Version { get; set; }
|
||||||
public NumericServerProperty MaxServerMemory { get; set; }
|
public NumericServerProperty MaxServerMemory { get; set; }
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -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.SqlServer.Management.Common;
|
||||||
|
using Microsoft.SqlServer.Management.Smo;
|
||||||
|
|
||||||
|
namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
|
||||||
|
{
|
||||||
|
internal class ServerPrototype130 : ServerPrototype
|
||||||
|
{
|
||||||
|
public ServerPrototype130(Server server, ServerConnection connection) : base(server, connection) { }
|
||||||
|
|
||||||
|
public bool IsPolyBaseInstalled
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this.currentState.IsPolyBaseInstalled;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this.currentState.IsPolyBaseInstalled = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void ApplyInfoToPrototype(ServerInfo serverInfo)
|
||||||
|
{
|
||||||
|
base.ApplyInfoToPrototype(serverInfo);
|
||||||
|
|
||||||
|
this.IsPolyBaseInstalled = serverInfo.IsPolyBaseInstalled.GetValueOrDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
//
|
||||||
|
// 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.Management.Common;
|
||||||
|
using Microsoft.SqlServer.Management.Smo;
|
||||||
|
|
||||||
|
namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
|
||||||
|
{
|
||||||
|
internal class ServerPrototype140 : ServerPrototype130
|
||||||
|
{
|
||||||
|
public ServerPrototype140(Server server, ServerConnection connection) : base(server, connection) { }
|
||||||
|
|
||||||
|
public string OperatingSystem
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this.currentState.OperatingSystem;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this.currentState.OperatingSystem = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Platform
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this.currentState.Platform;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this.currentState.Platform = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void ApplyInfoToPrototype(ServerInfo serverInfo)
|
||||||
|
{
|
||||||
|
base.ApplyInfoToPrototype(serverInfo);
|
||||||
|
|
||||||
|
this.OperatingSystem = serverInfo.OperatingSystem;
|
||||||
|
this.Platform = serverInfo.Platform;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
//
|
||||||
|
// 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.Management.Common;
|
||||||
|
using Microsoft.SqlServer.Management.Smo;
|
||||||
|
|
||||||
|
namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Prototype for representing a manage instance server.
|
||||||
|
/// </summary>
|
||||||
|
internal class ServerPrototypeMI : ServerPrototype140
|
||||||
|
{
|
||||||
|
public ServerPrototypeMI(Server server, ServerConnection connection) : base(server, connection) { }
|
||||||
|
|
||||||
|
public string HardwareGeneration
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this.currentState.HardwareGeneration;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this.currentState.HardwareGeneration = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ServiceTier
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this.currentState.ServiceTier;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this.currentState.ServiceTier = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int StorageSpaceUsageInMB
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this.currentState.StorageSpaceUsageInMB;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this.currentState.StorageSpaceUsageInMB = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int ReservedStorageSizeMB
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this.currentState.ReservedStorageSizeMB;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this.currentState.ReservedStorageSizeMB = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void ApplyInfoToPrototype(ServerInfo serverInfo)
|
||||||
|
{
|
||||||
|
base.ApplyInfoToPrototype(serverInfo);
|
||||||
|
|
||||||
|
this.HardwareGeneration = serverInfo.HardwareGeneration;
|
||||||
|
this.ServiceTier = serverInfo.ServiceTier;
|
||||||
|
this.ReservedStorageSizeMB = serverInfo.ReservedStorageSizeMB.GetValueOrDefault();
|
||||||
|
this.StorageSpaceUsageInMB = serverInfo.StorageSpaceUsageInMB.GetValueOrDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user