コード例 #1
0
ファイル: RoleApi.cs プロジェクト: franknew/RiskMgr
        public QueryRoleResultForm QueryRole(RoleQueryForm form)
        {
            QueryRoleResultForm result = new QueryRoleResultForm();

            result.Roles = bll.Query(form);
            return(result);
        }
コード例 #2
0
ファイル: RoleBLL.cs プロジェクト: franknew/RiskMgr
        /// <summary>
        /// 查询角色
        /// </summary>
        /// <param name="form"></param>
        /// <returns></returns>
        public List <FullRoleInfo> Query(RoleQueryForm form)
        {
            ISqlMapper            mapper = Common.GetMapperFromSession();
            RoleDao               dao    = new RoleDao(mapper);
            Role_Module_ActionDao rmadao = new Role_Module_ActionDao(mapper);
            List <FullRoleInfo>   result = new List <FullRoleInfo>();

            form.IsDeleted = 0;
            var roles   = dao.Query(form);
            var roleids = (from r in roles select r.ID).ToList();
            var rmas    = rmadao.Query(new Role_Module_ActionQueryForm {
                RoleIDs = roleids
            });
            AuthorityMapping mapping = XMLHelper.DeserializeFromFile <AuthorityMapping>(Common.AuthorityMappingFile);

            foreach (var role in roles)
            {
                var data       = role.ConvertTo <FullRoleInfo>();
                var parentrole = roles.Find(t => t.ID == role.ParentID);
                if (parentrole != null)
                {
                    data.ParentRoleName = parentrole.Name;
                }
                #region 查询权限
                var role_rmas = rmas.FindAll(t => t.RoleID.Equals(role.ID));
                data.Authority = new List <AuthorityNodeForCheck>();
                foreach (var auth in mapping.AuthNode)
                {
                    auth.Checked = (from au in auth.Item
                                    from r in role_rmas
                                    where au.ModuleID == r.ModuleID && au.ActionID == r.ActionID
                                    select au).Count() == auth.Item.Count;
                    data.Authority.Add(new AuthorityNodeForCheck {
                        ID = auth.ID, Checked = auth.Checked, Name = auth.Name
                    });
                }
                #endregion
                result.Add(data);
            }
            return(result);
        }