Example #1
0
        /// <summary>
        /// 获取数据库连接字符串(&lt;connectionStrings&gt;节点)
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static string GetConnString(string key)
        {
            var conn = ConfigurationManager.ConnectionStrings[key];

            if (conn == null)
            {
                throw new Exception(EnumCommon.GetDescription(ConfigEnum.AppSetting));
            }
            return(ConfigurationManager.ConnectionStrings[key].ConnectionString);
        }
Example #2
0
 /// <summary>
 /// 得到密钥
 /// </summary>
 /// <param name="key">用户输入密钥</param>
 /// <returns></returns>
 private static string FindEncryptKey(string key)
 {
     if (!string.IsNullOrEmpty(key))
     {
         return(key);//用户输入秘钥
     }
     if (!string.IsNullOrEmpty(AesEncryptionKey))
     {
         return(AesEncryptionKey);
     }
     AesEncryptionKey = ConfigCommon.GetConfig(AesEncryptionKeyNamePresent);
     if (!string.IsNullOrEmpty(AesEncryptionKey))
     {
         return(AesEncryptionKey);
     }
     throw new Exception(string.Format(EnumCommon.GetDescription(ConfigEnum.AppSetting), AesEncryptionKeyNamePresent));
 }