Exemplo n.º 1
0
        /// <summary>
        /// 获取SystemCore库的 公共配置信息
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static AppSettings DBGetInfo(string key)
        {
            AppSettings result = null;

            if (!cacheDBInfoAppSettings.TryGetValue(key, out result))
            {
                lock (objLock)
                {
                    if (!cacheDBInfoAppSettings.TryGetValue(key, out result))
                    {
                        result = CPQuery.From(string.Format(_sqlGetInfoKey, ConnStringHelper.GetDBName("SystemCore")), new { KeyName = key }).ToSingle <AppSettings>();
                        if (result != null)
                        {
                            cacheDBInfoAppSettings.Add(key, result);
                        }
                    }
                }
            }
            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取SystemCore库的 公共配置信息
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static string DBGet(string key)
        {
            string result = string.Empty;

            if (!cacheDBAppSettings.TryGetValue(key, out result))
            {
                lock (objLock)
                {
                    if (!cacheDBAppSettings.TryGetValue(key, out result))
                    {
                        result = CPQuery.From(string.Format(_sqlGetKey, ConnStringHelper.GetDBName("SystemCore")), new { KeyName = key }).ExecuteScalar <string>();
                        if (!string.IsNullOrEmpty(result))
                        {
                            cacheDBAppSettings.Add(key, result);
                        }
                    }
                }
            }
            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="dbName">数据库名</param>
        public static void Init(string dbName)
        {
            //zhangjm注释
            //if (string.IsNullOrEmpty(dbName))
            //{
            //    throw new ArgumentNullException("dbName");
            //}
            //初始化连接字符串
            //ConnStringHelper.Initializer();

            //注册连接字符串(CPQuery需要)
            // Panto.Map.Extensions.Initializer.UnSafeInit(ConnStringHelper.GetConnString(dbName));
            Panto.Map.Extensions.Initializer.UnSafeInit(ConnStringHelper.GetConnectString(dbName));

            //加载XmlCommand
            //var path = s_root + "/App_Data/XmlCommand/".Replace("/", "\\");
            //if (Directory.Exists(path))
            //{
            //    XmlCommandManager.LoadCommands(path);
            //}
        }
Exemplo n.º 4
0
        /// <summary>
        /// 转换属性
        /// </summary>
        /// <param name="info">属性</param>
        /// <param name="entity">实体Sql信息</param>
        private void TransferProperty(PropertyInfo info, EntitySqlInfo entity)
        {
            DataColumnAttribute attrColumn = info.GetMyAttribute <DataColumnAttribute>();

            if (attrColumn != null)
            {
                var prop = "";
                if (!string.IsNullOrEmpty(attrColumn.Alias))
                {
                    prop = string.Format("{0}.[{1}]", entity.TableName, attrColumn.Alias);
                }
                else
                {
                    prop = string.Format("{0}.[{1}]", entity.TableName, info.Name);
                }
                entity.Properties.Add(prop);
                if (attrColumn.PrimaryKey)
                {
                    entity.PrimaryKey = prop;
                }
            }
            else
            {
                ExtendColumnAttribute attrExtColumn = info.GetMyAttribute <ExtendColumnAttribute>();
                if (attrExtColumn != null && attrExtColumn.ColumnType != 0)
                {
                    switch (attrExtColumn.ColumnType)
                    {
                    case ExtendColumnTypeEnum.KeyParamOption_Code:
                        entity.ExtendTables.Add(string.Format("LEFT JOIN dbo.KeyParamOption AS {0} ON [{0}].[Code] = {1}.[{2}] AND [{0}].[ParamGroup] = '{3}'", info.Name, entity.TableName, attrExtColumn.RelationColumn, attrExtColumn.Expression));
                        entity.Properties.Add(string.Format("[{0}].[Name] AS {0}", info.Name));
                        break;

                    case ExtendColumnTypeEnum.KeyParamOption_Guid:
                        entity.ExtendTables.Add(string.Format("LEFT JOIN dbo.KeyParamOption AS {0} ON [{0}].[KeyParamOptionID] = {1}.[{2}]", info.Name, entity.TableName, attrExtColumn.RelationColumn));
                        entity.Properties.Add(string.Format("[{0}].[Name] AS {0}", info.Name));
                        break;

                    case ExtendColumnTypeEnum.UserName_Guid:
                        entity.ExtendTables.Add(string.Format("LEFT JOIN {0}.dbo.ORG_UserInfo AS {1} ON [{1}].[UserGUID] = {2}.[{3}]", ConnStringHelper.GetDBName("SystemCore"), info.Name, entity.TableName, attrExtColumn.RelationColumn));
                        entity.Properties.Add(string.Format("[{0}].[UserName_Chn] AS {0}", info.Name));
                        break;

                    case ExtendColumnTypeEnum.UserName_Code:
                        entity.ExtendTables.Add(string.Format("LEFT JOIN {0}.dbo.ORG_UserInfo AS {1} ON [{1}].[UserCode] = {2}.[{3}]", ConnStringHelper.GetDBName("SystemCore"), info.Name, entity.TableName, attrExtColumn.RelationColumn));
                        entity.Properties.Add(string.Format("[{0}].[UserName_Chn] AS {0}", info.Name));
                        break;

                    case ExtendColumnTypeEnum.BusinessUnit_Guid:
                        entity.ExtendTables.Add(string.Format("LEFT JOIN {0}.dbo.ORG_BusinessUnit AS {1} ON [{1}].[BUGUID] = {2}.[{3}]", ConnStringHelper.GetDBName("SystemCore"), info.Name, entity.TableName, attrExtColumn.RelationColumn));
                        entity.Properties.Add(string.Format("[{0}].[BUName] AS {0}", info.Name));
                        break;

                    case ExtendColumnTypeEnum.BusinessUnit_Code:
                        entity.ExtendTables.Add(string.Format("LEFT JOIN {0}.dbo.ORG_BusinessUnit AS {1} ON [{1}].[BUCode] = {2}.[{3}]", ConnStringHelper.GetDBName("SystemCore"), info.Name, entity.TableName, attrExtColumn.RelationColumn));
                        entity.Properties.Add(string.Format("[{0}].[BUName] AS {0}", info.Name));
                        break;

                    case ExtendColumnTypeEnum.Common:
                        entity.ExtendTables.Add(attrExtColumn.Expression);
                        entity.Properties.Add(attrExtColumn.RelationColumn);
                        break;
                    }
                }
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// 验证当前用户是否具有某功能权限
 /// </summary>
 /// <param name="systemGuid">系统GUID</param>
 /// <param name="functionCode">功能编码</param>
 /// <param name="actionCode">动作点编码</param>
 /// <returns>返回true,表示有权限;返回false,表示无权限</returns>
 public bool ValidFuncPermission(Guid systemGuid, string functionCode, string actionCode)
 {
     using (ConnectionScope scope = new ConnectionScope(TransactionMode.Inherits, ConnStringHelper.GetConnString("SystemCore")))
     {
         if (systemGuid.Equals(Guid.Empty))
         {
             throw new MyException("系统GUID没有初始化");
         }
         var parameters = new
         {
             //BUGUID = Panto.Framework.Login.UserManager.GetCurrentUser().UserGUID,
             FuncMenuCode = functionCode,
             SystemGUID   = systemGuid,
             ActionCode   = actionCode
         };
         var count = CPQuery.From(@"SELECT COUNT(*)
                             FROM dbo.PERM_RoleToUser AS a
                             INNER JOIN dbo.ROLE_RoleInfo AS b ON a.RoleGUID=b.RoleGUID
                             INNER JOIN dbo.PERM_FuncPermissionInfo AS c ON a.RoleGUID=c.RoleGUID
                             INNER JOIN dbo.SYS_ActionInfo AS d ON c.FuncGUID = d.ActionGUID
                             INNER JOIN dbo.SYS_FuncMenuInfo AS e ON d.FuncMenuGUID = e.FuncMenuGUID
                             WHERE a.BUGUID = @BUGUID AND e.FuncMenuCode = @FuncMenuCode AND b.SystemGUID =@SystemGUID AND d.ActionCode=@ActionCode", parameters).ExecuteScalar <int>();
         if (count > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }