通用权限管理系统基类中数据库的连接

    public class BaseController : Controller
    {

        /// <summary>
        /// 用户中心Dbhelper 
        /// </summary>
        public IDbHelper DbHelperUserCenter = GetDbConnection(BaseSystemInfo.UserCenterDbType, BaseSystemInfo.UserCenterDbConnection, ConfigHelper.GetConfigBool("BusinessDbEncrypt"));
        /// <summary>
        /// 业务库Dbhelper 
        /// </summary>
        public IDbHelper DbHelperBusiness = GetDbConnection(BaseSystemInfo.BusinessDbType, BaseSystemInfo.BusinessDbConnection, ConfigHelper.GetConfigBool("UserCenterDbEncrypt"));
        /// <summary>
        /// 获得DbHelper
        /// </summary>
        /// <param name="currentDbType">数据库类别</param>
        /// <param name="dbConnection">连接字符串</param>
        /// <param name="dbEncrypt">是否加密</param>
        /// <returns>IDbHelper</returns>
        private static IDbHelper GetDbConnection(CurrentDbType currentDbType, string dbConnection, bool dbEncrypt = false)
        {
            if (dbEncrypt)
            {
                dbConnection= SecretUtil.Decrypt(dbConnection);
            }
            return DbHelperFactory.GetHelper(currentDbType, dbConnection);
        }

..........
}

 

这里是mvc中基类的写法,其中提供了数据库使用加密方式后的解密方法。

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。