Пример #1
0
        /// <summary>
        /// 按操作权限获取列表
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="tableName">目标表</param>
        /// <param name="permissionCode">操作权限</param>
        /// <returns>数据表</returns>
        public List <BaseItemDetailsEntity> GetListByPermission(BaseUserInfo userInfo, string tableName, string permissionCode = "Resource.ManagePermission")
        {
            List <BaseItemDetailsEntity> result = null;

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessUserCenterReadDb(userInfo, parameter, (dbHelper) =>
            {
                var itemDetailsManager = new BaseItemDetailsManager(dbHelper, userInfo, tableName);

                // 管理员取得所有数据
                if (userInfo.IsAdministrator)
                {
                    result = itemDetailsManager.GetList <BaseItemDetailsEntity>(
                        new KeyValuePair <string, object>(BaseItemDetailsEntity.FieldDeletionStateCode, 0)
                        , BaseItemDetailsEntity.FieldSortCode);
                }
                else
                {
                    // 管理时需要把所有的数据显示出来,所以无效的数据也需要显示的
                    // , new KeyValuePair<string, object>(BaseItemDetailsEntity.FieldEnabled, 1)

                    // 按数据权限来过滤数据
                    BasePermissionScopeManager permissionScopeManager = new BasePermissionScopeManager(dbHelper, userInfo);
                    string[] ids = permissionScopeManager.GetResourceScopeIds(userInfo.SystemCode, userInfo.Id, tableName, permissionCode);
                    result       = itemDetailsManager.GetList <BaseItemDetailsEntity>(ids);
                }
            });
            return(result);
        }
Пример #2
0
        public List <BaseItemDetailsEntity> GetListByCode(IDbHelper dbHelper, BaseUserInfo userInfo, string code)
        {
            // 2013-09-07 吉日嘎拉 目标表,这样来个默认的表名,有助于提高稳定性,可以有一定的容错功能
            string targetTable = "Items" + code;

            // 检查有其他目标数据库表存储了数据
            BaseItemsManager itemsManager = new BaseItemsManager(dbHelper, userInfo);
            BaseItemsEntity  itemsEntity  = BaseEntity.Create <BaseItemsEntity>(itemsManager.GetDataTable(new KeyValuePair <string, object>(BaseItemsEntity.FieldCode, code)));

            if (itemsEntity != null && !String.IsNullOrEmpty(itemsEntity.TargetTable))
            {
                targetTable = itemsEntity.TargetTable;
            }

            BaseItemDetailsManager itemDetailsManager = new BaseItemDetailsManager(dbHelper, userInfo);

            itemDetailsManager = new BaseItemDetailsManager(dbHelper, userInfo, targetTable);
            // 这里只要有效的,没被删除的
            List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >();

            // 管理的时候无效的也需要被管理
            parameters.Add(new KeyValuePair <string, object>(BaseItemDetailsEntity.FieldEnabled, 1));
            parameters.Add(new KeyValuePair <string, object>(BaseItemDetailsEntity.FieldDeletionStateCode, 0));

            return(itemDetailsManager.GetList <BaseItemDetailsEntity>(parameters, BaseItemDetailsEntity.FieldSortCode));
        }
Пример #3
0
        /// <summary>
        /// 获取模块菜单表,从缓存读取
        /// 2016-03-14 吉日嘎拉 更新有缓存功能
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <param name="refresh">刷新</param>
        /// <returns>选项数据列表</returns>
        public static List <BaseItemDetailsEntity> GetEntitiesByCache(string tableName, bool refresh = false)
        {
            List <BaseItemDetailsEntity> result = null;

            string key = "ItemDetails:" + tableName;

            if (!refresh)
            {
                result = GetListCache(key);
            }

            if (result == null)
            {
                // 这里只要有效的,没被删除的
                BaseItemDetailsManager itemDetailsManager        = new BaseItemDetailsManager(tableName);
                List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >();
                // 管理的时候无效的也需要被管理
                parameters.Add(new KeyValuePair <string, object>(BaseItemDetailsEntity.FieldEnabled, 1));
                parameters.Add(new KeyValuePair <string, object>(BaseItemDetailsEntity.FieldDeletionStateCode, 0));
                result = itemDetailsManager.GetList <BaseItemDetailsEntity>(parameters, BaseItemDetailsEntity.FieldSortCode);

                // 若是空的不用缓存,继续读取实体
                if (result != null)
                {
                    SetListCache(key, result);
                }
            }

            return(result);
        }
Пример #4
0
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="tableName">目标表</param>
        /// <returns>列表</returns>
        public List <BaseItemDetailsEntity> GetList(BaseUserInfo userInfo, string tableName)
        {
            List <BaseItemDetailsEntity> entityList = new List <BaseItemDetailsEntity>();

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessUserCenterReadDb(userInfo, parameter, (dbHelper) =>
            {
                var itemDetailsManager = new BaseItemDetailsManager(dbHelper, userInfo, tableName);
                entityList             = itemDetailsManager.GetList <BaseItemDetailsEntity>(
                    new KeyValuePair <string, object>(BaseItemDetailsEntity.FieldDeletionStateCode, 0)
                    , BaseItemDetailsEntity.FieldSortCode);
                // 管理时需要把所有的数据显示出来,所以无效的数据也需要显示的
                // , new KeyValuePair<string, object>(BaseItemDetailsEntity.FieldEnabled, 1)
            });
            return(entityList);
        }
Пример #5
0
        public List <BaseItemDetailsEntity> GetListByTargetTable(IDbHelper dbHelper, BaseUserInfo userInfo, string tableName)
        {
            List <BaseItemDetailsEntity> result = null;
            // 检查有其他目标数据库表存储了数据
            var             itemsManager = new BaseItemsManager(dbHelper, userInfo);
            BaseItemsEntity itemsEntity  = BaseEntity.Create <BaseItemsEntity>(itemsManager.GetDataTable(new KeyValuePair <string, object>(BaseItemsEntity.FieldTargetTable, tableName)));

            if (!String.IsNullOrEmpty(itemsEntity.TargetTable))
            {
                BaseItemDetailsManager itemDetailsManager = new BaseItemDetailsManager(dbHelper, userInfo, itemsEntity.TargetTable);
                // 这里只要有效的,没被删除的
                List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >();
                // 管理的时候无效的也需要被管理
                parameters.Add(new KeyValuePair <string, object>(BaseItemDetailsEntity.FieldEnabled, 1));
                parameters.Add(new KeyValuePair <string, object>(BaseItemDetailsEntity.FieldDeletionStateCode, 0));
                result = itemDetailsManager.GetList <BaseItemDetailsEntity>(parameters, BaseItemDetailsEntity.FieldSortCode);
            }
            return(result);
        }