mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-17 02:51:45 -05:00
Added missing properties for databases and server (#373)
* added get database info to admin service * refactored code to be inline with standard * added comments to utils functions * added comments to public classes * added machine name to serverinfo from connection; added last backupdate and last log backup date to database info * removed camelcase from request type * removed the wrapper for the generic dictionary * removed unnecessary imports * merged master * changed datetime compare to equality operator * added database compatability level to info * renamed field * fixed CompatibilityLevel string typo, added bakcup dates to capabilities list
This commit is contained in:
@@ -151,7 +151,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
|||||||
}
|
}
|
||||||
|
|
||||||
await requestContext.SendResult(new GetDatabaseInfoResponse(){
|
await requestContext.SendResult(new GetDatabaseInfoResponse(){
|
||||||
Result = info
|
DatabaseInfo = info
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
|||||||
internal const string DatabaseContainmentType = "databaseContainmentType";
|
internal const string DatabaseContainmentType = "databaseContainmentType";
|
||||||
internal const string DatabaseState = "databaseState";
|
internal const string DatabaseState = "databaseState";
|
||||||
internal const string RecoveryModel = "recoveryModel";
|
internal const string RecoveryModel = "recoveryModel";
|
||||||
|
internal const string CompatibilityLevel = "compatibilityLevel";
|
||||||
|
internal const string LastBackupDate = "lastBackupDate";
|
||||||
|
internal const string LastLogBackupDate = "lastLogBackupDate";
|
||||||
internal const string FileGroupType = "fileGroupType";
|
internal const string FileGroupType = "fileGroupType";
|
||||||
internal const string IsDefault = "isDefault";
|
internal const string IsDefault = "isDefault";
|
||||||
internal const string IsFileStream = "isFileStream";
|
internal const string IsFileStream = "isFileStream";
|
||||||
@@ -205,6 +208,33 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
|||||||
GroupName = "Other"
|
GroupName = "Other"
|
||||||
},
|
},
|
||||||
new ServiceOption
|
new ServiceOption
|
||||||
|
{
|
||||||
|
Name = AdminServicesProviderOptionsHelper.LastBackupDate,
|
||||||
|
DisplayName = "LastBackupDate",
|
||||||
|
Description = "Last backup date",
|
||||||
|
ValueType = ServiceOption.ValueTypeString,
|
||||||
|
IsRequired = false,
|
||||||
|
GroupName = "Other"
|
||||||
|
},
|
||||||
|
new ServiceOption
|
||||||
|
{
|
||||||
|
Name = AdminServicesProviderOptionsHelper.LastLogBackupDate,
|
||||||
|
DisplayName = "LastLogBackupDate",
|
||||||
|
Description = "Last log backup date",
|
||||||
|
ValueType = ServiceOption.ValueTypeString,
|
||||||
|
IsRequired = false,
|
||||||
|
GroupName = "Other"
|
||||||
|
},
|
||||||
|
new ServiceOption
|
||||||
|
{
|
||||||
|
Name = AdminServicesProviderOptionsHelper.CompatibilityLevel,
|
||||||
|
DisplayName = "CompatibilityLevel",
|
||||||
|
Description = "Compatibility level",
|
||||||
|
ValueType = ServiceOption.ValueTypeString,
|
||||||
|
IsRequired = false,
|
||||||
|
GroupName = "Other"
|
||||||
|
},
|
||||||
|
new ServiceOption
|
||||||
{
|
{
|
||||||
Name = AdminServicesProviderOptionsHelper.FileGroups,
|
Name = AdminServicesProviderOptionsHelper.FileGroups,
|
||||||
DisplayName = "File Groups",
|
DisplayName = "File Groups",
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin.Contracts
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The object containing the database info
|
/// The object containing the database info
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DatabaseInfo Result { get; set; }
|
public DatabaseInfo DatabaseInfo { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
|||||||
public string collation;
|
public string collation;
|
||||||
|
|
||||||
public RecoveryModel recoveryModel;
|
public RecoveryModel recoveryModel;
|
||||||
|
public DateTime lastBackupDate;
|
||||||
|
public DateTime lastLogBackupDate;
|
||||||
public DatabaseUserAccess restrictAccess;
|
public DatabaseUserAccess restrictAccess;
|
||||||
public DatabaseStatus databaseState;
|
public DatabaseStatus databaseState;
|
||||||
public DefaultCursor defaultCursor;
|
public DefaultCursor defaultCursor;
|
||||||
@@ -373,6 +375,16 @@ WHERE do.database_id = @DbID
|
|||||||
this.recoveryModel = db.DatabaseOptions.RecoveryModel;
|
this.recoveryModel = db.DatabaseOptions.RecoveryModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (db.IsSupportedProperty("LastBackupDate"))
|
||||||
|
{
|
||||||
|
this.lastBackupDate = db.LastBackupDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (db.IsSupportedProperty("LastLogBackupDate"))
|
||||||
|
{
|
||||||
|
this.lastLogBackupDate = db.LastLogBackupDate;
|
||||||
|
}
|
||||||
|
|
||||||
if (Utils.IsSql12OrLater(context.Server.Information.Version.Major))
|
if (Utils.IsSql12OrLater(context.Server.Information.Version.Major))
|
||||||
{
|
{
|
||||||
this.autoCreateStatisticsIncremental = db.DatabaseOptions.AutoCreateStatisticsIncremental;
|
this.autoCreateStatisticsIncremental = db.DatabaseOptions.AutoCreateStatisticsIncremental;
|
||||||
@@ -651,6 +663,8 @@ WHERE do.database_id = @DbID
|
|||||||
this.name = other.name;
|
this.name = other.name;
|
||||||
this.collation = other.collation;
|
this.collation = other.collation;
|
||||||
this.recoveryModel = other.recoveryModel;
|
this.recoveryModel = other.recoveryModel;
|
||||||
|
this.lastBackupDate = other.lastBackupDate;
|
||||||
|
this.lastLogBackupDate = other.lastLogBackupDate;
|
||||||
this.restrictAccess = other.restrictAccess;
|
this.restrictAccess = other.restrictAccess;
|
||||||
this.databaseState = other.databaseState;
|
this.databaseState = other.databaseState;
|
||||||
this.defaultCursor = other.defaultCursor;
|
this.defaultCursor = other.defaultCursor;
|
||||||
@@ -730,6 +744,8 @@ WHERE do.database_id = @DbID
|
|||||||
{
|
{
|
||||||
bool result =
|
bool result =
|
||||||
(this.recoveryModel == other.recoveryModel) &&
|
(this.recoveryModel == other.recoveryModel) &&
|
||||||
|
(this.lastBackupDate == other.lastBackupDate) &&
|
||||||
|
(this.lastLogBackupDate == other.lastLogBackupDate) &&
|
||||||
(this.restrictAccess == other.restrictAccess) &&
|
(this.restrictAccess == other.restrictAccess) &&
|
||||||
(this.databaseState == other.databaseState) &&
|
(this.databaseState == other.databaseState) &&
|
||||||
(this.defaultCursor == other.defaultCursor) &&
|
(this.defaultCursor == other.defaultCursor) &&
|
||||||
@@ -891,6 +907,40 @@ WHERE do.database_id = @DbID
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The last backup date for the database
|
||||||
|
/// </summary>
|
||||||
|
[Browsable(false)]
|
||||||
|
public DateTime LastBackupDate
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this.currentState.lastBackupDate;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this.currentState.lastBackupDate = value;
|
||||||
|
this.NotifyObservers();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The last log backup date for the database
|
||||||
|
/// </summary>
|
||||||
|
[Browsable(false)]
|
||||||
|
public DateTime LastLogBackupDate
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this.currentState.lastLogBackupDate;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this.currentState.lastLogBackupDate = value;
|
||||||
|
this.NotifyObservers();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The collation for the database
|
/// The collation for the database
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -108,6 +108,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
|||||||
databaseInfo.Options.Add(AdminServicesProviderOptionsHelper.RecoveryModel, prototype.RecoveryModel.ToString());
|
databaseInfo.Options.Add(AdminServicesProviderOptionsHelper.RecoveryModel, prototype.RecoveryModel.ToString());
|
||||||
databaseInfo.Options.Add(AdminServicesProviderOptionsHelper.IsSystemDB, prototype.IsSystemDB.ToString());
|
databaseInfo.Options.Add(AdminServicesProviderOptionsHelper.IsSystemDB, prototype.IsSystemDB.ToString());
|
||||||
databaseInfo.Options.Add(AdminServicesProviderOptionsHelper.AnsiNulls, prototype.AnsiNulls.ToString());
|
databaseInfo.Options.Add(AdminServicesProviderOptionsHelper.AnsiNulls, prototype.AnsiNulls.ToString());
|
||||||
|
databaseInfo.Options.Add(AdminServicesProviderOptionsHelper.CompatibilityLevel, prototype.DatabaseCompatibilityLevel.ToString());
|
||||||
|
databaseInfo.Options.Add(AdminServicesProviderOptionsHelper.LastBackupDate, prototype.LastBackupDate.ToString());
|
||||||
|
databaseInfo.Options.Add(AdminServicesProviderOptionsHelper.LastLogBackupDate, prototype.LastLogBackupDate.ToString());
|
||||||
|
|
||||||
databaseInfo.Options.Add(
|
databaseInfo.Options.Add(
|
||||||
AdminServicesProviderOptionsHelper.FileGroups + "Count",
|
AdminServicesProviderOptionsHelper.FileGroups + "Count",
|
||||||
|
|||||||
@@ -317,7 +317,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
|
|||||||
ServerEdition = serverInfo.ServerEdition,
|
ServerEdition = serverInfo.ServerEdition,
|
||||||
IsCloud = serverInfo.IsCloud,
|
IsCloud = serverInfo.IsCloud,
|
||||||
AzureVersion = serverInfo.AzureVersion,
|
AzureVersion = serverInfo.AzureVersion,
|
||||||
OsVersion = serverInfo.OsVersion
|
OsVersion = serverInfo.OsVersion,
|
||||||
|
MachineName = serverInfo.MachineName
|
||||||
};
|
};
|
||||||
connectionInfo.IsAzure = serverInfo.IsCloud;
|
connectionInfo.IsAzure = serverInfo.IsCloud;
|
||||||
connectionInfo.MajorVersion = serverInfo.ServerMajorVersion;
|
connectionInfo.MajorVersion = serverInfo.ServerMajorVersion;
|
||||||
|
|||||||
@@ -59,5 +59,10 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.Contracts
|
|||||||
/// The Operating System version string of the machine running the SQL Server instance.
|
/// The Operating System version string of the machine running the SQL Server instance.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string OsVersion { get; set; }
|
public string OsVersion { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The Operating System version string of the machine running the SQL Server instance.
|
||||||
|
/// </summary>
|
||||||
|
public string MachineName { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -688,6 +688,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection
|
|||||||
}
|
}
|
||||||
|
|
||||||
public string OsVersion;
|
public string OsVersion;
|
||||||
|
|
||||||
|
public string MachineName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool TryGetServerVersion(string connectionString, out ServerInfo serverInfo)
|
public static bool TryGetServerVersion(string connectionString, out ServerInfo serverInfo)
|
||||||
@@ -751,11 +753,12 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection
|
|||||||
serverInfo.ServerVersion = reader[1].ToString();
|
serverInfo.ServerVersion = reader[1].ToString();
|
||||||
serverInfo.ServerLevel = reader[2].ToString();
|
serverInfo.ServerLevel = reader[2].ToString();
|
||||||
serverInfo.ServerEdition = reader[3].ToString();
|
serverInfo.ServerEdition = reader[3].ToString();
|
||||||
|
serverInfo.MachineName = reader[4].ToString();
|
||||||
|
|
||||||
if (reader.FieldCount > 4)
|
if (reader.FieldCount > 5)
|
||||||
{
|
{
|
||||||
// Detect the presence of SXI
|
// Detect the presence of SXI
|
||||||
serverInfo.IsSelectiveXmlIndexMetadataPresent = reader.GetInt32(4) == 1;
|
serverInfo.IsSelectiveXmlIndexMetadataPresent = reader.GetInt32(5) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The 'ProductVersion' server property is of the form ##.#[#].####.#,
|
// The 'ProductVersion' server property is of the form ##.#[#].####.#,
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection
|
|||||||
{
|
{
|
||||||
static class SqlConnectionHelperScripts
|
static class SqlConnectionHelperScripts
|
||||||
{
|
{
|
||||||
public const string EngineEdition = "SELECT SERVERPROPERTY('EngineEdition'), SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition'), (SELECT CASE WHEN EXISTS (SELECT TOP 1 1 from [sys].[all_columns] WITH (NOLOCK) WHERE name = N'xml_index_type' AND OBJECT_ID(N'sys.xml_indexes') = object_id) THEN 1 ELSE 0 END AS SXI_PRESENT)";
|
public const string EngineEdition = "SELECT SERVERPROPERTY('EngineEdition'), SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition'), SERVERPROPERTY ('MachineName'), (SELECT CASE WHEN EXISTS (SELECT TOP 1 1 from [sys].[all_columns] WITH (NOLOCK) WHERE name = N'xml_index_type' AND OBJECT_ID(N'sys.xml_indexes') = object_id) THEN 1 ELSE 0 END AS SXI_PRESENT)";
|
||||||
public const string EngineEditionWithLock = "SELECT SERVERPROPERTY('EngineEdition'), SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition'), (SELECT CASE WHEN EXISTS (SELECT TOP 1 1 from [sys].[all_columns] WHERE name = N'xml_index_type' AND OBJECT_ID(N'sys.xml_indexes') = object_id) THEN 1 ELSE 0 END AS SXI_PRESENT)";
|
public const string EngineEditionWithLock = "SELECT SERVERPROPERTY('EngineEdition'), SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition'), SERVERPROPERTY ('MachineName'), (SELECT CASE WHEN EXISTS (SELECT TOP 1 1 from [sys].[all_columns] WHERE name = N'xml_index_type' AND OBJECT_ID(N'sys.xml_indexes') = object_id) THEN 1 ELSE 0 END AS SXI_PRESENT)";
|
||||||
|
|
||||||
public const string CheckDatabaseReadonly = @"EXEC sp_dboption '{0}', 'read only'";
|
public const string CheckDatabaseReadonly = @"EXEC sp_dboption '{0}', 'read only'";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user