예제 #1
0
        public List<SysRelationEntity> GetEnabledSysRelationList()
        {
            var listEnabledSysRelation = GetSysRelationList();

            //���ؿ��õIJ˵��б�
            var listEnabledSysMenuEntity = new SysMenuBiz().GetEnabledSysMenuList();

            //���ݿ��õIJ˵��б��ȥ��û�������õĹ��ܵ�
            for (int i = listEnabledSysRelation.Count - 1; i >= 0; i--)
            {
                var permisionEntity = listEnabledSysRelation[i];
                var list = listEnabledSysMenuEntity.Where(n => n.ModuleId == permisionEntity.ModuleId && n.FuncPointId == permisionEntity.FuncPointId).ToList();
                if (list.Count <= 0) listEnabledSysRelation.Remove(permisionEntity);
            }

            return listEnabledSysRelation;
        }
예제 #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="permissionType">1=��ɫȨ�ޣ�2=�û�Ȩ��</param>
        /// <param name="userRoleId"></param>
        public List<BcPermissionEntity> GetEnabledBcPermissionList(int? permissionType, int? userRoleId = 0)
        {
            //��ȡ���õ�Ȩ���б�
            var allBcPermissionList = EntityExecution.ReadEntityList2<BcPermissionEntity>(null);
            var enabledBcPermissionList = new List<BcPermissionEntity>();
            if (userRoleId == 0)
            {
                enabledBcPermissionList.AddRange(allBcPermissionList.Where(n =>
                    n.PermissionType == permissionType));
            }
            else
            {
                enabledBcPermissionList.AddRange(allBcPermissionList.Where(n =>
                    n.UserRoleId == userRoleId && n.PermissionType == permissionType));
            }

            //���ؿ��õIJ˵��б�
            var listEnabledSysMenuEntity = new SysMenuBiz().GetEnabledSysMenuList();

            //���ݿ��õIJ˵��б��ȥ��û�������õĹ��ܵ�
            for (int i = enabledBcPermissionList.Count - 1; i >= 0; i--)
            {
                var permisionEntity = enabledBcPermissionList[i];
                var list = listEnabledSysMenuEntity.Where(n => n.ModuleId == permisionEntity.ModuleId && n.FuncPointId == permisionEntity.FuncPointId).ToList();
                if (list.Count <= 0) enabledBcPermissionList.Remove(permisionEntity);
            }

            //��������id��name
            var allBcRoleList = new BcRoleBiz().GetBcRoleList();
            var allBcUserInfoList = new BcUserInfoBiz().GetBcUserInfoList();

            foreach (BcPermissionEntity bcPermissionEntity in enabledBcPermissionList)
            {
                bcPermissionEntity.ModuleName = SysEnumNameExtensionBiz.GetDescription<SysModuleEnum>(bcPermissionEntity.ModuleId);
                bcPermissionEntity.FuncPointName = SysEnumNameExtensionBiz.GetDescription<SysFuncPointEnum>(bcPermissionEntity.FuncPointId);
                if (permissionType == 1)
                {
                    var list = allBcRoleList.Where(n => n.RoleId == bcPermissionEntity.UserRoleId).ToList();
                    if (list.Count > 0) bcPermissionEntity.UserRoleName = list[0].RoleName;
                }
                else if (permissionType == 2)
                {
                    var list = allBcUserInfoList.Where(n => n.UserId == bcPermissionEntity.UserRoleId).ToList();
                    if (list.Count > 0) bcPermissionEntity.UserRoleName = list[0].UserName;
                }

                if (!string.IsNullOrEmpty(bcPermissionEntity.Permissions))
                {
                    bcPermissionEntity.PermissionList = new List<string>();
                    bcPermissionEntity.PermissionNameList = new List<string>();
                    var list = bcPermissionEntity.Permissions.Split(',').ToList();
                    foreach (string s in list)
                    {
                        if (!string.IsNullOrEmpty(s))
                        {
                            bcPermissionEntity.PermissionList.Add(s);
                            bcPermissionEntity.PermissionNameList.Add(SysEnumNameExtensionBiz.GetDescription<SysFuncPointEnum>(s));
                        }
                    }
                    if (bcPermissionEntity.PermissionNameList.Count > 0)
                        bcPermissionEntity.PermissionNames = string.Join(",", bcPermissionEntity.PermissionNameList.ToArray());
                }
            }
            return enabledBcPermissionList.OrderBy(n => n.ModuleId).ThenBy(n => n.FuncPointId).ToList();
        }