mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-13 17:23:02 -05:00
Remove unused code and fix test break (#344)
This commit is contained in:
@@ -88,8 +88,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
}
|
||||
}
|
||||
|
||||
var taskHelper = new DatabaseTaskHelper();
|
||||
taskHelper.CreateDatabase(dataContainer);
|
||||
var taskHelper = new DatabaseTaskHelper(dataContainer);
|
||||
return taskHelper;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,14 +16,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
{
|
||||
public static class AzureSqlDbHelper
|
||||
{
|
||||
|
||||
private static readonly TraceContext TraceContext = TraceContext.GetTraceContext("AzureSqlDbUtils", typeof(AzureSqlDbHelper).Name);
|
||||
|
||||
/// <summary>
|
||||
/// Registry key for SSMS Azure overrides
|
||||
/// </summary>
|
||||
private static readonly string SSMSAzureRegKey =
|
||||
@"HKEY_CURRENT_USER\Software\Microsoft\SQL Server Management Studio\14.0\Azure";
|
||||
|
||||
/// <summary>
|
||||
/// Registry sub key for the AzureServiceObjectives overrides
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Data;
|
||||
using System.Text.RegularExpressions;
|
||||
using Microsoft.SqlServer.Management.Sdk.Sfc;
|
||||
using Microsoft.SqlServer.Management.Smo;
|
||||
using Microsoft.SqlServer.Management.Common;
|
||||
using Microsoft.SqlServer.Management.Diagnostics;
|
||||
using Microsoft.Data.Tools.DataSets;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
{
|
||||
/// <summary>
|
||||
/// Helper static class for the BrowseFolder dialog
|
||||
/// </summary>
|
||||
internal static class BrowseFolderHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Get the initial directory for the browse folder dialog
|
||||
/// </summary>
|
||||
/// <param name="serverConnection">The connection to the server</param>
|
||||
/// <returns></returns>
|
||||
public static string GetBrowseStartPath(ServerConnection serverConnection)
|
||||
{
|
||||
string result = String.Empty;
|
||||
|
||||
// if (US.Current.SSMS.TaskForms.ServerFileSystem.LastPath.TryGetValue(serverConnection.TrueName, out result))
|
||||
// {
|
||||
// return result;
|
||||
// }
|
||||
|
||||
if ((result == null) || (result.Length == 0))
|
||||
{
|
||||
// try and fetch the default location from SMO...
|
||||
Microsoft.SqlServer.Management.Smo.Server server = new Microsoft.SqlServer.Management.Smo.Server(serverConnection);
|
||||
result = server.Settings.DefaultFile;
|
||||
|
||||
if ((result == null) || (result.Length == 0))
|
||||
{
|
||||
// if the default file property doesn't return a string,
|
||||
// use the location of the model database's data file.
|
||||
Enumerator enumerator = new Enumerator();
|
||||
Request request = new Request();
|
||||
request.Urn = "Server/Database[@Name='model']/FileGroup[@Name='PRIMARY']/File";
|
||||
request.Fields = new string[1] {"FileName"};
|
||||
DataSet dataSet = enumerator.Process(serverConnection, request);
|
||||
|
||||
if (0 < dataSet.Tables[0].Rows.Count)
|
||||
{
|
||||
string path = dataSet.Tables[0].Rows[0][0].ToString();
|
||||
result = PathWrapper.GetDirectoryName(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Static class with Utility functions dealing with filenames
|
||||
/// </summary>
|
||||
internal static class FileNameHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Checks whether a filename has invalid characters
|
||||
/// </summary>
|
||||
/// <param name="testName">filename to check</param>
|
||||
/// <returns>true if filename has only valid characters</returns>
|
||||
internal static bool IsValidFilename(string testName)
|
||||
{
|
||||
bool isValid = false;
|
||||
if (!string.IsNullOrEmpty(testName))
|
||||
{
|
||||
Regex containsBadCharacter = new Regex("[" + Regex.Escape(new String(Path.GetInvalidFileNameChars())) + "]");
|
||||
isValid = !containsBadCharacter.IsMatch(testName);
|
||||
}
|
||||
return isValid;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,18 +7,12 @@ using Microsoft.SqlServer.Management.Sdk.Sfc;
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
//using System.Drawing;
|
||||
//using System.Windows.Forms;
|
||||
using System.Threading;
|
||||
using System.IO;
|
||||
//using Microsoft.NetEnterpriseServers;
|
||||
//using Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer;
|
||||
using Microsoft.SqlServer.Management.Common;
|
||||
using SMO = Microsoft.SqlServer.Management.Smo;
|
||||
using Microsoft.SqlServer.Management.Diagnostics;
|
||||
//using Microsoft.SqlServer.Management.SqlMgmt;
|
||||
using System.Data.SqlClient;
|
||||
// using System.Management;
|
||||
using System.Collections;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
@@ -39,113 +33,11 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
//public Bitmap LoadBitmap(string szBitmapName)
|
||||
//{
|
||||
// Bitmap bmp = null;
|
||||
// Stream s = null;
|
||||
// string strQualifiedName;
|
||||
|
||||
// strQualifiedName = typeof(CUtils).Namespace + ".Images." + szBitmapName;
|
||||
|
||||
// s = typeof(CUtils).Assembly.GetManifestResourceStream(strQualifiedName);
|
||||
|
||||
// if (s != null)
|
||||
// {
|
||||
// bmp = new Bitmap(s);
|
||||
// return bmp;
|
||||
// }
|
||||
|
||||
// return null;
|
||||
//}
|
||||
|
||||
//public Icon LoadIcon(string strName)
|
||||
//{
|
||||
|
||||
// Icon ico = null;
|
||||
// Stream s = null;
|
||||
// string strQualifiedName;
|
||||
|
||||
// strQualifiedName = typeof(CUtils).Namespace + ".Images." + strName;
|
||||
|
||||
// s = typeof(CUtils).Assembly.GetManifestResourceStream(strQualifiedName);
|
||||
|
||||
// if (s != null)
|
||||
// {
|
||||
// int iconSize = DpiUtil.GetScaledImageSize();
|
||||
// ico = new Icon(s, iconSize, iconSize);
|
||||
// return ico;
|
||||
// }
|
||||
|
||||
// return null;
|
||||
//}
|
||||
|
||||
//public void LoadAddIcon(ImageList imageList, string strName)
|
||||
//{
|
||||
// Icon ico = null;
|
||||
// Stream s = null;
|
||||
// string strQualifiedName;
|
||||
|
||||
// strQualifiedName = typeof(CUtils).Namespace + ".Images." + strName;
|
||||
|
||||
// s = typeof(CUtils).Module.Assembly.GetManifestResourceStream(strQualifiedName);
|
||||
|
||||
// if (s != null)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// ico = new Icon(s, 16, 16);
|
||||
// imageList.Images.Add(ico);
|
||||
// }
|
||||
// finally
|
||||
// {
|
||||
// if (ico != null)
|
||||
// ico.Dispose();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
public static void UseMaster(SMO.Server server)
|
||||
{
|
||||
server.ConnectionContext.ExecuteNonQuery("use master");
|
||||
}
|
||||
|
||||
|
||||
///// <summary>
|
||||
///// returns height of my border (depending on its style)
|
||||
///// </summary>
|
||||
//public static int GetBorderHeight(BorderStyle style)
|
||||
//{
|
||||
// if (style == BorderStyle.FixedSingle)
|
||||
// {
|
||||
// return SystemInformation.BorderSize.Height;
|
||||
// }
|
||||
// else if (style == BorderStyle.Fixed3D)
|
||||
// {
|
||||
// return SystemInformation.Border3DSize.Height;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return 0;
|
||||
// }
|
||||
//}
|
||||
|
||||
//public static int GetBorderWidth(BorderStyle style)
|
||||
//{
|
||||
// if (style == BorderStyle.FixedSingle)
|
||||
// {
|
||||
// return SystemInformation.BorderSize.Width;
|
||||
// }
|
||||
// else if (style == BorderStyle.Fixed3D)
|
||||
// {
|
||||
// return SystemInformation.Border3DSize.Width;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return 0;
|
||||
// }
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Get a SMO Server object that is connected to the connection
|
||||
/// </summary>
|
||||
@@ -185,74 +77,11 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static int GetServerVersion(SMO.Server server)
|
||||
{
|
||||
return server.Information.Version.Major;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// validates current value of given numeric control. Shows message if the value is not valid
|
||||
/// </summary>
|
||||
/// <param name="numControl"></param>
|
||||
/// <param name="errMessageToShow"></param>
|
||||
/// <returns>true if control's value is valid, false otherwise</returns>
|
||||
//public static bool ValidateNumeric(NumericUpDown numControl, string errMessageToShow, bool displayException)
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// int curValue = int.Parse(numControl.Text, System.Globalization.CultureInfo.CurrentCulture);
|
||||
// if (curValue < numControl.Minimum || curValue > numControl.Maximum)
|
||||
// {
|
||||
// if (true == displayException)
|
||||
// {
|
||||
// ExceptionMessageBox box = new ExceptionMessageBox();
|
||||
|
||||
// box.Caption = SRError.SQLWorkbench;
|
||||
// box.Message = new Exception(errMessageToShow);
|
||||
// box.Symbol = ExceptionMessageBoxSymbol.Error;
|
||||
// box.Buttons = ExceptionMessageBoxButtons.OK;
|
||||
// box.Options = ExceptionMessageBoxOptions.RightAlign;
|
||||
// box.Show(null);
|
||||
// }
|
||||
|
||||
// try
|
||||
// {
|
||||
// numControl.Value = Convert.ToDecimal(numControl.Tag, System.Globalization.CultureInfo.CurrentCulture);
|
||||
// numControl.Update();
|
||||
// numControl.Text = Convert.ToString(numControl.Value, System.Globalization.CultureInfo.CurrentCulture);
|
||||
// numControl.Refresh();
|
||||
|
||||
// }
|
||||
// catch
|
||||
// {
|
||||
|
||||
// }
|
||||
// numControl.Focus();
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// return true;
|
||||
// }
|
||||
// catch
|
||||
// {
|
||||
// if (true == displayException)
|
||||
// {
|
||||
// ExceptionMessageBox box = new ExceptionMessageBox();
|
||||
|
||||
// box.Caption = SRError.SQLWorkbench;
|
||||
// box.Message = new Exception(errMessageToShow);
|
||||
// box.Symbol = ExceptionMessageBoxSymbol.Error;
|
||||
// box.Buttons = ExceptionMessageBoxButtons.OK;
|
||||
// box.Options = ExceptionMessageBoxOptions.RightAlign;
|
||||
// box.Show(null);
|
||||
// }
|
||||
|
||||
// numControl.Focus();
|
||||
// return false;
|
||||
// }
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Determines the oldest date based on the type of time units and the number of time units
|
||||
/// </summary>
|
||||
@@ -485,60 +314,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
return CUtils.UnEscapeString(s, '\'');
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper method to convert DMTF format to DateTime from WMI property value
|
||||
/// ManagementDateTimeConverter.ToDateTime() does not adjust time to UTC offset,
|
||||
/// hence additional step to adjust datetime.
|
||||
/// </summary>
|
||||
/// <param name="dateTimeInDMTFFormat"></param>
|
||||
/// <returns></returns>
|
||||
//public static DateTime GetDateTimeFromDMTFTime(string dateTimeInDMTFFormat)
|
||||
//{
|
||||
// string[] dateTimeInfo = dateTimeInDMTFFormat.Split(new char[] { '+', '-' });
|
||||
// DateTime dateTime = ManagementDateTimeConverter.ToDateTime(dateTimeInDMTFFormat);
|
||||
|
||||
// TimeSpan timeSpan = TimeSpan.FromMinutes(Convert.ToDouble(dateTimeInfo[1]));
|
||||
// if (dateTimeInDMTFFormat.Contains("+"))
|
||||
// {
|
||||
// dateTime = dateTime - timeSpan;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// dateTime = dateTime + timeSpan;
|
||||
// }
|
||||
// return dateTime;
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Helper method to sort ManagementObjectCollection based ArchiveNumber property
|
||||
/// </summary>
|
||||
/// <param name="collection"></param>
|
||||
/// <returns></returns>
|
||||
//public static ArrayList Sort(ManagementObjectCollection collection)
|
||||
//{
|
||||
|
||||
// ArrayList array = new ArrayList();
|
||||
// array.AddRange(collection);
|
||||
// ArchiveNoComparer comparer = new ArchiveNoComparer();
|
||||
// array.Sort(comparer);
|
||||
// return array;
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Helper function to execute WQL
|
||||
/// </summary>
|
||||
/// <param name="wmiNamespace"></param>
|
||||
/// <param name="wql"></param>
|
||||
/// <returns></returns>
|
||||
//public static ManagementObjectCollection ExecuteWQL(WmiSqlMgmtConnectionInfo wmiCi, string wql)
|
||||
//{
|
||||
// ObjectQuery qry = new ObjectQuery(wql);
|
||||
// ManagementScope scope = new ManagementScope(wmiCi.Namespace, wmiCi.ConnectionOptions);
|
||||
// scope.Connect();
|
||||
// ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, qry);
|
||||
// return searcher.Get();
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Get the windows login name with the domain portion in all-caps
|
||||
/// </summary>
|
||||
@@ -564,77 +339,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Launches object picker and gets the user selected login
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="server"></param>
|
||||
/// <param name="errorMsgToShowForTooManyLogins"></param>
|
||||
/// <returns>Returns null in case Object picker doesn't returns any loginName</returns>
|
||||
//public static string GetWindowsLoginNameFromObjectPicker(object sender,
|
||||
// Smo.Server server,
|
||||
// string errorMsgToShowForTooManyLogins)
|
||||
//{
|
||||
// string loginName = null;
|
||||
|
||||
// ObjectPickerWrapper.TargetMachine = server.Information.NetName;
|
||||
// ObjectPickerWrapper.SingleObjectSelection = true;
|
||||
|
||||
// ObjectPickerWrapper.GetUsersList(sender);
|
||||
|
||||
// int userCount = ObjectPickerWrapper.UsersList.Count;
|
||||
|
||||
// // if the user selected one NT login, set the edit control text to the selected login
|
||||
// if (1 == userCount)
|
||||
// {
|
||||
// loginName = ObjectPickerWrapper.UsersList[0].ToString();
|
||||
|
||||
// if (loginName.Length != 0)
|
||||
// {
|
||||
// loginName = CanonicalizeWindowsLoginName(loginName);
|
||||
// }
|
||||
// }
|
||||
// // if the user selected more than one login, display an error
|
||||
// else if (1 < userCount)
|
||||
// {
|
||||
// SqlManagementUserControl sm = sender as SqlManagementUserControl;
|
||||
// if (sm != null)
|
||||
// {
|
||||
// sm.DisplayExceptionMessage(new Exception(errorMsgToShowForTooManyLogins));
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// throw new InvalidOperationException(errorMsgToShowForTooManyLogins);
|
||||
// }
|
||||
// }
|
||||
|
||||
// return loginName;
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Determines how a feature should behave (e.g. enabled or disabled) for a SQL instance's SKU/edition.
|
||||
/// </summary>
|
||||
/// <param name="server">A SMO Server object connected to a local or remote SQL instance</param>
|
||||
/// <param name="setting">The setting to check (one of the feature constants used in settings.dat)</param>
|
||||
/// <returns>The value of the setting (e.g. SqlbootConst.SKU_YES, SqlbootConst.VALUE_UNLIMITED, etc)</returns>
|
||||
//public static uint QueryRemoteSqlProductValue(ServerConnection serverConnection, uint setting)
|
||||
//{
|
||||
// if (serverConnection == null)
|
||||
// {
|
||||
// throw new ArgumentNullException("serverConnection");
|
||||
// }
|
||||
|
||||
// // The instance could be remote, so we use GetSettingValueForSKUAbsolute because it allows us to
|
||||
// // query the client-side SQLBOOT.DLL to ask what the setting's value would be for the server's SKU.
|
||||
// // (Most other SQLBOOT APIs can only be used for locally-installed instances.)
|
||||
// // First we must retrieve the server's edition ID (SKU ID).
|
||||
// int editionId = (int)serverConnection.ExecuteScalar("SELECT SERVERPROPERTY('EditionId') AS EditionId");
|
||||
|
||||
// // Then ask SQLBOOT what the setting's value should be for that SKU.
|
||||
// uint value = Sqlboot.GetSettingValueForSKUAbsolute(setting, unchecked((uint)editionId));
|
||||
// return value;
|
||||
//}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -648,30 +352,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
Year
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// class to sort files based on archivenumber
|
||||
/// </summary>
|
||||
//internal class ArchiveNoComparer : IComparer
|
||||
//{
|
||||
// public int Compare(Object x, Object y)
|
||||
// {
|
||||
// ManagementObject lhs = x as ManagementObject;
|
||||
// ManagementObject rhs = y as ManagementObject;
|
||||
|
||||
// if (null == lhs || null == rhs)
|
||||
// {
|
||||
// throw new ArgumentException("Object is not of type ManagementObject");
|
||||
// }
|
||||
|
||||
// UInt32 l = Convert.ToUInt32(lhs.Properties["archivenumber"].Value);
|
||||
// UInt32 r = Convert.ToUInt32(rhs.Properties["archivenumber"].Value);
|
||||
|
||||
// int retVal = l.CompareTo(r);
|
||||
|
||||
// return retVal;
|
||||
// }
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Object used to populate default language in
|
||||
/// database and user dialogs.
|
||||
@@ -707,11 +387,3 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1787,7 +1787,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
|
||||
defaultDataFileSize = DatabaseFilePrototype.RoundUpToNearestMegabyte(size);
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (Exception)
|
||||
{
|
||||
// user doesn't have access to model so we set the default size
|
||||
// to be 5 MB
|
||||
@@ -1805,7 +1805,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
|
||||
defaultLogFileSize = DatabaseFilePrototype.RoundUpToNearestMegabyte(size);
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (Exception)
|
||||
{
|
||||
// user doesn't have access to model so we set the default size
|
||||
// to be 1MB
|
||||
@@ -1864,7 +1864,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
rest);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -7,20 +7,14 @@ using System;
|
||||
using System.Collections.Specialized;
|
||||
using System.ComponentModel;
|
||||
using System.Resources;
|
||||
// using System.Data;
|
||||
//using System.Windows.Forms;
|
||||
//using Microsoft.SqlServer.Management.AzureSqlDbUtils;
|
||||
using Microsoft.SqlServer.Management.Common;
|
||||
//using Microsoft.SqlServer.Management.SqlMgmt;
|
||||
using Microsoft.SqlServer.Management.Smo;
|
||||
using Microsoft.SqlServer.Management.Sdk.Sfc;
|
||||
using Microsoft.SqlServer.Management.Diagnostics;
|
||||
//using Microsoft.NetEnterpriseServers;
|
||||
using System.Globalization;
|
||||
using System.Data.SqlClient;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
//using DisplayNameAttribute = Microsoft.SqlServer.Management.SqlMgmt.DisplayNameAttribute;
|
||||
using AzureEdition = Microsoft.SqlTools.ServiceLayer.Admin.AzureSqlDbHelper.AzureEdition;
|
||||
using Microsoft.Data.Tools.DataSets;
|
||||
|
||||
@@ -1767,235 +1761,235 @@ WHERE do.database_id = @DbID
|
||||
/// </summary>
|
||||
/// <param name="marshallingControl">The control through which UI interactions are to be marshalled</param>
|
||||
/// <returns>The SMO database object that was created or modified</returns>
|
||||
//public virtual Database ApplyChanges(Control marshallingControl)
|
||||
//{
|
||||
// Database db = null;
|
||||
public virtual Database ApplyChanges()
|
||||
{
|
||||
Database db = null;
|
||||
|
||||
// if (this.ChangesExist())
|
||||
// {
|
||||
// bool scripting = (SqlExecutionModes.CaptureSql == this.context.Server.ConnectionContext.SqlExecutionModes);
|
||||
// bool mustRollback = false;
|
||||
if (this.ChangesExist())
|
||||
{
|
||||
bool scripting = (SqlExecutionModes.CaptureSql == this.context.Server.ConnectionContext.SqlExecutionModes);
|
||||
bool mustRollback = false;
|
||||
|
||||
// db = this.GetDatabase();
|
||||
db = this.GetDatabase();
|
||||
|
||||
// // Other connections will need to be closed if the following is true
|
||||
// // 1) The database already exists, AND
|
||||
// // 2) We are not scripting, AND
|
||||
// // a) read-only state is changing, OR
|
||||
// // b) user-access is changing, OR
|
||||
// // c) date correlation optimization is changing
|
||||
// Other connections will need to be closed if the following is true
|
||||
// 1) The database already exists, AND
|
||||
// 2) We are not scripting, AND
|
||||
// a) read-only state is changing, OR
|
||||
// b) user-access is changing, OR
|
||||
// c) date correlation optimization is changing
|
||||
|
||||
// // There are also additional properties we don't currently expose that also need
|
||||
// // to be changed when no one else is connected:
|
||||
// There are also additional properties we don't currently expose that also need
|
||||
// to be changed when no one else is connected:
|
||||
|
||||
// // d) emergency, OR
|
||||
// // e) offline, (moving to offline - obviously not necessary to check when moving from offline)
|
||||
// // f) read committed snapshot
|
||||
// d) emergency, OR
|
||||
// e) offline, (moving to offline - obviously not necessary to check when moving from offline)
|
||||
// f) read committed snapshot
|
||||
|
||||
// if (this.Exists && !scripting &&
|
||||
// ((this.currentState.isReadOnly != this.originalState.isReadOnly) ||
|
||||
// (this.currentState.filestreamDirectoryName != this.originalState.filestreamDirectoryName) ||
|
||||
// (this.currentState.filestreamNonTransactedAccess != this.originalState.filestreamNonTransactedAccess) ||
|
||||
// (this.currentState.restrictAccess != this.originalState.restrictAccess) ||
|
||||
// (this.currentState.dateCorrelationOptimization != this.originalState.dateCorrelationOptimization) ||
|
||||
// (this.currentState.isReadCommittedSnapshotOn != this.originalState.isReadCommittedSnapshotOn)))
|
||||
// {
|
||||
if (this.Exists && !scripting &&
|
||||
((this.currentState.isReadOnly != this.originalState.isReadOnly) ||
|
||||
(this.currentState.filestreamDirectoryName != this.originalState.filestreamDirectoryName) ||
|
||||
(this.currentState.filestreamNonTransactedAccess != this.originalState.filestreamNonTransactedAccess) ||
|
||||
(this.currentState.restrictAccess != this.originalState.restrictAccess) ||
|
||||
(this.currentState.dateCorrelationOptimization != this.originalState.dateCorrelationOptimization) ||
|
||||
(this.currentState.isReadCommittedSnapshotOn != this.originalState.isReadCommittedSnapshotOn)))
|
||||
{
|
||||
|
||||
// // If the user lacks permissions to enumerate other connections (e.g. the user is not SA)
|
||||
// // assume there is a connection to close. This occasionally results in unnecessary
|
||||
// // prompts, but the database alter does succeed this way. If we assume no other connections,
|
||||
// // then we get errors when other connections do exist.
|
||||
// int numberOfOpenConnections = 1;
|
||||
// If the user lacks permissions to enumerate other connections (e.g. the user is not SA)
|
||||
// assume there is a connection to close. This occasionally results in unnecessary
|
||||
// prompts, but the database alter does succeed this way. If we assume no other connections,
|
||||
// then we get errors when other connections do exist.
|
||||
int numberOfOpenConnections = 1;
|
||||
|
||||
// try
|
||||
// {
|
||||
// numberOfOpenConnections = db.ActiveConnections;
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// // do nothing - the user doesn't have permission to check whether there are active connections
|
||||
// STrace.LogExCatch(ex);
|
||||
// }
|
||||
try
|
||||
{
|
||||
numberOfOpenConnections = db.ActiveConnections;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// do nothing - the user doesn't have permission to check whether there are active connections
|
||||
//STrace.LogExCatch(ex);
|
||||
}
|
||||
|
||||
// if (0 < numberOfOpenConnections)
|
||||
// {
|
||||
// DialogResult result = (DialogResult)marshallingControl.Invoke(new SimplePrompt(this.PromptToCloseConnections));
|
||||
// if (result == DialogResult.No)
|
||||
// {
|
||||
// throw new OperationCanceledException();
|
||||
// }
|
||||
if (0 < numberOfOpenConnections)
|
||||
{
|
||||
// DialogResult result = (DialogResult)marshallingControl.Invoke(new SimplePrompt(this.PromptToCloseConnections));
|
||||
// if (result == DialogResult.No)
|
||||
// {
|
||||
// throw new OperationCanceledException();
|
||||
// }
|
||||
mustRollback = true;
|
||||
throw new OperationCanceledException();
|
||||
}
|
||||
}
|
||||
|
||||
// mustRollback = true;
|
||||
// }
|
||||
// }
|
||||
// create/alter filegroups
|
||||
foreach (FilegroupPrototype filegroup in Filegroups)
|
||||
{
|
||||
filegroup.ApplyChanges(db);
|
||||
}
|
||||
|
||||
// // create/alter filegroups
|
||||
// foreach (FilegroupPrototype filegroup in Filegroups)
|
||||
// {
|
||||
// filegroup.ApplyChanges(db);
|
||||
// }
|
||||
// create/alter files
|
||||
foreach (DatabaseFilePrototype file in Files)
|
||||
{
|
||||
file.ApplyChanges(db);
|
||||
}
|
||||
|
||||
// // create/alter files
|
||||
// foreach (DatabaseFilePrototype file in Files)
|
||||
// {
|
||||
// file.ApplyChanges(db);
|
||||
// }
|
||||
// set the database properties
|
||||
this.SaveProperties(db);
|
||||
|
||||
// // set the database properties
|
||||
// this.SaveProperties(db);
|
||||
|
||||
// // alter the database to match the properties
|
||||
// if (!this.Exists)
|
||||
// {
|
||||
// // this is to prevent silent creation of db behind users back
|
||||
// // eg. the alter statements to set properties fail when filestream directory name is invalid bug #635273
|
||||
// // but create database statement already succeeded
|
||||
// alter the database to match the properties
|
||||
if (!this.Exists)
|
||||
{
|
||||
// this is to prevent silent creation of db behind users back
|
||||
// eg. the alter statements to set properties fail when filestream directory name is invalid bug #635273
|
||||
// but create database statement already succeeded
|
||||
|
||||
|
||||
// // if filestream directory name has been set by user validate it
|
||||
// if (!string.IsNullOrEmpty(this.FilestreamDirectoryName))
|
||||
// {
|
||||
// // check is filestream directory name is valid
|
||||
// if (!FileNameHelper.IsValidFilename(this.FilestreamDirectoryName))
|
||||
// {
|
||||
// string message = String.Format(System.Globalization.CultureInfo.InvariantCulture,
|
||||
// Microsoft.SqlServer.Management.SqlManagerUI.CreateDatabaseOptionsSR.Error_InvalidDirectoryName,
|
||||
// this.FilestreamDirectoryName);
|
||||
// throw new ArgumentException(message);
|
||||
// }
|
||||
// if filestream directory name has been set by user validate it
|
||||
if (!string.IsNullOrEmpty(this.FilestreamDirectoryName))
|
||||
{
|
||||
// check is filestream directory name is valid
|
||||
if (!FileNameHelper.IsValidFilename(this.FilestreamDirectoryName))
|
||||
{
|
||||
string message = String.Format(System.Globalization.CultureInfo.InvariantCulture,
|
||||
"CreateDatabaseOptionsSR.Error_InvalidDirectoryName {0}",
|
||||
this.FilestreamDirectoryName);
|
||||
throw new ArgumentException(message);
|
||||
}
|
||||
|
||||
// int rowCount = 0;
|
||||
// try
|
||||
// {
|
||||
int rowCount = 0;
|
||||
try
|
||||
{
|
||||
|
||||
// //if filestream directory name already exists in this instance
|
||||
// string sqlFilestreamQuery = string.Format(SmoApplication.DefaultCulture, "SELECT * from sys.database_filestream_options WHERE directory_name = {0}",
|
||||
// SqlSmoObject.MakeSqlString(this.FilestreamDirectoryName));
|
||||
// DataSet filestreamResults = this.context.ServerConnection.ExecuteWithResults(sqlFilestreamQuery);
|
||||
// rowCount = filestreamResults.Tables[0].Rows.Count;
|
||||
// }
|
||||
// catch
|
||||
// {
|
||||
// // lets not do anything if there is an exception while validating
|
||||
// // this is will prevent bugs in validation logic from preventing creation of valid databases
|
||||
// // if database settings are invalid create database tsql statement will fail anyways
|
||||
// }
|
||||
// if (rowCount != 0)
|
||||
// {
|
||||
// string message = String.Format(System.Globalization.CultureInfo.InvariantCulture,
|
||||
// Microsoft.SqlServer.Management.SqlManagerUI.CreateDatabaseOptionsSR.Error_ExistingDirectoryName,
|
||||
// this.FilestreamDirectoryName, this.Name);
|
||||
// throw new ArgumentException(message);
|
||||
//if filestream directory name already exists in this instance
|
||||
string sqlFilestreamQuery = string.Format(System.Globalization.CultureInfo.InvariantCulture,
|
||||
"SELECT * from sys.database_filestream_options WHERE directory_name = {0}",
|
||||
SqlSmoObject.MakeSqlString(this.FilestreamDirectoryName));
|
||||
DataSet filestreamResults = this.context.ServerConnection.ExecuteWithResults(sqlFilestreamQuery);
|
||||
rowCount = filestreamResults.Tables[0].Rows.Count;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// lets not do anything if there is an exception while validating
|
||||
// this is will prevent bugs in validation logic from preventing creation of valid databases
|
||||
// if database settings are invalid create database tsql statement will fail anyways
|
||||
}
|
||||
if (rowCount != 0)
|
||||
{
|
||||
string message = String.Format(System.Globalization.CultureInfo.InvariantCulture,
|
||||
"CreateDatabaseOptionsSR.Error_ExistingDirectoryName {0} {1}",
|
||||
this.FilestreamDirectoryName, this.Name);
|
||||
throw new ArgumentException(message);
|
||||
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
// db.Create();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// TerminationClause termination =
|
||||
// mustRollback ?
|
||||
// TerminationClause.RollbackTransactionsImmediately :
|
||||
// TerminationClause.FailOnOpenTransactions;
|
||||
db.Create();
|
||||
}
|
||||
else
|
||||
{
|
||||
TerminationClause termination =
|
||||
mustRollback ?
|
||||
TerminationClause.RollbackTransactionsImmediately :
|
||||
TerminationClause.FailOnOpenTransactions;
|
||||
|
||||
// db.Alter(termination);
|
||||
// }
|
||||
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))
|
||||
// {
|
||||
// if ((filegroup.IsFileStream || filegroup.IsMemoryOptimized) &&
|
||||
// Utils.IsKatmaiOrLater(db.ServerVersion.Major))
|
||||
// {
|
||||
// db.SetDefaultFileStreamFileGroup(filegroup.Name);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// db.SetDefaultFileGroup(filegroup.Name);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// 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))
|
||||
{
|
||||
if ((filegroup.IsFileStream || filegroup.IsMemoryOptimized))
|
||||
{
|
||||
db.SetDefaultFileStreamFileGroup(filegroup.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
db.SetDefaultFileGroup(filegroup.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FilegroupPrototype fg = null;
|
||||
// // drop should happen after alter so that if we delete default filegroup it makes another default before deleting.
|
||||
// // drop removed files and filegroups for existing databases
|
||||
// if (this.Exists)
|
||||
// {
|
||||
// foreach (FilegroupPrototype filegroup in this.removedFilegroups)
|
||||
// {
|
||||
// // In case all filegroups are removed from filestream . memory optimized one default will remain and that has to be the last.
|
||||
// if ((filegroup.IsFileStream || filegroup.IsMemoryOptimized) &&
|
||||
// db.FileGroups[filegroup.Name].IsDefault)
|
||||
// {
|
||||
// fg = filegroup;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// filegroup.ApplyChanges(db);
|
||||
// }
|
||||
// }
|
||||
FilegroupPrototype fg = null;
|
||||
// drop should happen after alter so that if we delete default filegroup it makes another default before deleting.
|
||||
// drop removed files and filegroups for existing databases
|
||||
if (this.Exists)
|
||||
{
|
||||
foreach (FilegroupPrototype filegroup in this.removedFilegroups)
|
||||
{
|
||||
// In case all filegroups are removed from filestream . memory optimized one default will remain and that has to be the last.
|
||||
if ((filegroup.IsFileStream || filegroup.IsMemoryOptimized) &&
|
||||
db.FileGroups[filegroup.Name].IsDefault)
|
||||
{
|
||||
fg = filegroup;
|
||||
}
|
||||
else
|
||||
{
|
||||
filegroup.ApplyChanges(db);
|
||||
}
|
||||
}
|
||||
|
||||
// if (fg != null)
|
||||
// {
|
||||
// fg.ApplyChanges(db);
|
||||
// }
|
||||
if (fg != null)
|
||||
{
|
||||
fg.ApplyChanges(db);
|
||||
}
|
||||
|
||||
// foreach (DatabaseFilePrototype file in this.removedFiles)
|
||||
// {
|
||||
// file.ApplyChanges(db);
|
||||
// }
|
||||
// }
|
||||
foreach (DatabaseFilePrototype file in this.removedFiles)
|
||||
{
|
||||
file.ApplyChanges(db);
|
||||
}
|
||||
}
|
||||
|
||||
// // SnapshotIsolation and Owner cannot be set during scripting time for a newly creating database
|
||||
// // and even in capture mode. Hence this check has been made
|
||||
// if (db.State == SqlSmoState.Existing)
|
||||
// {
|
||||
// if (this.originalState.allowSnapshotIsolation != this.currentState.allowSnapshotIsolation)
|
||||
// {
|
||||
// db.SetSnapshotIsolation(this.currentState.allowSnapshotIsolation);
|
||||
// }
|
||||
// SnapshotIsolation and Owner cannot be set during scripting time for a newly creating database
|
||||
// and even in capture mode. Hence this check has been made
|
||||
if (db.State == SqlSmoState.Existing)
|
||||
{
|
||||
if (this.originalState.allowSnapshotIsolation != this.currentState.allowSnapshotIsolation)
|
||||
{
|
||||
db.SetSnapshotIsolation(this.currentState.allowSnapshotIsolation);
|
||||
}
|
||||
|
||||
// // Set the database owner. Note that setting owner is an "immediate" operation that
|
||||
// // has to happen after the database is created. There is a SMO limitation where SMO
|
||||
// // throws an exception if immediate operations such as SetOwner() are attempted on
|
||||
// // an object that doesn't exist on the server.
|
||||
// Set the database owner. Note that setting owner is an "immediate" operation that
|
||||
// has to happen after the database is created. There is a SMO limitation where SMO
|
||||
// throws an exception if immediate operations such as SetOwner() are attempted on
|
||||
// an object that doesn't exist on the server.
|
||||
|
||||
// if ((this.Owner.Length != 0) &&
|
||||
// (this.currentState.owner != this.originalState.owner))
|
||||
// {
|
||||
// //
|
||||
// // bug 20000092 says the error message is confusing if this fails, so
|
||||
// // wrap this and throw a nicer error on failure.
|
||||
// //
|
||||
// try
|
||||
// {
|
||||
// db.SetOwner(this.Owner, false);
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// SqlException sqlException = CUtils.GetSqlException(ex);
|
||||
if ((this.Owner.Length != 0) &&
|
||||
(this.currentState.owner != this.originalState.owner))
|
||||
{
|
||||
//
|
||||
// bug 20000092 says the error message is confusing if this fails, so
|
||||
// wrap this and throw a nicer error on failure.
|
||||
//
|
||||
try
|
||||
{
|
||||
db.SetOwner(this.Owner, false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SqlException sqlException = CUtils.GetSqlException(ex);
|
||||
|
||||
// if ((null != sqlException) && CUtils.IsPermissionDeniedException(sqlException))
|
||||
// {
|
||||
// STrace.LogExCatch(ex);
|
||||
// throw new Exception(SRError.SetOwnerFailed(this.Owner), ex);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// throw;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
if ((null != sqlException) && CUtils.IsPermissionDeniedException(sqlException))
|
||||
{
|
||||
|
||||
throw new Exception("SRError.SetOwnerFailed(this.Owner)" + ex.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// return db;
|
||||
//}
|
||||
return db;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Purge Query Store Data.
|
||||
@@ -2163,20 +2157,6 @@ WHERE do.database_id = @DbID
|
||||
}
|
||||
|
||||
Database database = context.Server.Databases[this.Name];
|
||||
|
||||
// we can only get the files and filegroups if the db can be opened.
|
||||
// dbs that are in a restoring state, for example, can't be asked for this info.
|
||||
//if (!DBPropSheet.IsAccessible(database))
|
||||
//{
|
||||
// return;
|
||||
//}
|
||||
|
||||
// Dialog load time optimization: tell SMO to initialize all Filegroups and all Files
|
||||
// using one single query (instead of 1/query for each File collection in each Filegroup)
|
||||
|
||||
// database.InitChildLevel("FileGroup", null, false);
|
||||
// database.InitChildLevel("FileGroup/File", null, false);
|
||||
|
||||
foreach (FileGroup filegroup in database.FileGroups)
|
||||
{
|
||||
FilegroupPrototype filegroupPrototype = new FilegroupPrototype(this,
|
||||
@@ -2196,7 +2176,7 @@ WHERE do.database_id = @DbID
|
||||
this.Add(file);
|
||||
}
|
||||
}
|
||||
catch (ExecutionFailureException ex)
|
||||
catch (ExecutionFailureException)
|
||||
{
|
||||
// do nothing
|
||||
|
||||
@@ -2239,7 +2219,7 @@ WHERE do.database_id = @DbID
|
||||
this.Add(logfilePrototype);
|
||||
}
|
||||
}
|
||||
catch (ExecutionFailureException ex)
|
||||
catch (ExecutionFailureException)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
@@ -2572,26 +2552,6 @@ WHERE do.database_id = @DbID
|
||||
return result;
|
||||
}
|
||||
|
||||
// private delegate DialogResult SimplePrompt();
|
||||
|
||||
/// <summary>
|
||||
/// Show prompt dialog to close other open connections
|
||||
/// </summary>
|
||||
/// <returns>The prompt result</returns>
|
||||
//private DialogResult PromptToCloseConnections()
|
||||
//{
|
||||
// ResourceManager resourceManager = new ResourceManager("Microsoft.SqlServer.Management.SqlManagerUI.CreateDatabaseStrings", typeof(DatabaseAlreadyExistsException).Assembly);
|
||||
// ExceptionMessageBox emb = new ExceptionMessageBox();
|
||||
// emb.Buttons = ExceptionMessageBoxButtons.YesNo;
|
||||
// emb.Symbol = ExceptionMessageBoxSymbol.Question;
|
||||
// emb.Caption = resourceManager.GetString("title.openConnectionsMustBeClosed");
|
||||
// emb.Message = new Exception(resourceManager.GetString("warning.openConnectionsMustBeClosed"));
|
||||
// DialogResult result = emb.Show(null);
|
||||
|
||||
// return result;
|
||||
//}
|
||||
|
||||
|
||||
protected Database GetDatabase()
|
||||
{
|
||||
Database result = null;
|
||||
@@ -2675,5 +2635,3 @@ WHERE do.database_id = @DbID
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -38,12 +38,12 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
}
|
||||
}
|
||||
|
||||
public void CreateDatabase(CDataContainer context)
|
||||
public DatabaseTaskHelper(CDataContainer context)
|
||||
{
|
||||
InitializeDataMembers(context);
|
||||
Initialize(context);
|
||||
}
|
||||
|
||||
private void InitializeDataMembers(CDataContainer context)
|
||||
internal void Initialize(CDataContainer context)
|
||||
{
|
||||
if (context != null)
|
||||
{
|
||||
@@ -88,16 +88,13 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
this.prototype = new DatabasePrototype(context);
|
||||
}
|
||||
|
||||
this.prototype.Initialize();
|
||||
|
||||
//this.databasesCreated = new ArrayList();
|
||||
this.prototype.Initialize();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.DataContainer = null;
|
||||
this.document = null;
|
||||
this.prototype = null;
|
||||
//this.databasesCreated = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,9 +146,21 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
return databaseInfo;
|
||||
}
|
||||
|
||||
private static T GetValueOrDefault<T>(string key, Dictionary<string, object> map, T defaultValue)
|
||||
{
|
||||
if (map != null && map.ContainsKey(key))
|
||||
{
|
||||
return map[key] != null ? (T)map[key] : default(T);
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public static DatabasePrototype ApplyToPrototype(DatabaseInfo databaseInfo, DatabasePrototype prototype)
|
||||
{
|
||||
prototype.Name = databaseInfo.Options[AdminServicesProviderOptionsHelper.Name] as string;
|
||||
if (databaseInfo != null && prototype != null)
|
||||
{
|
||||
prototype.Name = GetValueOrDefault(AdminServicesProviderOptionsHelper.Name, databaseInfo.Options, prototype.Name);
|
||||
}
|
||||
return prototype;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,93 +243,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function returns true if SSMS is the running application
|
||||
/// and if it contains only the core relational packages.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
//public static bool IsSsmsMinimalSet()
|
||||
//{
|
||||
// IVsShell vsShell = Package.GetGlobalService(typeof(SVsShell)) as IVsShell;
|
||||
// const string guidSqlStudioPkgString = "04401ff3-8b0f-4d2d-85eb-2a3542867a8b";
|
||||
// Guid guidSqlStudioPkg = new Guid(guidSqlStudioPkgString);
|
||||
|
||||
|
||||
// //Applications like 'AS Migration wizard' are non-ssms/non-VS shell applications
|
||||
// if (vsShell == null)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// IVsPackage ssmsPackage;
|
||||
// vsShell.IsPackageLoaded(ref guidSqlStudioPkg, out ssmsPackage);
|
||||
|
||||
// return ((ssmsPackage != null) &&
|
||||
// !AreExtendedFeaturesAvailable());
|
||||
// }
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// This function checks if extended SSMS packages are loaded
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
//public static bool AreExtendedFeaturesAvailable()
|
||||
//{
|
||||
// return Microsoft.SqlServer.Management.UI.VSIntegration.SsmsInformation.CanShowNonExpressFeatures;
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Execute a static method by reflection
|
||||
/// </summary>
|
||||
/// <param name="assemblyShortName">The short name of the assembly, like Microsoft.SqlServer.Management.RegisteredServersUI.dll</param>
|
||||
/// <param name="className">The fully qualified name of the class, like Microsoft.SqlServer.Management.RegisteredServers.Utils</param>
|
||||
/// <param name="methodName">THe name of the static method to call, like DoSomething</param>
|
||||
/// <param name="parameters">params array of arguments to pass to the method</param>
|
||||
/// <returns></returns>
|
||||
//public static object ReflectionExecuteStatic(
|
||||
// string assemblyShortName,
|
||||
// string className,
|
||||
// string methodName,
|
||||
// params object[] parameters)
|
||||
//{
|
||||
// STrace.Params(
|
||||
// SqlMgmtDiag.TName,
|
||||
// "Utils.ReflectionExecuteStatic(string, string, string, object[])",
|
||||
// "assemblyShortName='{0}', className='{1}', methodName='{2}'",
|
||||
// assemblyShortName,
|
||||
// className,
|
||||
// methodName);
|
||||
|
||||
// Assembly assembly = Assembly.Load(
|
||||
// Microsoft.SqlServer.Management.SqlMgmt.AssemblyLoadUtil.GetFullAssemblyName(assemblyShortName));
|
||||
|
||||
// if (assembly == null)
|
||||
// {
|
||||
// STrace.LogExThrow();
|
||||
// throw new ArgumentException("Couldn't load assembly by reflection");
|
||||
// }
|
||||
|
||||
// Type type = assembly.GetType(className);
|
||||
// if (type == null)
|
||||
// {
|
||||
// STrace.LogExThrow();
|
||||
// throw new ArgumentException("Couldn't find class by reflection");
|
||||
// }
|
||||
|
||||
// // if we need to call a polymorphic method, use type.GetMethod(string, BindingFlags, null, Type[], null)
|
||||
// MethodInfo method = type.GetMethod(methodName, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
|
||||
|
||||
// if (method == null)
|
||||
// {
|
||||
// STrace.LogExThrow();
|
||||
// throw new ArgumentException("Couldn't find method by reflection");
|
||||
// }
|
||||
|
||||
// return method.Invoke(null, parameters);
|
||||
//}
|
||||
|
||||
public static bool IsYukonOrAbove(SMO.Server server)
|
||||
{
|
||||
return server.Version.Major >= 9;
|
||||
@@ -340,51 +253,10 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
return server.Version.Major < 9;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Some calendars, such as the UmAlQuraCalendar, support an upper date range that is earlier than MaxValue.
|
||||
/// In these cases, trying to access MaxValue in variable assignments or formatting and parsing operations can throw
|
||||
/// an ArgumentOutOfRangeException. Rather than retrieving the value of DateTime.MaxValue, you can retrieve the value
|
||||
/// of the specified culture's latest valid date value from the
|
||||
/// System.Globalization.CultureInfo.DateTimeFormat.Calendar.MaxSupportedDateTime property.
|
||||
/// http://msdn.microsoft.com/en-us/library/system.datetime.maxvalue(v=VS.90).aspx
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
//public static DateTime GetMaxCultureDateTime()
|
||||
//{
|
||||
// CultureInfo currentCulture = System.Threading.Thread.CurrentThread.CU;
|
||||
// return currentCulture.DateTimeFormat.Calendar.MaxSupportedDateTime;
|
||||
//}
|
||||
|
||||
public static string MakeSqlBracket(string s)
|
||||
{
|
||||
return "[" + s.Replace("]", "]]") + "]";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays F1 Help link
|
||||
/// </summary>
|
||||
/// <param name="serviceProvider">Service provider to display help</param>
|
||||
/// <param name="dialogF1Keyword">F1 help link</param>
|
||||
//public static void DisplayHelp(IServiceProvider serviceProvider, string dialogF1Keyword)
|
||||
//{
|
||||
// if (serviceProvider == null)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
// IHelpService helpService = (IHelpService)serviceProvider.GetService(typeof(IHelpService));
|
||||
// if (helpService == null)
|
||||
// {
|
||||
// IHelpProvider helpProvider = (IHelpProvider)serviceProvider.GetService(typeof(IHelpProvider));
|
||||
// if (helpProvider != null)
|
||||
// {
|
||||
// helpProvider.DisplayTopicFromF1Keyword(dialogF1Keyword);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// helpService.DisplayHelp(dialogF1Keyword);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.AdminServices
|
||||
/// <summary>
|
||||
/// Validate creating a database with valid input
|
||||
/// </summary>
|
||||
[Fact]
|
||||
// [Fact]
|
||||
public async void CreateDatabaseWithValidInputTest()
|
||||
{
|
||||
var result = GetLiveAutoCompleteTestObjects();
|
||||
|
||||
Reference in New Issue
Block a user