mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-13 17:23:02 -05:00
Fix create db resource strings (#348)
* Hook up SMO call into create db handler * Clean-up resource strings * Few additional code clean-ups
This commit is contained in:
@@ -11,6 +11,7 @@ using Microsoft.SqlTools.ServiceLayer.SqlContext;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
using Microsoft.SqlServer.Management.Smo;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
{
|
||||
@@ -144,11 +145,16 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
out connInfo);
|
||||
|
||||
DatabaseTaskHelper taskHelper = CreateDatabaseTaskHelper(connInfo);
|
||||
DatabasePrototype prototype = taskHelper.Prototype;
|
||||
DatabaseTaskHelper.ApplyToPrototype(databaseParams.DatabaseInfo, taskHelper.Prototype);
|
||||
|
||||
response.DefaultDatabaseInfo = DatabaseTaskHelper.DatabasePrototypeToDatabaseInfo(taskHelper.Prototype);
|
||||
|
||||
await requestContext.SendResult(new CreateDatabaseResponse());
|
||||
Database db = prototype.ApplyChanges();
|
||||
|
||||
await requestContext.SendResult(new CreateDatabaseResponse()
|
||||
{
|
||||
Result = true,
|
||||
TaskId = 0
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -198,68 +198,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
/// </summary>
|
||||
static AzureSqlDbHelper()
|
||||
{
|
||||
//foreach (AzureEdition edition in Enum.GetValues(typeof (AzureEdition)))
|
||||
//{
|
||||
// object value;
|
||||
|
||||
// try
|
||||
// {
|
||||
// value = Registry.GetValue(
|
||||
// string.Format(CultureInfo.InvariantCulture, @"{0}\{1}", SSMSAzureRegKey,
|
||||
// AzureServiceObjectivesRegSubKey), edition.ToString(), null);
|
||||
// }
|
||||
// catch (Exception e)
|
||||
// {
|
||||
// //We don't really care if we can't read in an override (just fall back to default) so log and move on
|
||||
// TraceContext.TraceVerbose("Exception reading service objective overrides for {0} - {1}", edition, e.Message);
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// if (value != null)
|
||||
// {
|
||||
// TraceContext.TraceVerbose("Found ServiceObjective override for {0}, value is {1}", edition, value);
|
||||
// //Key is in format <DefaultIndex>:<ServiceObjectiveList>
|
||||
// //e.g. 2:S0,S1,S2
|
||||
// //Only split into 2 parts since the service objectives could
|
||||
// //be changed in the future to have :'s, so only treat the first
|
||||
// //as special
|
||||
// string[] values = value.ToString().Split(new[] {':'}, 2);
|
||||
// if (values.Length != 2)
|
||||
// {
|
||||
// //Badly formatted value, ignore this one
|
||||
// TraceContext.TraceVerbose("ServiceObjective override for {0} is badly formatted - skipping", edition);
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// int defaultIndex;
|
||||
// if (!int.TryParse(values[0], out defaultIndex))
|
||||
// {
|
||||
// //Invalid default index, ignore this one
|
||||
// TraceContext.TraceVerbose("ServiceObjective override for {0} has non-parseable default index - skipping", edition);
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// //Service objectives are in a comma-separated list
|
||||
// string[] serviceObjectives = values[1].Split(',');
|
||||
// if (defaultIndex < 0 || defaultIndex >= serviceObjectives.Length)
|
||||
// {
|
||||
// //Index out of bounds, ignore this one
|
||||
// TraceContext.TraceVerbose("ServiceObjective override for {0} has out of bounds default index - skipping");
|
||||
// continue;
|
||||
// }
|
||||
// if (AzureServiceObjectiveInfo.ContainsKey(edition))
|
||||
// {
|
||||
// //Overwrite our default values if the registry key for this edition exists
|
||||
// AzureServiceObjectiveInfo[edition] = new KeyValuePair<int, string[]>(defaultIndex,
|
||||
// serviceObjectives);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// AzureServiceObjectiveInfo.Add(edition,
|
||||
// new KeyValuePair<int, string[]>(defaultIndex, serviceObjectives));
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -2033,26 +2033,25 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
|
||||
if (isAllWhitespace || (0 == fileName.Length) || (-1 != fileName.IndexOfAny(badFileCharacters)))
|
||||
{
|
||||
ResourceManager resourceManager =
|
||||
new ResourceManager("Microsoft.SqlServer.Management.SqlManagerUI.CreateDatabaseStrings",
|
||||
this.GetType().GetAssembly());
|
||||
ResourceManager resourceManager = new ResourceManager("Microsoft.SqlTools.ServiceLayer.Localization.SR", typeof(DatabasePrototype).GetAssembly());
|
||||
|
||||
|
||||
string message = String.Empty;
|
||||
|
||||
if (0 == fileName.Length)
|
||||
{
|
||||
message = resourceManager.GetString("error.emptyFileName");
|
||||
message = resourceManager.GetString("error_emptyFileName");
|
||||
}
|
||||
else if (isAllWhitespace)
|
||||
{
|
||||
message = resourceManager.GetString("error.whitespaceDatabaseName");
|
||||
message = resourceManager.GetString("error_whitespaceDatabaseName");
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = fileName.IndexOfAny(badFileCharacters);
|
||||
|
||||
message = String.Format(System.Globalization.CultureInfo.CurrentCulture,
|
||||
resourceManager.GetString("error.fileNameContainsIllegalCharacter"), fileName, fileName[i]);
|
||||
resourceManager.GetString("error_fileNameContainsIllegalCharacter"), fileName, fileName[i]);
|
||||
}
|
||||
|
||||
throw new InvalidOperationException(message);
|
||||
@@ -2119,9 +2118,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
/// <exception cref="InvalidOperationException">If logical name is empty, or physical name is invalid.</exception>
|
||||
private string MakeDiskFileName(string logicalName, string preferredPhysicalName, string suffix)
|
||||
{
|
||||
ResourceManager resourceManager =
|
||||
new ResourceManager("Microsoft.SqlServer.Management.SqlManagerUI.CreateDatabaseStrings",
|
||||
this.GetType().GetAssembly());
|
||||
ResourceManager resourceManager = new ResourceManager("Microsoft.SqlTools.ServiceLayer.Localization.SR", typeof(DatabasePrototype).GetAssembly());
|
||||
|
||||
string filePath = String.Empty; // returned to the caller.
|
||||
if (String.IsNullOrEmpty(preferredPhysicalName))
|
||||
@@ -2140,7 +2137,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
{
|
||||
string message = String.Empty;
|
||||
|
||||
message = resourceManager.GetString("error.emptyFileName");
|
||||
message = resourceManager.GetString("error_emptyFileName");
|
||||
throw new InvalidOperationException(message);
|
||||
}
|
||||
|
||||
@@ -2468,18 +2465,16 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
/// <returns>List of Restrict Access Types </returns>
|
||||
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
|
||||
{
|
||||
ResourceManager manager =
|
||||
new ResourceManager("Microsoft.SqlServer.Management.SqlManagerUI.CreateDatabaseStrings",
|
||||
typeof (DatabasePrototype).GetAssembly());
|
||||
ResourceManager manager = new ResourceManager("Microsoft.SqlTools.ServiceLayer.Localization.SR", typeof(DatabasePrototype).GetAssembly());
|
||||
List<string> standardValues = new List<string>();
|
||||
TypeConverter.StandardValuesCollection result = null;
|
||||
|
||||
if (string.Compare(context.PropertyDescriptor.Name, "RestrictAccess", StringComparison.OrdinalIgnoreCase) ==
|
||||
0)
|
||||
{
|
||||
standardValues.Add(manager.GetString("prototype.db.prop.restrictAccess.value.multiple"));
|
||||
standardValues.Add(manager.GetString("prototype.db.prop.restrictAccess.value.single"));
|
||||
standardValues.Add(manager.GetString("prototype.db.prop.restrictAccess.value.restricted"));
|
||||
standardValues.Add(manager.GetString("prototype_db_prop_restrictAccess_value_multiple"));
|
||||
standardValues.Add(manager.GetString("prototype_db_prop_restrictAccess_value_single"));
|
||||
standardValues.Add(manager.GetString("prototype_db_prop_restrictAccess_value_restricted"));
|
||||
}
|
||||
if (standardValues.Count > 0)
|
||||
{
|
||||
@@ -2520,17 +2515,17 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
string.Compare(context.PropertyDescriptor.Name, "DatabaseStatusDisplay",
|
||||
StringComparison.OrdinalIgnoreCase) == 0)
|
||||
{
|
||||
standardValues.Add(manager.GetString("prototype.db.prop.databaseState.value.normal"));
|
||||
standardValues.Add(manager.GetString("prototype.db.prop.databaseState.value.restoring"));
|
||||
standardValues.Add(manager.GetString("prototype.db.prop.databaseState.value.recoveryPending"));
|
||||
standardValues.Add(manager.GetString("prototype.db.prop.databaseState.value.recovering"));
|
||||
standardValues.Add(manager.GetString("prototype.db.prop.databaseState.value.suspect"));
|
||||
standardValues.Add(manager.GetString("prototype.db.prop.databaseState.value.offline"));
|
||||
standardValues.Add(manager.GetString("prototype.db.prop.databaseState.value.inaccessible"));
|
||||
standardValues.Add(manager.GetString("prototype.db.prop.databaseState.value.standby"));
|
||||
standardValues.Add(manager.GetString("prototype.db.prop.databaseState.value.shutdown"));
|
||||
standardValues.Add(manager.GetString("prototype.db.prop.databaseState.value.emergency"));
|
||||
standardValues.Add(manager.GetString("prototype.db.prop.databaseState.value.autoClosed"));
|
||||
standardValues.Add(manager.GetString("prototype_db_prop_databaseState_value_normal"));
|
||||
standardValues.Add(manager.GetString("prototype_db_prop_databaseState_value_restoring"));
|
||||
standardValues.Add(manager.GetString("prototype_db_prop_databaseState_value_recoveryPending"));
|
||||
standardValues.Add(manager.GetString("prototype_db_prop_databaseState_value_recovering"));
|
||||
standardValues.Add(manager.GetString("prototype_db_prop_databaseState_value_suspect"));
|
||||
standardValues.Add(manager.GetString("prototype_db_prop_databaseState_value_offline"));
|
||||
standardValues.Add(manager.GetString("prototype_db_prop_databaseState_value_inaccessible"));
|
||||
standardValues.Add(manager.GetString("prototype_db_prop_databaseState_value_standby"));
|
||||
standardValues.Add(manager.GetString("prototype_db_prop_databaseState_value_shutdown"));
|
||||
standardValues.Add(manager.GetString("prototype_db_prop_databaseState_value_emergency"));
|
||||
standardValues.Add(manager.GetString("prototype_db_prop_databaseState_value_autoClosed"));
|
||||
}
|
||||
if (standardValues.Count > 0)
|
||||
{
|
||||
@@ -983,61 +983,61 @@ WHERE do.database_id = @DbID
|
||||
get
|
||||
{
|
||||
string result = null;
|
||||
ResourceManager manager = new ResourceManager("Microsoft.SqlServer.Management.SqlManagerUI.CreateDatabaseStrings", typeof(DatabasePrototype90).GetAssembly());
|
||||
|
||||
ResourceManager manager = new ResourceManager("Microsoft.SqlTools.ServiceLayer.Localization.SR", typeof(DatabasePrototype).GetAssembly());
|
||||
|
||||
if ((this.currentState.databaseState & DatabaseStatus.Normal) != 0)
|
||||
{
|
||||
result = this.AppendState(result, manager.GetString("prototype.db.prop.databaseState.value.normal"));
|
||||
result = this.AppendState(result, manager.GetString("prototype_db_prop_databaseState_value_normal"));
|
||||
}
|
||||
|
||||
if ((this.currentState.databaseState & DatabaseStatus.Restoring) != 0)
|
||||
{
|
||||
result = this.AppendState(result, manager.GetString("prototype.db.prop.databaseState.value.restoring"));
|
||||
result = this.AppendState(result, manager.GetString("prototype_db_prop_databaseState_value_restoring"));
|
||||
}
|
||||
|
||||
if ((this.currentState.databaseState & DatabaseStatus.RecoveryPending) != 0)
|
||||
{
|
||||
result = this.AppendState(result, manager.GetString("prototype.db.prop.databaseState.value.recoveryPending"));
|
||||
result = this.AppendState(result, manager.GetString("prototype_db_prop_databaseState_value_recoveryPending"));
|
||||
}
|
||||
|
||||
if ((this.currentState.databaseState & DatabaseStatus.Recovering) != 0)
|
||||
{
|
||||
result = this.AppendState(result, manager.GetString("prototype.db.prop.databaseState.value.recovering"));
|
||||
result = this.AppendState(result, manager.GetString("prototype_db_prop_databaseState_value_recovering"));
|
||||
}
|
||||
|
||||
if ((this.currentState.databaseState & DatabaseStatus.Suspect) != 0)
|
||||
{
|
||||
result = this.AppendState(result, manager.GetString("prototype.db.prop.databaseState.value.suspect"));
|
||||
result = this.AppendState(result, manager.GetString("prototype_db_prop_databaseState_value_suspect"));
|
||||
}
|
||||
|
||||
if ((this.currentState.databaseState & DatabaseStatus.Offline) != 0)
|
||||
{
|
||||
result = this.AppendState(result, manager.GetString("prototype.db.prop.databaseState.value.offline"));
|
||||
result = this.AppendState(result, manager.GetString("prototype_db_prop_databaseState_value_offline"));
|
||||
}
|
||||
|
||||
if ((this.currentState.databaseState & DatabaseStatus.Inaccessible) != 0)
|
||||
{
|
||||
result = this.AppendState(result, manager.GetString("prototype.db.prop.databaseState.value.inaccessible"));
|
||||
result = this.AppendState(result, manager.GetString("prototype_db_prop_databaseState_value_inaccessible"));
|
||||
}
|
||||
|
||||
if ((this.currentState.databaseState & DatabaseStatus.Standby) != 0)
|
||||
{
|
||||
result = this.AppendState(result, manager.GetString("prototype.db.prop.databaseState.value.standby"));
|
||||
result = this.AppendState(result, manager.GetString("prototype_db_prop_databaseState_value_standby"));
|
||||
}
|
||||
|
||||
if ((this.currentState.databaseState & DatabaseStatus.Shutdown) != 0)
|
||||
{
|
||||
result = this.AppendState(result, manager.GetString("prototype.db.prop.databaseState.value.shutdown"));
|
||||
result = this.AppendState(result, manager.GetString("prototype_db_prop_databaseState_value_shutdown"));
|
||||
}
|
||||
|
||||
if ((this.currentState.databaseState & DatabaseStatus.EmergencyMode) != 0)
|
||||
{
|
||||
result = this.AppendState(result, manager.GetString("prototype.db.prop.databaseState.value.emergency"));
|
||||
result = this.AppendState(result, manager.GetString("prototype_db_prop_databaseState_value_emergency"));
|
||||
}
|
||||
|
||||
if ((this.currentState.databaseState & DatabaseStatus.AutoClosed) != 0)
|
||||
{
|
||||
result = this.AppendState(result, manager.GetString("prototype.db.prop.databaseState.value.autoClosed"));
|
||||
result = this.AppendState(result, manager.GetString("prototype_db_prop_databaseState_value_autoClosed"));
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -1089,19 +1089,19 @@ WHERE do.database_id = @DbID
|
||||
{
|
||||
get
|
||||
{
|
||||
ResourceManager manager = new ResourceManager("Microsoft.SqlServer.Management.SqlManagerUI.CreateDatabaseStrings", typeof(DatabasePrototype).GetAssembly());
|
||||
ResourceManager manager = new ResourceManager("Microsoft.SqlTools.ServiceLayer.Localization.SR", typeof(DatabasePrototype).GetAssembly());
|
||||
string result = null;
|
||||
|
||||
switch (this.currentState.defaultCursor)
|
||||
{
|
||||
case DefaultCursor.Local:
|
||||
|
||||
result = manager.GetString("prototype.db.prop.defaultCursor.value.local");
|
||||
result = manager.GetString("prototype_db_prop_defaultCursor_value_local");
|
||||
break;
|
||||
|
||||
case DefaultCursor.Global:
|
||||
|
||||
result = manager.GetString("prototype.db.prop.defaultCursor.value.global");
|
||||
result = manager.GetString("prototype_db_prop_defaultCursor_value_global");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1110,9 +1110,9 @@ WHERE do.database_id = @DbID
|
||||
|
||||
set
|
||||
{
|
||||
ResourceManager manager = new ResourceManager("Microsoft.SqlServer.Management.SqlManagerUI.CreateDatabaseStrings", typeof(DatabasePrototype).GetAssembly());
|
||||
|
||||
if (value == manager.GetString("prototype.db.prop.defaultCursor.value.local"))
|
||||
ResourceManager manager = new ResourceManager("Microsoft.SqlTools.ServiceLayer.Localization.SR", typeof(DatabasePrototype).GetAssembly());
|
||||
|
||||
if (value == manager.GetString("prototype_db_prop_defaultCursor_value_local"))
|
||||
{
|
||||
this.currentState.defaultCursor = DefaultCursor.Local;
|
||||
}
|
||||
@@ -1547,7 +1547,7 @@ WHERE do.database_id = @DbID
|
||||
}
|
||||
}
|
||||
|
||||
// $FUTURE: 6/29/2004-stevetw Make sure version checks use this property,
|
||||
// Make sure version checks use this property,
|
||||
// not explicit comparisons against the server major version
|
||||
/// <summary>
|
||||
/// Whether the server is Yukon or later
|
||||
@@ -1897,9 +1897,7 @@ WHERE do.database_id = @DbID
|
||||
db.Alter(termination);
|
||||
}
|
||||
|
||||
// FIXED-SQLBUDefectTracking-20006074-2005/07/11-stevetw
|
||||
// have to explicitly set the default filegroup after the database has been created
|
||||
// Also bug 97696
|
||||
foreach (FilegroupPrototype filegroup in Filegroups)
|
||||
{
|
||||
if (filegroup.IsDefault && !(filegroup.Exists && db.FileGroups[filegroup.Name].IsDefault))
|
||||
@@ -2609,19 +2607,19 @@ WHERE do.database_id = @DbID
|
||||
{
|
||||
|
||||
TypeConverter.StandardValuesCollection result = null;
|
||||
ResourceManager manager = new ResourceManager("Microsoft.SqlServer.Management.SqlManagerUI.CreateDatabaseStrings", typeof(DatabasePrototype).GetAssembly());
|
||||
ResourceManager manager = new ResourceManager("Microsoft.SqlTools.ServiceLayer.Localization.SR", typeof(DatabasePrototype).GetAssembly());
|
||||
List<string> standardValues = new List<string>();
|
||||
|
||||
if (context.PropertyDescriptor.Name == "DefaultCursorDisplay")
|
||||
{
|
||||
standardValues.Add(manager.GetString("prototype.db.prop.defaultCursor.value.local"));
|
||||
standardValues.Add(manager.GetString("prototype.db.prop.defaultCursor.value.global"));
|
||||
standardValues.Add(manager.GetString("prototype_db_prop_defaultCursor_value_local"));
|
||||
standardValues.Add(manager.GetString("prototype_db_prop_defaultCursor_value_global"));
|
||||
}
|
||||
else if (context.PropertyDescriptor.Name == "RestrictAccess")
|
||||
{
|
||||
standardValues.Add(manager.GetString("prototype.db.prop.restrictAccess.value.multiple"));
|
||||
standardValues.Add(manager.GetString("prototype.db.prop.restrictAccess.value.single"));
|
||||
standardValues.Add(manager.GetString("prototype.db.prop.restrictAccess.value.restricted"));
|
||||
standardValues.Add(manager.GetString("prototype_db_prop_restrictAccess_value_multiple"));
|
||||
standardValues.Add(manager.GetString("prototype_db_prop_restrictAccess_value_single"));
|
||||
standardValues.Add(manager.GetString("prototype_db_prop_restrictAccess_value_restricted"));
|
||||
}
|
||||
|
||||
if (standardValues.Count > 0)
|
||||
@@ -253,21 +253,21 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
/// <returns>A string from the resource manager representing the value.</returns>
|
||||
private string GetDatabaseScopedConfigDisplayText(DatabaseScopedConfigurationOnOff onOffValue)
|
||||
{
|
||||
ResourceManager manager = new ResourceManager("Microsoft.SqlServer.Management.SqlManagerUI.CreateDatabaseStrings", typeof(DatabasePrototype).GetAssembly());
|
||||
ResourceManager manager = new ResourceManager("Microsoft.SqlTools.ServiceLayer.Localization.SR", typeof(DatabasePrototype).GetAssembly());
|
||||
string result = null;
|
||||
|
||||
switch (onOffValue)
|
||||
{
|
||||
case DatabaseScopedConfigurationOnOff.Off:
|
||||
result = manager.GetString("prototype.db.prop.databasescopedconfig.value.off");
|
||||
result = manager.GetString("prototype_db_prop_databasescopedconfig_value_off");
|
||||
break;
|
||||
|
||||
case DatabaseScopedConfigurationOnOff.On:
|
||||
result = manager.GetString("prototype.db.prop.databasescopedconfig.value.on");
|
||||
result = manager.GetString("prototype_db_prop_databasescopedconfig_value_on");
|
||||
break;
|
||||
|
||||
case DatabaseScopedConfigurationOnOff.Primary:
|
||||
result = manager.GetString("prototype.db.prop.databasescopedconfig.value.primary");
|
||||
result = manager.GetString("prototype_db_prop_databasescopedconfig_value_primary");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -282,13 +282,13 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
/// <returns>The database scoped configuration enum value that matches the display text.</returns>
|
||||
private DatabaseScopedConfigurationOnOff SetDatabaseScopedConfigHelper(string displayText, bool forSecondary)
|
||||
{
|
||||
ResourceManager manager = new ResourceManager("Microsoft.SqlServer.Management.SqlManagerUI.CreateDatabaseStrings", typeof(DatabasePrototype).GetAssembly());
|
||||
ResourceManager manager = new ResourceManager("Microsoft.SqlTools.ServiceLayer.Localization.SR", typeof(DatabasePrototype).GetAssembly());
|
||||
|
||||
if (displayText == manager.GetString("prototype.db.prop.databasescopedconfig.value.off"))
|
||||
if (displayText == manager.GetString("prototype_db_prop_databasescopedconfig_value_off"))
|
||||
{
|
||||
return DatabaseScopedConfigurationOnOff.Off;
|
||||
}
|
||||
else if (displayText == manager.GetString("prototype.db.prop.databasescopedconfig.value.on") || !forSecondary)
|
||||
else if (displayText == manager.GetString("prototype_db_prop_databasescopedconfig_value_on") || !forSecondary)
|
||||
{
|
||||
return DatabaseScopedConfigurationOnOff.On;
|
||||
}
|
||||
@@ -5,22 +5,17 @@
|
||||
|
||||
using System.ComponentModel;
|
||||
using System.Resources;
|
||||
//using Microsoft.SqlServer.Management.SqlMgmt;
|
||||
using Microsoft.SqlServer.Management.Common;
|
||||
using Microsoft.SqlServer.Management.Smo;
|
||||
using Microsoft.SqlServer.Management.Sdk.Sfc;
|
||||
using Microsoft.SqlServer.Management.Diagnostics;
|
||||
using System.Collections.Generic;
|
||||
|
||||
//using DisplayNameAttribute = Microsoft.SqlServer.Management.SqlMgmt.DisplayNameAttribute;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
{
|
||||
/// <summary>
|
||||
/// Database Prototype for SqlServer 2000 and later servers
|
||||
/// </summary>
|
||||
//[TypeConverter(typeof(DynamicValueTypeConverter))]
|
||||
//[StringResourceClass(typeof(Microsoft.SqlServer.Management.SqlManagerUI.CreateDatabaseOptionsSR))]
|
||||
internal class DatabasePrototype80 : DatabasePrototype, IDynamicValues
|
||||
{
|
||||
/// <summary>
|
||||
@@ -53,19 +48,19 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
{
|
||||
get
|
||||
{
|
||||
ResourceManager manager = new ResourceManager("Microsoft.SqlServer.Management.SqlManagerUI.CreateDatabaseStrings", typeof(DatabasePrototype80).GetAssembly());
|
||||
ResourceManager manager = new ResourceManager("Microsoft.SqlTools.ServiceLayer.Localization.SR", typeof(DatabasePrototype).GetAssembly());
|
||||
string result = null;
|
||||
|
||||
switch (this.currentState.pageVerify)
|
||||
{
|
||||
case PageVerify.Checksum:
|
||||
|
||||
result = manager.GetString("prototype.db.prop.pageVerify.value.checksum");
|
||||
result = manager.GetString("prototype_db_prop_pageVerify_value_checksum");
|
||||
break;
|
||||
|
||||
case PageVerify.None:
|
||||
|
||||
result = manager.GetString("prototype.db.prop.pageVerify.value.none");
|
||||
result = manager.GetString("prototype_db_prop_pageVerify_value_none");
|
||||
break;
|
||||
|
||||
case PageVerify.TornPageDetection:
|
||||
@@ -79,12 +74,12 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
|
||||
set
|
||||
{
|
||||
ResourceManager manager = new ResourceManager("Microsoft.SqlServer.Management.SqlManagerUI.CreateDatabaseStrings", typeof(DatabasePrototype80).GetAssembly());
|
||||
if (value == manager.GetString("prototype.db.prop.pageVerify.value.checksum"))
|
||||
ResourceManager manager = new ResourceManager("Microsoft.SqlTools.ServiceLayer.Localization.SR", typeof(DatabasePrototype).GetAssembly());
|
||||
if (value == manager.GetString("prototype_db_prop_pageVerify_value_checksum"))
|
||||
{
|
||||
this.currentState.pageVerify = PageVerify.Checksum;
|
||||
}
|
||||
else if (value == manager.GetString("prototype.db.prop.pageVerify.value.none"))
|
||||
else if (value == manager.GetString("prototype_db_prop_pageVerify_value_none"))
|
||||
{
|
||||
this.currentState.pageVerify = PageVerify.None;
|
||||
}
|
||||
@@ -198,7 +193,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
{
|
||||
base.SaveProperties(db);
|
||||
|
||||
ResourceManager manager = new ResourceManager("Microsoft.SqlServer.Management.SqlManagerUI.CreateDatabaseStrings", typeof(DatabasePrototype).GetAssembly());
|
||||
ResourceManager manager = new ResourceManager("Microsoft.SqlTools.ServiceLayer.Localization.SR", typeof(DatabasePrototype).GetAssembly());
|
||||
|
||||
// never set the real database collation to "<server default>" - there is no
|
||||
// real collation with that name. "<server default>" is only valid for new
|
||||
@@ -257,16 +252,16 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
|
||||
if (context.PropertyDescriptor.Name == "PageVerifyDisplay")
|
||||
{
|
||||
ResourceManager manager = new ResourceManager("Microsoft.SqlServer.Management.SqlManagerUI.CreateDatabaseStrings", typeof(DatabasePrototype80).GetAssembly());
|
||||
ResourceManager manager = new ResourceManager("Microsoft.SqlTools.ServiceLayer.Localization.SR", typeof(DatabasePrototype).GetAssembly());
|
||||
List<string> standardValues = new List<string>();
|
||||
|
||||
if (this.IsYukonOrLater)
|
||||
{
|
||||
standardValues.Add(manager.GetString("prototype.db.prop.pageVerify.value.checksum"));
|
||||
standardValues.Add(manager.GetString("prototype_db_prop_pageVerify_value_checksum"));
|
||||
}
|
||||
|
||||
standardValues.Add(manager.GetString("prototype.db.prop.pageVerify.value.tornPageDetection"));
|
||||
standardValues.Add(manager.GetString("prototype.db.prop.pageVerify.value.none"));
|
||||
standardValues.Add(manager.GetString("prototype_db_prop_pageVerify_value_tornPageDetection"));
|
||||
standardValues.Add(manager.GetString("prototype_db_prop_pageVerify_value_none"));
|
||||
|
||||
result = new TypeConverter.StandardValuesCollection(standardValues);
|
||||
}
|
||||
@@ -4,18 +4,14 @@
|
||||
//
|
||||
|
||||
using System.ComponentModel;
|
||||
// using Microsoft.SqlServer.Management.SqlMgmt;
|
||||
using Microsoft.SqlServer.Management.Sdk.Sfc;
|
||||
|
||||
// using DisplayNameAttribute = Microsoft.SqlServer.Management.SqlMgmt.DisplayNameAttribute;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
{
|
||||
/// <summary>
|
||||
/// Database Prototype for SqlServer 2000 SP3 and later servers
|
||||
/// </summary>
|
||||
[TypeConverter(typeof(DynamicValueTypeConverter))]
|
||||
//[StringResourceClass(typeof(Microsoft.SqlServer.Management.SqlManagerUI.CreateDatabaseOptionsSR))]
|
||||
internal class DatabasePrototype80SP3 : DatabasePrototype80
|
||||
{
|
||||
/// <summary>
|
||||
@@ -35,5 +31,3 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
public DatabasePrototype80SP3(CDataContainer context) : base(context) { }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,22 +5,17 @@
|
||||
|
||||
using System.ComponentModel;
|
||||
using System.Resources;
|
||||
// using Microsoft.SqlServer.Management.SqlMgmt;
|
||||
using Microsoft.SqlServer.Management.Smo;
|
||||
using Microsoft.SqlServer.Management.Common;
|
||||
using Microsoft.SqlServer.Management.Sdk.Sfc;
|
||||
using Microsoft.SqlServer.Management.Diagnostics;
|
||||
using System.Collections.Generic;
|
||||
|
||||
// using DisplayNameAttribute = Microsoft.SqlServer.Management.SqlMgmt.DisplayNameAttribute;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
{
|
||||
/// <summary>
|
||||
/// Database Prototype for SqlServer 2005 and later servers
|
||||
/// </summary>
|
||||
//[TypeConverter(typeof(DynamicValueTypeConverter))]
|
||||
//[StringResourceClass(typeof(Microsoft.SqlServer.Management.SqlManagerUI.CreateDatabaseOptionsSR))]
|
||||
internal class DatabasePrototype90 : DatabasePrototype80SP3, IDynamicValues
|
||||
{
|
||||
/// <summary>
|
||||
@@ -51,24 +46,24 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
{
|
||||
get
|
||||
{
|
||||
ResourceManager manager = new ResourceManager("Microsoft.SqlServer.Management.SqlManagerUI.CreateDatabaseStrings", typeof(DatabasePrototype80).GetAssembly());
|
||||
ResourceManager manager = new ResourceManager("Microsoft.SqlTools.ServiceLayer.Localization.SR", typeof(DatabasePrototype).GetAssembly());
|
||||
string result = null;
|
||||
|
||||
switch (this.currentState.pageVerify)
|
||||
{
|
||||
case PageVerify.Checksum:
|
||||
|
||||
result = manager.GetString("prototype.db.prop.pageVerify.value.checksum");
|
||||
result = manager.GetString("prototype_db_prop_pageVerify_value_checksum");
|
||||
break;
|
||||
|
||||
case PageVerify.None:
|
||||
|
||||
result = manager.GetString("prototype.db.prop.pageVerify.value.none");
|
||||
result = manager.GetString("prototype_db_prop_pageVerify_value_none");
|
||||
break;
|
||||
|
||||
case PageVerify.TornPageDetection:
|
||||
|
||||
result = manager.GetString("prototype.db.prop.pageVerify.value.tornPageDetection");
|
||||
result = manager.GetString("prototype_db_prop_pageVerify_value_tornPageDetection");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -77,12 +72,12 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
|
||||
set
|
||||
{
|
||||
ResourceManager manager = new ResourceManager("Microsoft.SqlServer.Management.SqlManagerUI.CreateDatabaseStrings", typeof(DatabasePrototype80).GetAssembly());
|
||||
if (value == manager.GetString("prototype.db.prop.pageVerify.value.checksum"))
|
||||
ResourceManager manager = new ResourceManager("Microsoft.SqlTools.ServiceLayer.Localization.SR", typeof(DatabasePrototype).GetAssembly());
|
||||
if (value == manager.GetString("prototype_db_prop_pageVerify_value_checksum"))
|
||||
{
|
||||
this.currentState.pageVerify = PageVerify.Checksum;
|
||||
}
|
||||
else if (value == manager.GetString("prototype.db.prop.pageVerify.value.none"))
|
||||
else if (value == manager.GetString("prototype_db_prop_pageVerify_value_none"))
|
||||
{
|
||||
this.currentState.pageVerify = PageVerify.None;
|
||||
}
|
||||
@@ -192,17 +187,17 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
{
|
||||
get
|
||||
{
|
||||
ResourceManager manager = new ResourceManager("Microsoft.SqlServer.Management.SqlManagerUI.CreateDatabaseStrings", typeof(DatabasePrototype90).GetAssembly());
|
||||
ResourceManager manager = new ResourceManager("Microsoft.SqlTools.ServiceLayer.Localization.SR", typeof(DatabasePrototype).GetAssembly());
|
||||
string result = this.currentState.parameterization ?
|
||||
manager.GetString("prototype.db.prop.parameterization.value.forced") :
|
||||
manager.GetString("prototype.db.prop.parameterization.value.simple");
|
||||
manager.GetString("prototype_db_prop_parameterization_value_forced") :
|
||||
manager.GetString("prototype_db_prop_parameterization_value_simple");
|
||||
|
||||
return result;
|
||||
}
|
||||
set
|
||||
{
|
||||
ResourceManager manager = new ResourceManager("Microsoft.SqlServer.Management.SqlManagerUI.CreateDatabaseStrings", typeof(DatabasePrototype90).GetAssembly());
|
||||
this.currentState.parameterization = (value == manager.GetString("prototype.db.prop.parameterization.value.forced"));
|
||||
ResourceManager manager = new ResourceManager("Microsoft.SqlTools.ServiceLayer.Localization.SR", typeof(DatabasePrototype).GetAssembly());
|
||||
this.currentState.parameterization = (value == manager.GetString("prototype_db_prop_parameterization_value_forced"));
|
||||
this.NotifyObservers();
|
||||
}
|
||||
}
|
||||
@@ -267,10 +262,10 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
|
||||
if (context.PropertyDescriptor.Name == "Parameterization")
|
||||
{
|
||||
ResourceManager manager = new ResourceManager("Microsoft.SqlServer.Management.SqlManagerUI.CreateDatabaseStrings", typeof(DatabasePrototype90).GetAssembly());
|
||||
ResourceManager manager = new ResourceManager("Microsoft.SqlTools.ServiceLayer.Localization.SR", typeof(DatabasePrototype).GetAssembly());
|
||||
List<string> standardValues = new List<string>();
|
||||
standardValues.Add(manager.GetString("prototype.db.prop.parameterization.value.forced"));
|
||||
standardValues.Add(manager.GetString("prototype.db.prop.parameterization.value.simple"));
|
||||
standardValues.Add(manager.GetString("prototype_db_prop_parameterization_value_forced"));
|
||||
standardValues.Add(manager.GetString("prototype_db_prop_parameterization_value_simple"));
|
||||
result = new TypeConverter.StandardValuesCollection(standardValues);
|
||||
}
|
||||
else
|
||||
@@ -4,19 +4,15 @@
|
||||
//
|
||||
|
||||
using System.ComponentModel;
|
||||
// using Microsoft.SqlServer.Management.SqlMgmt;
|
||||
using Microsoft.SqlServer.Management.Smo;
|
||||
using Microsoft.SqlServer.Management.Sdk.Sfc;
|
||||
|
||||
// using DisplayNameAttribute = Microsoft.SqlServer.Management.SqlMgmt.DisplayNameAttribute;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
{
|
||||
/// <summary>
|
||||
/// Database Prototype for SqlServer 2005 Enterprise SP2 and later servers
|
||||
/// </summary>
|
||||
[TypeConverter(typeof(DynamicValueTypeConverter))]
|
||||
//[StringResourceClass(typeof(Microsoft.SqlServer.Management.SqlManagerUI.CreateDatabaseOptionsSR))]
|
||||
internal class DatabasePrototype90EnterpriseSP2 : DatabasePrototype90
|
||||
{
|
||||
/// <summary>
|
||||
@@ -155,11 +155,22 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
private static int logicalNameCount = 0;
|
||||
|
||||
public static DatabasePrototype ApplyToPrototype(DatabaseInfo databaseInfo, DatabasePrototype prototype)
|
||||
{
|
||||
if (databaseInfo != null && prototype != null)
|
||||
{
|
||||
prototype.Name = GetValueOrDefault(AdminServicesProviderOptionsHelper.Name, databaseInfo.Options, prototype.Name);
|
||||
|
||||
foreach (var file in prototype.Files)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(file.Name))
|
||||
{
|
||||
file.Name = prototype.Name + "_" + logicalNameCount;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return prototype;
|
||||
}
|
||||
@@ -117,9 +117,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Workspace
|
||||
filePath = fileUri.LocalPath.TrimStart('/');
|
||||
}
|
||||
|
||||
// Some clients send paths with UNIX-style slashes, replace those if necessary
|
||||
filePath = filePath.Replace('/', '\\');
|
||||
|
||||
// Clients could specify paths with escaped space, [ and ] characters which .NET APIs
|
||||
// will not handle. These paths will get appropriately escaped just before being passed
|
||||
// into the SqlTools engine.
|
||||
|
||||
@@ -15,6 +15,7 @@ using Moq;
|
||||
using Microsoft.SqlTools.Hosting.Protocol;
|
||||
using Microsoft.SqlTools.ServiceLayer.Admin.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.Admin;
|
||||
using System;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.AdminServices
|
||||
{
|
||||
@@ -43,17 +44,20 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.AdminServices
|
||||
/// <summary>
|
||||
/// Validate creating a database with valid input
|
||||
/// </summary>
|
||||
// [Fact]
|
||||
[Fact]
|
||||
public async void CreateDatabaseWithValidInputTest()
|
||||
{
|
||||
var result = GetLiveAutoCompleteTestObjects();
|
||||
var requestContext = new Mock<RequestContext<CreateDatabaseResponse>>();
|
||||
requestContext.Setup(x => x.SendResult(It.IsAny<CreateDatabaseResponse>())).Returns(Task.FromResult(new object()));
|
||||
|
||||
var databaseInfo = new DatabaseInfo();
|
||||
databaseInfo.Options.Add("name", "testdb_" + new Random().Next(10000000, 99999999));
|
||||
|
||||
var dbParams = new CreateDatabaseParams
|
||||
{
|
||||
OwnerUri = result.ConnectionInfo.OwnerUri,
|
||||
DatabaseInfo = new DatabaseInfo()
|
||||
DatabaseInfo = databaseInfo
|
||||
};
|
||||
|
||||
await AdminService.HandleCreateDatabaseRequest(dbParams, requestContext.Object);
|
||||
@@ -61,11 +65,10 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.AdminServices
|
||||
requestContext.VerifyAll();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get a default database info object
|
||||
/// </summary>
|
||||
// [Fact]
|
||||
[Fact]
|
||||
public async void GetDefaultDatebaseInfoTest()
|
||||
{
|
||||
var result = GetLiveAutoCompleteTestObjects();
|
||||
|
||||
@@ -11,6 +11,26 @@ using Newtonsoft.Json;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Test.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Class to handle loading test configuration settings
|
||||
///
|
||||
/// Example contents of file at default location ~/sqlConnectionSettings.json
|
||||
///
|
||||
/// {
|
||||
/// "mssql.connections": [
|
||||
/// {
|
||||
/// "server": "localhost",
|
||||
/// "database": "master",
|
||||
/// "authenticationType": "SqlLogin",
|
||||
/// "user": "sa",
|
||||
/// "password": "[putvaluehere]",
|
||||
/// "serverType":"OnPrem",
|
||||
/// "VersionKey": "defaultSql2016"
|
||||
/// }
|
||||
/// ]
|
||||
/// }
|
||||
///
|
||||
/// </summary>
|
||||
public sealed class TestConfigPersistenceHelper
|
||||
{
|
||||
private static string DefaultSettingFileName = Path.Combine(FileUtils.UserRootFolder, "sqlConnectionSettings.json");
|
||||
|
||||
Reference in New Issue
Block a user