コード例 #1
0
        /// <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()));
        }
コード例 #2
0
        /// <summary>
        /// Get show connection string using server name and show code.
        /// </summary>
        /// <param name="showCode"></param>
        /// <param name="serverName"></param>
        /// <param name="appTypeCode"></param>
        /// <returns></returns>
        public virtual string GetConnectionString(string showCode, string serverName, AppTypeCode appTypeCode)
        {
            // for caching purpose
            string cachedConnectionStringKey = string.Concat(serverName, showCode, appTypeCode.ToString()).ToLower();

            if (cachedConnectionStrings.ContainsKey(cachedConnectionStringKey))
            {
                return(cachedConnectionStrings[cachedConnectionStringKey].ToString());
            }

            return(this.GetConnectionString(
                       cachedConnectionStringKey,
                       ConnectionManagerBase.GetGenericConnectionString(serverName, this.EntDatabaseName),
                       showCode,
                       appTypeCode.ToString()));
        }