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

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

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

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

                    // 按数据权限来过滤数据
                    var permissionScopeManager = new BasePermissionScopeManager(dbHelper, userInfo);
                    var ids = permissionScopeManager.GetResourceScopeIds(userInfo.SystemCode, userInfo.Id, tableName, permissionCode);
                    result  = itemDetailsManager.GetList <BaseDictionaryItemEntity>(ids);
                }
            });
            return(result);
        }
Пример #2
0
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="tableName">目标表</param>
        /// <returns>列表</returns>
        public List <BaseDictionaryItemEntity> GetList(BaseUserInfo userInfo, string tableName)
        {
            var entityList = new List <BaseDictionaryItemEntity>();

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

            ServiceUtil.ProcessUserCenterReadDb(userInfo, parameter, (dbHelper) =>
            {
                var itemDetailsManager = new BaseDictionaryItemManager(dbHelper, userInfo, tableName);
                entityList             = itemDetailsManager.GetList <BaseDictionaryItemEntity>(
                    new KeyValuePair <string, object>(BaseDictionaryItemEntity.FieldDeleted, 0)
                    , BaseDictionaryItemEntity.FieldSortCode);
                // 管理时需要把所有的数据显示出来,所以无效的数据也需要显示的
                // , new KeyValuePair<string, object>(BaseDictionaryItemEntity.FieldEnabled, 1)
            });
            return(entityList);
        }
Пример #3
0
        /// <summary>
        /// GetListByCode
        /// </summary>
        /// <param name="dbHelper"></param>
        /// <param name="userInfo"></param>
        /// <param name="code"></param>
        /// <returns></returns>
        public List <BaseDictionaryItemEntity> GetListByCode(IDbHelper dbHelper, BaseUserInfo userInfo, string code)
        {
            List <BaseDictionaryItemEntity> result = null;
            // 检查有其他目标数据库表存储了数据
            var itemsManager = new BaseDictionaryManager(dbHelper, userInfo);
            var itemsEntity  = BaseEntity.Create <BaseDictionaryEntity>(itemsManager.GetDataTable(new KeyValuePair <string, object>(BaseDictionaryEntity.FieldCode, code)));

            if (itemsEntity != null)
            {
                var itemDetailsManager = new BaseDictionaryItemManager(dbHelper, userInfo);
                // 这里只要有效的,没被删除的
                var parameters = new List <KeyValuePair <string, object> >
                {
                    // 管理的时候无效的也需要被管理
                    new KeyValuePair <string, object>(BaseDictionaryItemEntity.FieldDictionaryId, itemsEntity.Id),
                    new KeyValuePair <string, object>(BaseDictionaryItemEntity.FieldEnabled, 1),
                    new KeyValuePair <string, object>(BaseDictionaryItemEntity.FieldDeleted, 0)
                };
                result = itemDetailsManager.GetList <BaseDictionaryItemEntity>(parameters, BaseDictionaryItemEntity.FieldSortCode);
            }
            return(result);
        }