mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 10:58:30 -05:00
Additional create db options (#342)
* Refactor unsafe block * Stage changes * Add additional database prototype metadata * Fix nullref bug * Read database info properties
This commit is contained in:
@@ -68,41 +68,49 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
|||||||
serviceHost.SetRequestHandler(DefaultDatabaseInfoRequest.Type, HandleDefaultDatabaseInfoRequest);
|
serviceHost.SetRequestHandler(DefaultDatabaseInfoRequest.Type, HandleDefaultDatabaseInfoRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task HandleDefaultDatabaseInfoRequest(
|
private static DatabaseTaskHelper CreateDatabaseTaskHelper(ConnectionInfo connInfo)
|
||||||
DefaultDatabaseInfoParams optionsParams,
|
|
||||||
RequestContext<DefaultDatabaseInfoResponse> requestContext)
|
|
||||||
{
|
{
|
||||||
var response = new DefaultDatabaseInfoResponse();
|
|
||||||
|
|
||||||
ConnectionInfo connInfo;
|
|
||||||
AdminService.ConnectionServiceInstance.TryFindConnection(
|
|
||||||
optionsParams.OwnerUri,
|
|
||||||
out connInfo);
|
|
||||||
|
|
||||||
XmlDocument xmlDoc = CreateDataContainerDocument(connInfo);
|
XmlDocument xmlDoc = CreateDataContainerDocument(connInfo);
|
||||||
char[] passwordArray = connInfo.ConnectionDetails.Password.ToCharArray();
|
char[] passwordArray = connInfo.ConnectionDetails.Password.ToCharArray();
|
||||||
|
CDataContainer dataContainer;
|
||||||
|
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (char* passwordPtr = passwordArray)
|
fixed (char* passwordPtr = passwordArray)
|
||||||
{
|
{
|
||||||
var dataContainer = new CDataContainer(
|
dataContainer = new CDataContainer(
|
||||||
CDataContainer.ServerType.SQL,
|
CDataContainer.ServerType.SQL,
|
||||||
connInfo.ConnectionDetails.ServerName,
|
connInfo.ConnectionDetails.ServerName,
|
||||||
false,
|
false,
|
||||||
connInfo.ConnectionDetails.UserName,
|
connInfo.ConnectionDetails.UserName,
|
||||||
new System.Security.SecureString(passwordPtr, passwordArray.Length),
|
new System.Security.SecureString(passwordPtr, passwordArray.Length),
|
||||||
xmlDoc.InnerXml);
|
xmlDoc.InnerXml);
|
||||||
|
|
||||||
var taskHelper = new DatabaseTaskHelper();
|
|
||||||
taskHelper.CreateDatabase(dataContainer);
|
|
||||||
|
|
||||||
response.DefaultDatabaseInfo = DatabaseTaskHelper.DatabasePrototypeToDatabaseInfo(taskHelper.Prototype);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await requestContext.SendResult(response);
|
var taskHelper = new DatabaseTaskHelper();
|
||||||
|
taskHelper.CreateDatabase(dataContainer);
|
||||||
|
return taskHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handle a request for the default database prototype info
|
||||||
|
/// </summary>
|
||||||
|
public static async Task HandleDefaultDatabaseInfoRequest(
|
||||||
|
DefaultDatabaseInfoParams optionsParams,
|
||||||
|
RequestContext<DefaultDatabaseInfoResponse> requestContext)
|
||||||
|
{
|
||||||
|
var response = new DefaultDatabaseInfoResponse();
|
||||||
|
ConnectionInfo connInfo;
|
||||||
|
AdminService.ConnectionServiceInstance.TryFindConnection(
|
||||||
|
optionsParams.OwnerUri,
|
||||||
|
out connInfo);
|
||||||
|
|
||||||
|
DatabaseTaskHelper taskHelper = CreateDatabaseTaskHelper(connInfo);
|
||||||
|
|
||||||
|
response.DefaultDatabaseInfo = DatabaseTaskHelper.DatabasePrototypeToDatabaseInfo(taskHelper.Prototype);
|
||||||
|
await requestContext.SendResult(response);
|
||||||
|
}
|
||||||
|
|
||||||
private static XmlDocument CreateDataContainerDocument(ConnectionInfo connInfo)
|
private static XmlDocument CreateDataContainerDocument(ConnectionInfo connInfo)
|
||||||
{
|
{
|
||||||
@@ -130,6 +138,17 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
|||||||
CreateDatabaseParams databaseParams,
|
CreateDatabaseParams databaseParams,
|
||||||
RequestContext<CreateDatabaseResponse> requestContext)
|
RequestContext<CreateDatabaseResponse> requestContext)
|
||||||
{
|
{
|
||||||
|
var response = new DefaultDatabaseInfoResponse();
|
||||||
|
ConnectionInfo connInfo;
|
||||||
|
AdminService.ConnectionServiceInstance.TryFindConnection(
|
||||||
|
databaseParams.OwnerUri,
|
||||||
|
out connInfo);
|
||||||
|
|
||||||
|
DatabaseTaskHelper taskHelper = CreateDatabaseTaskHelper(connInfo);
|
||||||
|
DatabaseTaskHelper.ApplyToPrototype(databaseParams.DatabaseInfo, taskHelper.Prototype);
|
||||||
|
|
||||||
|
response.DefaultDatabaseInfo = DatabaseTaskHelper.DatabasePrototypeToDatabaseInfo(taskHelper.Prototype);
|
||||||
|
|
||||||
await requestContext.SendResult(new CreateDatabaseResponse());
|
await requestContext.SendResult(new CreateDatabaseResponse());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,31 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
|||||||
internal const string FileGroups = "fileGroups";
|
internal const string FileGroups = "fileGroups";
|
||||||
internal const string DatabaseFiles = "databaseFiles";
|
internal const string DatabaseFiles = "databaseFiles";
|
||||||
internal const string PhysicalName = "physicalName";
|
internal const string PhysicalName = "physicalName";
|
||||||
|
internal const string RecursiveTriggers = "recursiveTriggers";
|
||||||
|
internal const string Trustworthy = "trustworthy";
|
||||||
|
internal const string AnsiNullDefault = "ansiNullDefault";
|
||||||
|
internal const string AnsiNulls = "ansiNulls";
|
||||||
|
internal const string AnsiPadding = "ansiNulls";
|
||||||
|
internal const string AnsiWarnings = "ansiNulls";
|
||||||
|
internal const string IsFilestreamEnabled = "isFilestreamEnabled";
|
||||||
|
internal const string IsReadCommittedSnapshotOn = "isReadCommittedSnapshotOn";
|
||||||
|
internal const string IsReadOnly = "isReadOnly";
|
||||||
|
internal const string IsSystemDB = "isSystemDB";
|
||||||
|
internal const string MaxDop = "maxDop";
|
||||||
|
internal const string DatabaseContainmentType = "databaseContainmentType";
|
||||||
|
internal const string DatabaseState = "databaseState";
|
||||||
|
internal const string FileGroupType = "fileGroupType";
|
||||||
|
internal const string IsDefault = "isDefault";
|
||||||
|
internal const string IsFileStream = "isFileStream";
|
||||||
|
internal const string IsMemoryOptimized = "isMemoryOptimized";
|
||||||
|
internal const string Autogrowth = "autogrowth";
|
||||||
|
internal const string DatabaseFileType = "databaseFileType";
|
||||||
|
internal const string Folder = "folder";
|
||||||
|
internal const string Size = "size";
|
||||||
|
internal const string FileGroup = "fileGroup";
|
||||||
|
internal const string InitialSize = "initialSize";
|
||||||
|
internal const string IsPrimaryFile = "isPrimaryFile";
|
||||||
|
|
||||||
|
|
||||||
internal static AdminServicesProviderOptions BuildAdminServicesProviderOptions()
|
internal static AdminServicesProviderOptions BuildAdminServicesProviderOptions()
|
||||||
{
|
{
|
||||||
@@ -53,6 +78,123 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
|||||||
GroupName = "General"
|
GroupName = "General"
|
||||||
},
|
},
|
||||||
new ServiceOption
|
new ServiceOption
|
||||||
|
{
|
||||||
|
Name = AdminServicesProviderOptionsHelper.RecursiveTriggers,
|
||||||
|
DisplayName = "Recursive Triggers",
|
||||||
|
Description = "Recursive triggers",
|
||||||
|
ValueType = ServiceOption.ValueTypeBoolean,
|
||||||
|
IsRequired = false,
|
||||||
|
GroupName = "Other"
|
||||||
|
},
|
||||||
|
new ServiceOption
|
||||||
|
{
|
||||||
|
Name = AdminServicesProviderOptionsHelper.Trustworthy,
|
||||||
|
DisplayName = "Trustworthy",
|
||||||
|
Description = "Trustworthy",
|
||||||
|
ValueType = ServiceOption.ValueTypeBoolean,
|
||||||
|
IsRequired = false,
|
||||||
|
GroupName = "Other"
|
||||||
|
},
|
||||||
|
new ServiceOption
|
||||||
|
{
|
||||||
|
Name = AdminServicesProviderOptionsHelper.AnsiNullDefault,
|
||||||
|
DisplayName = "AnsiNullDefault",
|
||||||
|
Description = "Ansi null default",
|
||||||
|
ValueType = ServiceOption.ValueTypeBoolean,
|
||||||
|
IsRequired = false,
|
||||||
|
GroupName = "Other"
|
||||||
|
},
|
||||||
|
new ServiceOption
|
||||||
|
{
|
||||||
|
Name = AdminServicesProviderOptionsHelper.AnsiNulls,
|
||||||
|
DisplayName = "AnsiNulls",
|
||||||
|
Description = "AnsiNulls",
|
||||||
|
ValueType = ServiceOption.ValueTypeBoolean,
|
||||||
|
IsRequired = false,
|
||||||
|
GroupName = "Other"
|
||||||
|
},
|
||||||
|
new ServiceOption
|
||||||
|
{
|
||||||
|
Name = AdminServicesProviderOptionsHelper.AnsiPadding,
|
||||||
|
DisplayName = "AnsiPadding",
|
||||||
|
Description = "Ansi padding",
|
||||||
|
ValueType = ServiceOption.ValueTypeBoolean,
|
||||||
|
IsRequired = false,
|
||||||
|
GroupName = "Other"
|
||||||
|
},
|
||||||
|
new ServiceOption
|
||||||
|
{
|
||||||
|
Name = AdminServicesProviderOptionsHelper.AnsiWarnings,
|
||||||
|
DisplayName = "AnsiWarnings",
|
||||||
|
Description = "Ansi warnings",
|
||||||
|
ValueType = ServiceOption.ValueTypeBoolean,
|
||||||
|
IsRequired = false,
|
||||||
|
GroupName = "Other"
|
||||||
|
},
|
||||||
|
new ServiceOption
|
||||||
|
{
|
||||||
|
Name = AdminServicesProviderOptionsHelper.IsFilestreamEnabled,
|
||||||
|
DisplayName = "IsFilestreamEnabled",
|
||||||
|
Description = "Is filestream enabled",
|
||||||
|
ValueType = ServiceOption.ValueTypeBoolean,
|
||||||
|
IsRequired = false,
|
||||||
|
GroupName = "Other"
|
||||||
|
},
|
||||||
|
new ServiceOption
|
||||||
|
{
|
||||||
|
Name = AdminServicesProviderOptionsHelper.IsReadCommittedSnapshotOn,
|
||||||
|
DisplayName = "IsReadCommittedSnapshotOn",
|
||||||
|
Description = "Is read committed snapshot on",
|
||||||
|
ValueType = ServiceOption.ValueTypeBoolean,
|
||||||
|
IsRequired = false,
|
||||||
|
GroupName = "Other"
|
||||||
|
},
|
||||||
|
new ServiceOption
|
||||||
|
{
|
||||||
|
Name = AdminServicesProviderOptionsHelper.IsReadOnly,
|
||||||
|
DisplayName = "IsReadOnly",
|
||||||
|
Description = "Is read only",
|
||||||
|
ValueType = ServiceOption.ValueTypeBoolean,
|
||||||
|
IsRequired = false,
|
||||||
|
GroupName = "Other"
|
||||||
|
},
|
||||||
|
new ServiceOption
|
||||||
|
{
|
||||||
|
Name = AdminServicesProviderOptionsHelper.IsSystemDB,
|
||||||
|
DisplayName = "IsSystemDB",
|
||||||
|
Description = "Is system database",
|
||||||
|
ValueType = ServiceOption.ValueTypeBoolean,
|
||||||
|
IsRequired = false,
|
||||||
|
GroupName = "Other"
|
||||||
|
},
|
||||||
|
new ServiceOption
|
||||||
|
{
|
||||||
|
Name = AdminServicesProviderOptionsHelper.MaxDop,
|
||||||
|
DisplayName = "MaxDop",
|
||||||
|
Description = "Max degree of parallelism",
|
||||||
|
ValueType = ServiceOption.ValueTypeBoolean,
|
||||||
|
IsRequired = false,
|
||||||
|
GroupName = "Other"
|
||||||
|
},
|
||||||
|
new ServiceOption
|
||||||
|
{
|
||||||
|
Name = AdminServicesProviderOptionsHelper.DatabaseContainmentType,
|
||||||
|
DisplayName = "DatabaseContainmentType",
|
||||||
|
Description = "Database containment type",
|
||||||
|
ValueType = ServiceOption.ValueTypeString,
|
||||||
|
IsRequired = false,
|
||||||
|
GroupName = "Other"
|
||||||
|
},
|
||||||
|
new ServiceOption
|
||||||
|
{
|
||||||
|
Name = AdminServicesProviderOptionsHelper.DatabaseState,
|
||||||
|
DisplayName = "DatabaseState",
|
||||||
|
Description = "Database state",
|
||||||
|
ValueType = ServiceOption.ValueTypeString,
|
||||||
|
IsRequired = false,
|
||||||
|
GroupName = "Other"
|
||||||
|
},
|
||||||
|
new ServiceOption
|
||||||
{
|
{
|
||||||
Name = AdminServicesProviderOptionsHelper.FileGroups,
|
Name = AdminServicesProviderOptionsHelper.FileGroups,
|
||||||
DisplayName = "File Groups",
|
DisplayName = "File Groups",
|
||||||
@@ -85,8 +227,55 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
|||||||
ValueType = ServiceOption.ValueTypeString,
|
ValueType = ServiceOption.ValueTypeString,
|
||||||
IsRequired = true,
|
IsRequired = true,
|
||||||
GroupName = "General"
|
GroupName = "General"
|
||||||
}
|
},
|
||||||
|
new ServiceOption
|
||||||
|
{
|
||||||
|
Name = AdminServicesProviderOptionsHelper.FileGroupType,
|
||||||
|
DisplayName = "FileGroupType",
|
||||||
|
Description = "File group type",
|
||||||
|
ValueType = ServiceOption.ValueTypeString,
|
||||||
|
IsRequired = true,
|
||||||
|
GroupName = "General"
|
||||||
|
},
|
||||||
|
new ServiceOption
|
||||||
|
{
|
||||||
|
Name = AdminServicesProviderOptionsHelper.IsDefault,
|
||||||
|
DisplayName = "IsDefault",
|
||||||
|
Description = "Is default",
|
||||||
|
ValueType = ServiceOption.ValueTypeString,
|
||||||
|
IsRequired = true,
|
||||||
|
GroupName = "General"
|
||||||
|
},
|
||||||
|
new ServiceOption
|
||||||
|
{
|
||||||
|
Name = AdminServicesProviderOptionsHelper.IsFileStream,
|
||||||
|
DisplayName = "IsFileStream",
|
||||||
|
Description = "Is file stream",
|
||||||
|
ValueType = ServiceOption.ValueTypeString,
|
||||||
|
IsRequired = true,
|
||||||
|
GroupName = "General"
|
||||||
|
},
|
||||||
|
new ServiceOption
|
||||||
|
{
|
||||||
|
Name = AdminServicesProviderOptionsHelper.IsMemoryOptimized,
|
||||||
|
DisplayName = "IsMemoryOptimized",
|
||||||
|
Description = "Is memory optimized",
|
||||||
|
ValueType = ServiceOption.ValueTypeString,
|
||||||
|
IsRequired = true,
|
||||||
|
GroupName = "General"
|
||||||
|
},
|
||||||
|
new ServiceOption
|
||||||
|
{
|
||||||
|
Name = AdminServicesProviderOptionsHelper.IsReadOnly,
|
||||||
|
DisplayName = "IsReadOnly",
|
||||||
|
Description = "Is read-only",
|
||||||
|
ValueType = ServiceOption.ValueTypeString,
|
||||||
|
IsRequired = true,
|
||||||
|
GroupName = "General"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
DatabaseFileInfoOptions = new ServiceOption[]
|
DatabaseFileInfoOptions = new ServiceOption[]
|
||||||
{
|
{
|
||||||
new ServiceOption
|
new ServiceOption
|
||||||
@@ -98,7 +287,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
|||||||
IsRequired = true,
|
IsRequired = true,
|
||||||
GroupName = "General"
|
GroupName = "General"
|
||||||
},
|
},
|
||||||
new ServiceOption
|
new ServiceOption
|
||||||
{
|
{
|
||||||
Name = AdminServicesProviderOptionsHelper.PhysicalName,
|
Name = AdminServicesProviderOptionsHelper.PhysicalName,
|
||||||
DisplayName = "Physical Name",
|
DisplayName = "Physical Name",
|
||||||
@@ -106,7 +295,71 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
|||||||
ValueType = ServiceOption.ValueTypeString,
|
ValueType = ServiceOption.ValueTypeString,
|
||||||
IsRequired = true,
|
IsRequired = true,
|
||||||
GroupName = "General"
|
GroupName = "General"
|
||||||
}
|
},
|
||||||
|
|
||||||
|
new ServiceOption
|
||||||
|
{
|
||||||
|
Name = AdminServicesProviderOptionsHelper.Autogrowth,
|
||||||
|
DisplayName = "Autogrowth",
|
||||||
|
Description = "Autogrowth",
|
||||||
|
ValueType = ServiceOption.ValueTypeString,
|
||||||
|
IsRequired = true,
|
||||||
|
GroupName = "General"
|
||||||
|
},
|
||||||
|
new ServiceOption
|
||||||
|
{
|
||||||
|
Name = AdminServicesProviderOptionsHelper.DatabaseFileType,
|
||||||
|
DisplayName = "DatabaseFileType",
|
||||||
|
Description = "Database file type",
|
||||||
|
ValueType = ServiceOption.ValueTypeString,
|
||||||
|
IsRequired = true,
|
||||||
|
GroupName = "General"
|
||||||
|
},
|
||||||
|
new ServiceOption
|
||||||
|
{
|
||||||
|
Name = AdminServicesProviderOptionsHelper.Folder,
|
||||||
|
DisplayName = "Folder",
|
||||||
|
Description = "Folder",
|
||||||
|
ValueType = ServiceOption.ValueTypeString,
|
||||||
|
IsRequired = true,
|
||||||
|
GroupName = "General"
|
||||||
|
},
|
||||||
|
new ServiceOption
|
||||||
|
{
|
||||||
|
Name = AdminServicesProviderOptionsHelper.Size,
|
||||||
|
DisplayName = "Size",
|
||||||
|
Description = "Size",
|
||||||
|
ValueType = ServiceOption.ValueTypeString,
|
||||||
|
IsRequired = true,
|
||||||
|
GroupName = "General"
|
||||||
|
},
|
||||||
|
new ServiceOption
|
||||||
|
{
|
||||||
|
Name = AdminServicesProviderOptionsHelper.FileGroup,
|
||||||
|
DisplayName = "FileGroup",
|
||||||
|
Description = "File group",
|
||||||
|
ValueType = ServiceOption.ValueTypeString,
|
||||||
|
IsRequired = true,
|
||||||
|
GroupName = "General"
|
||||||
|
},
|
||||||
|
new ServiceOption
|
||||||
|
{
|
||||||
|
Name = AdminServicesProviderOptionsHelper.InitialSize,
|
||||||
|
DisplayName = "InitialSize",
|
||||||
|
Description = "Initial size",
|
||||||
|
ValueType = ServiceOption.ValueTypeString,
|
||||||
|
IsRequired = true,
|
||||||
|
GroupName = "General"
|
||||||
|
},
|
||||||
|
new ServiceOption
|
||||||
|
{
|
||||||
|
Name = AdminServicesProviderOptionsHelper.IsPrimaryFile,
|
||||||
|
DisplayName = "IsPrimaryFile",
|
||||||
|
Description = "Is primary file",
|
||||||
|
ValueType = ServiceOption.ValueTypeString,
|
||||||
|
IsRequired = true,
|
||||||
|
GroupName = "General"
|
||||||
|
},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,20 +11,14 @@ using System.Resources;
|
|||||||
using System.Data;
|
using System.Data;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
//using System.Windows.Forms;
|
|
||||||
//using System.Drawing.Design;
|
|
||||||
using Microsoft.SqlServer.Management.Common;
|
using Microsoft.SqlServer.Management.Common;
|
||||||
// using Microsoft.SqlServer.Management.SqlMgmt;
|
|
||||||
using Microsoft.SqlServer.Management.Smo;
|
using Microsoft.SqlServer.Management.Smo;
|
||||||
using Smo = Microsoft.SqlServer.Management.Smo;
|
using Smo = Microsoft.SqlServer.Management.Smo;
|
||||||
using Microsoft.SqlServer.Management.Sdk.Sfc;
|
using Microsoft.SqlServer.Management.Sdk.Sfc;
|
||||||
using Microsoft.SqlServer.Management.Diagnostics;
|
using Microsoft.SqlServer.Management.Diagnostics;
|
||||||
//using Microsoft.NetEnterpriseServers;
|
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
// using DisplayNameAttribute = Microsoft.SqlServer.Management.SqlMgmt.DisplayNameAttribute;
|
|
||||||
using AzureEdition = Microsoft.SqlTools.ServiceLayer.Admin.AzureSqlDbHelper.AzureEdition;
|
using AzureEdition = Microsoft.SqlTools.ServiceLayer.Admin.AzureSqlDbHelper.AzureEdition;
|
||||||
using DataSet = Microsoft.Data.Tools.DataSets.DataSet;
|
using DataSet = Microsoft.Data.Tools.DataSets.DataSet;
|
||||||
using DataTable = Microsoft.Data.Tools.DataSets.DataTable;
|
using DataTable = Microsoft.Data.Tools.DataSets.DataTable;
|
||||||
@@ -741,9 +735,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
|||||||
/// <returns>The string representation</returns>
|
/// <returns>The string representation</returns>
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
ResourceManager manager =
|
ResourceManager manager = new ResourceManager("Microsoft.SqlTools.ServiceLayer.Localization.SR", typeof(DatabasePrototype).GetAssembly());
|
||||||
new ResourceManager("Microsoft.SqlServer.Management.SqlManagerUI.CreateDatabaseStrings",
|
|
||||||
this.GetType().GetAssembly());
|
|
||||||
string result = "";
|
string result = "";
|
||||||
|
|
||||||
if (this.IsEnabled)
|
if (this.IsEnabled)
|
||||||
@@ -760,7 +752,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
result = String.Format(System.Globalization.CultureInfo.CurrentCulture,
|
result = String.Format(System.Globalization.CultureInfo.CurrentCulture,
|
||||||
manager.GetString("prototype.autogrowth.restrictedGrowthByMB"),
|
manager.GetString("prototype_autogrowth_restrictedGrowthByMB"),
|
||||||
this.GrowthInMegabytes,
|
this.GrowthInMegabytes,
|
||||||
this.MaximumFileSizeInMegabytes);
|
this.MaximumFileSizeInMegabytes);
|
||||||
}
|
}
|
||||||
@@ -770,13 +762,13 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
|||||||
if (this.IsGrowthInPercent)
|
if (this.IsGrowthInPercent)
|
||||||
{
|
{
|
||||||
result = String.Format(System.Globalization.CultureInfo.CurrentCulture,
|
result = String.Format(System.Globalization.CultureInfo.CurrentCulture,
|
||||||
manager.GetString("prototype.autogrowth.unrestrictedGrowthByPercent"),
|
manager.GetString("prototype_autogrowth_unrestrictedGrowthByPercent"),
|
||||||
this.GrowthInPercent);
|
this.GrowthInPercent);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
result = String.Format(System.Globalization.CultureInfo.CurrentCulture,
|
result = String.Format(System.Globalization.CultureInfo.CurrentCulture,
|
||||||
manager.GetString("prototype.autogrowth.unrestrictedGrowthByMB"),
|
manager.GetString("prototype_autogrowth_unrestrictedGrowthByMB"),
|
||||||
this.GrowthInMegabytes);
|
this.GrowthInMegabytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -107,24 +107,52 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
|||||||
databaseInfo.Options.Add(AdminServicesProviderOptionsHelper.Name, prototype.Name);
|
databaseInfo.Options.Add(AdminServicesProviderOptionsHelper.Name, prototype.Name);
|
||||||
databaseInfo.Options.Add(AdminServicesProviderOptionsHelper.Owner, prototype.Owner);
|
databaseInfo.Options.Add(AdminServicesProviderOptionsHelper.Owner, prototype.Owner);
|
||||||
databaseInfo.Options.Add(AdminServicesProviderOptionsHelper.Collation, prototype.Collation);
|
databaseInfo.Options.Add(AdminServicesProviderOptionsHelper.Collation, prototype.Collation);
|
||||||
|
databaseInfo.Options.Add(AdminServicesProviderOptionsHelper.DatabaseState, prototype.DatabaseState.ToString());
|
||||||
|
databaseInfo.Options.Add(AdminServicesProviderOptionsHelper.IsSystemDB, prototype.IsSystemDB.ToString());
|
||||||
|
databaseInfo.Options.Add(AdminServicesProviderOptionsHelper.AnsiNulls, prototype.AnsiNulls.ToString());
|
||||||
|
|
||||||
|
databaseInfo.Options.Add(
|
||||||
|
AdminServicesProviderOptionsHelper.FileGroups + "Count",
|
||||||
|
prototype.Filegroups.Count);
|
||||||
|
|
||||||
for (int i = 0; i < prototype.Filegroups.Count; ++i)
|
for (int i = 0; i < prototype.Filegroups.Count; ++i)
|
||||||
{
|
{
|
||||||
var fileGroup = prototype.Filegroups[i];
|
var fileGroup = prototype.Filegroups[i];
|
||||||
string itemPrefix = AdminServicesProviderOptionsHelper.FileGroups + "." + i + ".";
|
string itemPrefix = AdminServicesProviderOptionsHelper.FileGroups + "." + i + ".";
|
||||||
databaseInfo.Options.Add(itemPrefix + AdminServicesProviderOptionsHelper.Name, fileGroup.Name);
|
databaseInfo.Options.Add(itemPrefix + AdminServicesProviderOptionsHelper.Name, fileGroup.Name);
|
||||||
|
databaseInfo.Options.Add(itemPrefix + AdminServicesProviderOptionsHelper.IsMemoryOptimized, fileGroup.IsMemoryOptimized);
|
||||||
|
databaseInfo.Options.Add(itemPrefix + AdminServicesProviderOptionsHelper.IsReadOnly, fileGroup.IsReadOnly);
|
||||||
|
databaseInfo.Options.Add(itemPrefix + AdminServicesProviderOptionsHelper.IsFileStream, fileGroup.IsFileStream);
|
||||||
|
databaseInfo.Options.Add(itemPrefix + AdminServicesProviderOptionsHelper.IsDefault, fileGroup.IsDefault);
|
||||||
|
databaseInfo.Options.Add(itemPrefix + AdminServicesProviderOptionsHelper.FileGroupType, fileGroup.FileGroupType.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
databaseInfo.Options.Add(
|
||||||
|
AdminServicesProviderOptionsHelper.DatabaseFiles + "Count",
|
||||||
|
prototype.Files.Count);
|
||||||
|
|
||||||
for (int i = 0; i < prototype.Files.Count; ++i)
|
for (int i = 0; i < prototype.Files.Count; ++i)
|
||||||
{
|
{
|
||||||
var file = prototype.Files[i];
|
var file = prototype.Files[i];
|
||||||
string itemPrefix = AdminServicesProviderOptionsHelper.DatabaseFiles + "." + i + ".";
|
string itemPrefix = AdminServicesProviderOptionsHelper.DatabaseFiles + "." + i + ".";
|
||||||
databaseInfo.Options.Add(itemPrefix + AdminServicesProviderOptionsHelper.Name, file.Name);
|
databaseInfo.Options.Add(itemPrefix + AdminServicesProviderOptionsHelper.Name, file.Name);
|
||||||
databaseInfo.Options.Add(itemPrefix + AdminServicesProviderOptionsHelper.PhysicalName, file.PhysicalName);
|
databaseInfo.Options.Add(itemPrefix + AdminServicesProviderOptionsHelper.PhysicalName, file.PhysicalName);
|
||||||
|
databaseInfo.Options.Add(itemPrefix + AdminServicesProviderOptionsHelper.Autogrowth, file.DefaultAutogrowth.ToString());
|
||||||
|
databaseInfo.Options.Add(itemPrefix + AdminServicesProviderOptionsHelper.DatabaseFileType, file.DatabaseFileType.ToString());
|
||||||
|
databaseInfo.Options.Add(itemPrefix + AdminServicesProviderOptionsHelper.Folder, file.DefaultFolder);
|
||||||
|
databaseInfo.Options.Add(itemPrefix + AdminServicesProviderOptionsHelper.Size, file.DefaultSize);
|
||||||
|
databaseInfo.Options.Add(itemPrefix + AdminServicesProviderOptionsHelper.FileGroup, file.FileGroup != null ? file.FileGroup.Name : string.Empty);
|
||||||
|
databaseInfo.Options.Add(itemPrefix + AdminServicesProviderOptionsHelper.InitialSize, file.InitialSize);
|
||||||
|
databaseInfo.Options.Add(itemPrefix + AdminServicesProviderOptionsHelper.IsPrimaryFile, file.IsPrimaryFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
return databaseInfo;
|
return databaseInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static DatabasePrototype ApplyToPrototype(DatabaseInfo databaseInfo, DatabasePrototype prototype)
|
||||||
|
{
|
||||||
|
prototype.Name = databaseInfo.Options[AdminServicesProviderOptionsHelper.Name] as string;
|
||||||
|
return prototype;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user