private void VerifyGetValidForFlag(SqlServerType serverType, ValidForFlag validForFlag) { ValidForFlag validforFlag = ServerVersionHelper.GetValidForFlag(serverType); ValidForFlag expected = validForFlag; Assert.Equal(validforFlag, expected); }
public void CalculateServerTypeShouldReturnSql2017Given2017Version() { string serverVersion = "14.1.2.3"; SqlServerType expected = SqlServerType.Sql2017; VerifyCalculateServerType(serverVersion, expected); }
public void CalculateServerTypeShouldReturnSqlOnDemandGivenEngineEdition() { int engineEdition = 11; SqlServerType expected = SqlServerType.SqlOnDemand; VerifyCalculateServerTypeForEngineEdition(engineEdition, expected); }
private void VerifyCalculateServerType(string serverVersion, SqlServerType expected) { ServerInfo serverInfo = new ServerInfo { ServerVersion = serverVersion }; SqlServerType actual = ServerVersionHelper.CalculateServerType(serverInfo); Assert.Equal(expected, actual); }
public void Clone(Connection connection) { this.SqlDatabase = connection.SqlDatabase; this.SqlServerType = connection.SqlServerType; this._connection = connection._connection; this._bGlobal = connection._bGlobal; this._lock = connection._lock; this._nLockTimeout = connection._nLockTimeout; this._nOpenCount = connection._nOpenCount; }
private void VerifyCalculateServerTypeForEngineEdition(int engineEdition, SqlServerType expected) { ServerInfo serverInfo = new ServerInfo { EngineEditionId = engineEdition }; SqlServerType actual = ServerVersionHelper.CalculateServerType(serverInfo); Assert.True(actual == expected, $"Verify server type based on Engine Edition. Actual value: {actual}, Expected value: {expected}"); }
/// <summary> /// Creates a server type from the server version /// </summary> public static SqlServerType CalculateServerType(ServerInfo serverInfo) { SqlServerType serverType = SqlServerType.Unknown; string serverVersion = serverInfo.ServerVersion; if (serverInfo.EngineEditionId == 11) { serverType = SqlServerType.SqlOnDemand; } else if (serverInfo.IsCloud) { serverType = SqlServerType.AzureV12; } else if (!string.IsNullOrWhiteSpace(serverVersion)) { if (serverVersion.StartsWith("9", StringComparison.Ordinal) || serverVersion.StartsWith("09", StringComparison.Ordinal)) { serverType = SqlServerType.Sql2005; } else if (serverVersion.StartsWith("10", StringComparison.Ordinal)) { serverType = SqlServerType.Sql2008; // and 2008R2 } else if (serverVersion.StartsWith("11", StringComparison.Ordinal)) { serverType = SqlServerType.Sql2012; } else if (serverVersion.StartsWith("12", StringComparison.Ordinal)) { serverType = SqlServerType.Sql2014; } else if (serverVersion.StartsWith("13", StringComparison.Ordinal)) { serverType = SqlServerType.Sql2016; } else if (serverVersion.StartsWith("14", StringComparison.Ordinal)) { serverType = SqlServerType.Sql2017; } else { // vNext case - default to latest version serverType = SqlServerType.Sql2017; } } return(serverType); }
/// <summary> /// Converts a server type to ValidForFlag /// </summary> public static ValidForFlag GetValidForFlag(SqlServerType serverType, bool isSqlDw) { ValidForFlag validforFlag = ValidForFlag.All; if (Enum.TryParse <ValidForFlag>(serverType.ToString(), out validforFlag)) { if (isSqlDw && serverType == SqlServerType.AzureV12) { validforFlag = ValidForFlag.SqlDw; } else { //TODO: not supporting SQL DW for on prem } return(validforFlag); } return(ValidForFlag.All); }
public void Connect() { using (ShellConnectionDialog dialog = new ShellConnectionDialog()) { IServerType serverType = new SqlServerType(); dialog.AddServer(serverType); UIConnectionInfo connectionInfo = new UIConnectionInfo(); if (dialog.ShowDialogCollectValues(ServiceCache.MainShellWindow, ref connectionInfo) == DialogResult.OK) { ConnectionManager.ConnectInternalsViewer(connectionInfo); this.allocationWindowControl.RefreshDatabases(); } } }
public static IUnitOfWork Create(string connString, SqlServerType serverType) { switch (serverType) { case SqlServerType.MsSql: { return(new SqlUnitOfWork(connString)); } case SqlServerType.MySql: case SqlServerType.OracleSql: case SqlServerType.PostgreSql: default: { throw new NotSupportedException($"{serverType} not supported now. Please contact your developer team"); } } }
public ServerNode(ConnectionCompleteParams connInfo, IMultiServiceProvider serviceProvider, ServerConnection serverConnection) : base() { Validate.IsNotNull(nameof(connInfo), connInfo); Validate.IsNotNull("connInfo.ConnectionSummary", connInfo.ConnectionSummary); Validate.IsNotNull(nameof(serviceProvider), serviceProvider); this.connectionSummary = connInfo.ConnectionSummary; this.serverInfo = connInfo.ServerInfo; this.sqlServerType = ServerVersionHelper.CalculateServerType(this.serverInfo); this.context = new Lazy <SmoQueryContext>(() => CreateContext(serviceProvider)); this.serverConnection = serverConnection; NodeValue = connectionSummary.ServerName; IsAlwaysLeaf = false; NodeType = NodeTypes.Server.ToString(); NodeTypeId = NodeTypes.Server; Label = GetConnectionLabel(); }
/// <summary> /// Converts a server type to ValidForFlag /// </summary> public static ValidForFlag GetValidForFlag(SqlServerType serverType, Database database = null) { return(GetValidForFlag(serverType, database != null && database.IsSqlDw)); }
/* public Connection(SqlServerType server_type, string strConnectionString) { this.SqlServerType = server_type; if (server_type == rms.SqlServerType.MsSqlServer) this.m_connection = new SqlConnection(strConnectionString); else if (server_type == rms.SqlServerType.SQLite) this.m_connection = new SQLiteConnection(strConnectionString); else { throw new Exception("不支持的类型 " + server_type.ToString()); } } * */ public Connection(SqlDatabase database, string strConnectionString, ConnectionStyle style = ConnectionStyle.None) { this.SqlDatabase = database; this.SqlServerType = database.container.SqlServerType; if (this.m_nLockTimeout < this.SqlDatabase.m_nTimeOut) this.m_nLockTimeout = this.SqlDatabase.m_nTimeOut; if (this.SqlServerType == rms.SqlServerType.MsSqlServer) this.m_connection = new SqlConnection(strConnectionString); else if (this.SqlServerType == rms.SqlServerType.SQLite) { #if NO // SQLite 专用, 快速的, 全局共用的 if ((style & ConnectionStyle.Global) == ConnectionStyle.Global) { Debug.Assert(this.SqlDatabase.SQLiteInfo != null, ""); lock (this.SqlDatabase.SQLiteInfo) { if (this.SqlDatabase.SQLiteInfo.FastMode == false) { this.m_connection = new SQLiteConnection(strConnectionString); return; } if (this.SqlDatabase.SQLiteInfo.m_connection == null) { this.m_connection = new SQLiteConnection(strConnectionString); this.m_bGlobal = true; this.SqlDatabase.SQLiteInfo.m_connection = this; } else { // 复制成员 this.Clone(this.SqlDatabase.SQLiteInfo.m_connection); if (this.m_nLockTimeout < this.SqlDatabase.m_nTimeOut) this.m_nLockTimeout = this.SqlDatabase.m_nTimeOut; } } return; } #endif if ((style & ConnectionStyle.Global) == ConnectionStyle.Global) { this.m_bGlobal = true; } this.m_connection = new SQLiteConnection(strConnectionString); } else if (this.SqlServerType == rms.SqlServerType.MySql) this.m_connection = new MySqlConnection(strConnectionString); else if (this.SqlServerType == rms.SqlServerType.Oracle) this.m_connection = new OracleConnection(strConnectionString); else { throw new Exception("不支持的类型 " + this.SqlServerType.ToString()); } }
public void Clone(Connection connection) { this.SqlDatabase = connection.SqlDatabase; this.SqlServerType = connection.SqlServerType; this.m_connection = connection.m_connection; this.m_bGlobal = connection.m_bGlobal; this.m_lock = connection.m_lock; this.m_nLockTimeout = connection.m_nLockTimeout; this.m_nOpenCount = connection.m_nOpenCount; }
//public ManagerFactory() //{ //} public ManagerFactory(string conSring, SqlServerType sqlType) { DataBaseInfo.ConString = conSring; DataBaseInfo.SqlType = sqlType; }
/* * public Connection(SqlServerType server_type, * string strConnectionString) * { * this.SqlServerType = server_type; * if (server_type == rms.SqlServerType.MsSqlServer) * this.m_connection = new SqlConnection(strConnectionString); * else if (server_type == rms.SqlServerType.SQLite) * this.m_connection = new SQLiteConnection(strConnectionString); * else * { * throw new Exception("不支持的类型 " + server_type.ToString()); * } * } * */ public Connection(SqlDatabase database, string strConnectionString, ConnectionStyle style = ConnectionStyle.None) { this.SqlDatabase = database; this.SqlServerType = database.container.SqlServerType; if (this._nLockTimeout < this.SqlDatabase.m_nTimeOut) { this._nLockTimeout = this.SqlDatabase.m_nTimeOut; } if (this.SqlServerType == rms.SqlServerType.MsSqlServer) { this._connection = new SqlConnection(strConnectionString); } else if (this.SqlServerType == rms.SqlServerType.SQLite) { #if NO // SQLite 专用, 快速的, 全局共用的 if ((style & ConnectionStyle.Global) == ConnectionStyle.Global) { Debug.Assert(this.SqlDatabase.SQLiteInfo != null, ""); lock (this.SqlDatabase.SQLiteInfo) { if (this.SqlDatabase.SQLiteInfo.FastMode == false) { this.m_connection = new SQLiteConnection(strConnectionString); return; } if (this.SqlDatabase.SQLiteInfo.m_connection == null) { this.m_connection = new SQLiteConnection(strConnectionString); this.m_bGlobal = true; this.SqlDatabase.SQLiteInfo.m_connection = this; } else { // 复制成员 this.Clone(this.SqlDatabase.SQLiteInfo.m_connection); if (this.m_nLockTimeout < this.SqlDatabase.m_nTimeOut) { this.m_nLockTimeout = this.SqlDatabase.m_nTimeOut; } } } return; } #endif if ((style & ConnectionStyle.Global) == ConnectionStyle.Global) { this._bGlobal = true; } this._connection = new SQLiteConnection(strConnectionString); } else if (this.SqlServerType == rms.SqlServerType.MySql) { this._connection = new MySqlConnection(strConnectionString); } else if (this.SqlServerType == rms.SqlServerType.Oracle) { this._connection = new OracleConnection(strConnectionString); } else { throw new Exception("不支持的类型 " + this.SqlServerType.ToString()); } }