Improve database properties view: (#501)

- Compatibility Level should be a numerical value. In using `enum.ToString()` the result was `Version140` instead of `140`
- Backup date should be sensible if never backed up. Added a simple check that states it was never backed up if the backup date is before 1900.
This commit is contained in:
Kevin Cunnane
2017-10-18 09:51:00 -07:00
committed by GitHub
parent e52d95cebf
commit 4bf9b9ddae
15 changed files with 9400 additions and 19281 deletions

View File

@@ -18,6 +18,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
{ {
public class DatabaseTaskHelper: IDisposable public class DatabaseTaskHelper: IDisposable
{ {
private static DateTime minBackupDate = new DateTime(1900, 1, 1);
private DatabasePrototype prototype; private DatabasePrototype prototype;
private XmlDocument document; private XmlDocument document;
@@ -109,9 +111,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.CompatibilityLevel, (int)prototype.DatabaseCompatibilityLevel);
databaseInfo.Options.Add(AdminServicesProviderOptionsHelper.LastBackupDate, prototype.LastBackupDate.ToString()); databaseInfo.Options.Add(AdminServicesProviderOptionsHelper.LastBackupDate, GetBackupDate(prototype.LastBackupDate));
databaseInfo.Options.Add(AdminServicesProviderOptionsHelper.LastLogBackupDate, prototype.LastLogBackupDate.ToString()); databaseInfo.Options.Add(AdminServicesProviderOptionsHelper.LastLogBackupDate, GetBackupDate(prototype.LastLogBackupDate));
databaseInfo.Options.Add( databaseInfo.Options.Add(
AdminServicesProviderOptionsHelper.FileGroups + "Count", AdminServicesProviderOptionsHelper.FileGroups + "Count",
@@ -151,6 +153,16 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
return databaseInfo; return databaseInfo;
} }
private static string GetBackupDate(DateTime backupDate)
{
if (backupDate == null
|| backupDate < minBackupDate)
{
return SR.NeverBackedUp;
}
return backupDate.ToString();
}
private static T GetValueOrDefault<T>(string key, Dictionary<string, object> map, T defaultValue) private static T GetValueOrDefault<T>(string key, Dictionary<string, object> map, T defaultValue)
{ {
if (map != null && map.ContainsKey(key)) if (map != null && map.ContainsKey(key))

View File

@@ -3277,6 +3277,14 @@ namespace Microsoft.SqlTools.ServiceLayer
} }
} }
public static string NeverBackedUp
{
get
{
return Keys.GetString(Keys.NeverBackedUp);
}
}
public static string BackupTaskName public static string BackupTaskName
{ {
get get
@@ -4871,6 +4879,9 @@ namespace Microsoft.SqlTools.ServiceLayer
public const string prototype_file_noApplicableFileGroup = "prototype_file_noApplicableFileGroup"; public const string prototype_file_noApplicableFileGroup = "prototype_file_noApplicableFileGroup";
public const string NeverBackedUp = "NeverBackedUp";
public const string BackupTaskName = "BackupTaskName"; public const string BackupTaskName = "BackupTaskName";

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1811,6 +1811,10 @@
<value>No Applicable Filegroup</value> <value>No Applicable Filegroup</value>
<comment></comment> <comment></comment>
</data> </data>
<data name="NeverBackedUp" xml:space="preserve">
<value>Never</value>
<comment></comment>
</data>
<data name="BackupTaskName" xml:space="preserve"> <data name="BackupTaskName" xml:space="preserve">
<value>Backup Database</value> <value>Backup Database</value>
<comment></comment> <comment></comment>

File diff suppressed because it is too large Load Diff

View File

@@ -802,6 +802,7 @@ general_containmentType_None = None
general_containmentType_Partial = Partial general_containmentType_Partial = Partial
filegroups_filestreamFiles = FILESTREAM Files filegroups_filestreamFiles = FILESTREAM Files
prototype_file_noApplicableFileGroup = No Applicable Filegroup prototype_file_noApplicableFileGroup = No Applicable Filegroup
NeverBackedUp = Never
############################################################################ ############################################################################
# Backup Service # Backup Service

View File

@@ -2275,6 +2275,11 @@
<target state="new">No backupset selected to be restored</target> <target state="new">No backupset selected to be restored</target>
<note></note> <note></note>
</trans-unit> </trans-unit>
<trans-unit id="NeverBackedUp">
<source>Never</source>
<target state="new">Never</target>
<note></note>
</trans-unit>
</body> </body>
</file> </file>
</xliff> </xliff>