/// <summary> /// Get show connection string in specific environment. /// </summary> /// <param name="showCode"></param> /// <param name="environment"></param> /// <param name="appTypeCode"></param> /// <returns></returns> public virtual string GetConnectionString(string showCode, ServerTypeCode environment, AppTypeCode appTypeCode) { // flush environment keys CMSecurity.Flush(); // find environment master DataRow[] server = ConnectionManagerBase.ServerTable.Select("servertypecode = '" + environment.ToString() + "' and IsEnvironmentMaster = 1"); if (server.Length == 0) { throw new Exception("Failed to retrieve environment server information."); } string entServerName = server[0]["ServerName"].ToString(); // for caching purpose string cachedConnectionStringKey = string.Concat(entServerName, showCode, appTypeCode.ToString()).ToLower(); if (cachedConnectionStrings.ContainsKey(cachedConnectionStringKey)) { return(cachedConnectionStrings[cachedConnectionStringKey].ToString()); } return(this.GetConnectionString( cachedConnectionStringKey, ConnectionManagerBase.GetGenericConnectionString(entServerName, this.EntDatabaseName), showCode, appTypeCode.ToString())); }
public virtual string GetEntConnectionString(ServerTypeCode environment) { var filter = string.Format("[ServerTypeCode] = '{0}' AND [IsEnvironmentMaster] = 1", Enum.GetName(typeof(ServerTypeCode), environment)); var server = ConnectionManagerBase.ServerTable.Select(filter).FirstOrDefault(); if (server == null || !server.Table.Columns.Contains("ServerName") || server.Table.Columns["ServerName"].DataType != typeof(string)) { throw new Exception("Failed to retrieve environment server information."); } var entServerName = (string)server["ServerName"]; return(ConnectionManagerBase.GetWinAuthConnectionString(entServerName, this.EntDatabaseName)); }