/// <summary>
 /// 获取子集
 /// </summary>
 /// <param name="parent"></param>
 /// <param name="allList"></param>
 public void GetPermissionChildren(ref VIEW_FW_PERMISSION parent, List <FW_PERMISSION> allList)
 {
     foreach (FW_PERMISSION permission in allList)
     {
         if (permission.PERMISSION_PID == parent.PERMISSION_ID)
         {
             //实体转化
             VIEW_FW_PERMISSION child = VIEW_FW_PERMISSION.ToViewModel(permission);
             if (parent.children == null)
             {
                 parent.children = new List <VIEW_FW_PERMISSION>();
             }
             //添加到父级的Children中
             parent.children.Add(child);
             GetPermissionChildren(ref child, allList);//递归添加子树
         }
     }
 }
        /// <summary>
        /// 请求权限列表信息
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns></returns>
        //public EasyUIGrid GetPermissionForGrid(EasyUIGridRequest request)
        //{
        //    int count = 0;
        //    return new EasyUIGrid()
        //    {
        //        rows = ViewModelButton.ToListViewModel(GetPermission(request, ref count)),
        //        total = count//myDao.GetEntitiesCount(p => true)
        //    };
        //}
        /// <summary>
        /// 根据条件获取权限信息
        /// </summary>
        /// <param name="request">请求</param>
        /// <param name="Count">总个数</param>
        /// <returns></returns>
        public IEnumerable <VIEW_FW_PERMISSION> GetPermission()
        {
            int count = 0;

            var data = base.GetListBy(p => true, p => p.SEQ_NO);

            count = data.Count();
            //GetPermission(request, out count);
            List <VIEW_FW_PERMISSION> listPermission = new List <VIEW_FW_PERMISSION>();
            //查找所有的一级权限
            var ParentPermission = data.Where(con => con.PERMISSION_PID == "");

            foreach (var parent in ParentPermission)
            {
                //实体转化
                VIEW_FW_PERMISSION parentItem = VIEW_FW_PERMISSION.ToViewModel(parent);
                //获取子级
                GetPermissionChildren(ref parentItem, data.ToList());
                listPermission.Add(parentItem);
            }
            return(listPermission);
        }
示例#3
0
        /// <summary>
        /// 根据用户id查询用户权限
        /// </summary>
        /// <param name="usrId"></param>
        public List <string> GetUserPermissionId(string usrId)
        {
            //-------A.根据用户角色查询
            //1.0 根据用户 id 查到 该用户的 角色id
            List <string> listRoleId = Current.BLLSession.IFW_USER_ROLE_MANAGER.GetListBy(ur => ur.USER_ID == usrId).Select(ur => ur.ROLE_ID).ToList();
            //2.0 根据角色 id 查询角色权限 id
            List <string> listModulePerIds = Current.BLLSession.IFW_ROLEPERMISSION_MANAGER.GetListBy(rp => listRoleId.Contains(rp.RP_ID)).Select(rp => rp.MP_ID).ToList();

            List <string> listModuleIds = Current.BLLSession.IFW_MODULEPERMISSION_MANAGER.GetListBy(mp => listModulePerIds.Contains(mp.MP_ID)).Select(mp => mp.MODULE_ID).Distinct().ToList();

            UsrMenu = listModuleIds;
            List <string> listPerIds = Current.BLLSession.IFW_MODULEPERMISSION_MANAGER.GetListBy(mp => listModulePerIds.Contains(mp.MP_ID)).Select(rp => rp.PERMISSION_ID).ToList();
            //3.0 查询所有角色数据
            List <VIEW_FW_PERMISSION> listPermission = Current.BLLSession.IFW_PERMISSION_MANAGER.GetListBy(p => listPerIds.Contains(p.PERMISSION_ID)).Select(p => VIEW_FW_PERMISSION.ToViewModel(p)).ToList();

            //-------B.根据用户特权查询
            ////b.1 查询 用户特权id
            //List<int> vipPerIds = Current.BLLSession.IOu_UserVipPermissionBLL.GetListBy(vip => vip.vipUserId == usrId).Select(vip => vip.vipPermission).ToList();
            ////b.2 查询 特权数据
            //List<MODEL.Ou_Permission> listPermission2 = Current.BLLSession.IOu_PermissionBLL.GetListBy(p => vipPerIds.Contains(p.pid)).Select(p => p.ToPOCO()).ToList();
            //-------C.将两个权限集合 合并(将集合2的权限数据 添加到 集合1中)
            //listPermission2.ForEach(p =>
            //{
            //    listPermission.Add(p);
            //});
            return(listPermission.OrderBy(u => u.SEQ_NO).Select(p => p.PERMISSION_ID).ToList());



            ////PermissionManager = (ISample_PermissionManager)cxt.GetObject("Manager.Permission");
            ////UserInfoManager = (ISample_UserInfoManager)cxt.GetObject("Manager.UserInfo");
            //var Usr=UserInfoManager.Get(usrId);
            //var listRoleId = Usr.RoleList.Select(r => r.roleId).ToList();
            //string tableName="p";
            //string innerJoin = "left join fetch  p.ModulePermissionList mp left join fetch mp.RoleList r left join fetch r.UserList u";
            //string field = "p";
            //string orderName = "pOrder";
            //string where = "u.userId="+Usr.userId;
            //var permissionList = PermissionManager.GetDataByWhere(tableName, innerJoin, field, orderName, "", where).ToList();

            //return permissionList;
        }