Exemplo n.º 1
0
        /// <summary>
        /// 获取当前用户拥有的所有权限
        /// </summary>
        public static PermissionCollection GetAllPermissions(this User user, bool Obsolete)
        {
            PermissionCollection ps = new PermissionCollection();

            foreach (Role r in user.Roles())
            {
                if (r.Flag)
                {
                    foreach (Permission p in r.Permissions)
                    {
                        if (!ps.ContainsPermission(p))
                        {
                            ps.Add(p);
                        }
                    }
                }
            }
            foreach (Department dep in user.Departments)
            {
                //Department dep = DepartmentLogic.GetInstance().GetDepartment(d);
                foreach (Role r in dep.Roles())
                {
                    if (r.Flag)
                    {
                        foreach (Permission p in r.Permissions)
                        {
                            if (!ps.ContainsPermission(p))
                            {
                                ps.Add(p);
                            }
                        }
                    }
                }
            }
            foreach (UserGroup ugg in user.Usergroups)
            {
                //UserGroup ugg = UserGroupLogic.GetInstance().GetUserGroup(ug);
                foreach (Role r in ugg.Roles())
                {
                    if (r.Flag)
                    {
                        foreach (Permission p in r.Permissions())
                        {
                            if (!ps.ContainsPermission(p))
                            {
                                ps.Add(p);
                            }
                        }
                    }
                }
            }
            return(ps);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取当前用户拥有的所有权限
        /// </summary>
        public static PermissionCollection GetAllPermissionsByUser(this User user)
        {
            PermissionCollection ps = new PermissionCollection();

            foreach (Role role in user.Roles)
            {
                //Role role = RoleLogic.GetInstance().GetRole(r);
                if (role.Flag)
                {
                    //PermissionLogic pl = PermissionLogic.GetInstance();
                    foreach (Permission per in role.Permissions)
                    {
                        //Permission per = pl.GetPermission(p);
                        if (!ps.ContainsPermission(per))
                        {
                            ps.Add(per);
                        }
                    }
                }
            }
            foreach (Department dep in user.Departments)
            {
                //Department dep = DepartmentLogic.GetInstance().GetDepartment(d);
                foreach (Role role in dep.Roles)
                {
                    //Role role = RoleLogic.GetInstance().GetRole(r);
                    if (role.Flag)
                    {
                        //PermissionLogic pl = PermissionLogic.GetInstance();
                        foreach (Permission per in role.Permissions)
                        {
                            //Permission per = pl.GetPermission(p);
                            if (!ps.ContainsPermission(per))
                            {
                                ps.Add(per);
                            }
                        }
                    }
                }
            }
            foreach (UserGroup ugg in user.Usergroups)
            {
                //UserGroup ugg = UserGroupLogic.GetInstance().GetUserGroup(ug);
                foreach (Role role in ugg.Roles)
                {
                    //Role role = RoleLogic.GetInstance().GetRole(r);
                    if (role.Flag)
                    {
                        //PermissionLogic pl = PermissionLogic.GetInstance();
                        foreach (Permission per in role.Permissions)
                        {
                            //Permission per = pl.GetPermission(p);
                            if (!ps.ContainsPermission(per))
                            {
                                ps.Add(per);
                            }
                        }
                    }
                }
            }
            return(ps);
        }