Beispiel #1
0
        private static bool IsSystemAdministrator(BasicAuthority authority)
        {
            foreach (BasicPersonRole role in authority.SystemPersonRoles)
            {
                if (role.Type == RoleType.SystemAdmin)
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #2
0
        public static BasicGeography[] GetNodesInAuthorityForOrganization(BasicAuthority authority, int organizationId,
                                                                          RoleType[] roleTypes)
        {
            Organizations organizationLine = Organization.FromIdentity(organizationId).GetLine();

            // Build lookup tables

            Dictionary <int, BasicOrganization> orgLookup = new Dictionary <int, BasicOrganization>();

            foreach (BasicOrganization organization in organizationLine)
            {
                orgLookup[organization.OrganizationId] = organization;
            }

            Dictionary <RoleType, bool> roleLookup = new Dictionary <RoleType, bool>();

            foreach (RoleType roleType in roleTypes)
            {
                roleLookup[roleType] = true;
            }

            // Create list

            List <BasicGeography> result = new List <BasicGeography>();

            if (authority.AllPersonRoles.Length > 0)
            {
                Dictionary <int, BasicGeography> geoDict = GeographyCache.GetGeographyHashtable(Geography.RootIdentity);

                foreach (BasicPersonRole role in authority.AllPersonRoles)
                {
                    if (orgLookup.ContainsKey(role.OrganizationId))
                    {
                        if (roleLookup.ContainsKey(role.Type))
                        {
                            result.Add(geoDict[role.GeographyId]);
                        }
                    }
                }
            }

            return(result.ToArray());
        }
Beispiel #3
0
        public static BasicPersonRole[] Select(int personId, RoleClass roleClass)
        {
            BasicAuthority authority = Authorization.GetPersonAuthority(personId);

            switch (roleClass)
            {
            case RoleClass.System:
                return(authority.SystemPersonRoles);

            case RoleClass.Organization:
                return(authority.OrganizationPersonRoles);

            case RoleClass.Local:
                return(authority.LocalPersonRoles);

            default:
                throw new InvalidOperationException("Undefined RoleClass in RolesDataObject.Select: " + roleClass);
            }
        }
Beispiel #4
0
 public static BasicGeography[] GetNodesInAuthorityForOrganization(BasicAuthority authority, int organizationId)
 {
     return(GetNodesInAuthorityForOrganization(authority, organizationId, RoleTypes.AllRoleTypes));
 }
Beispiel #5
0
 public static Authority FromBasic(BasicAuthority basic)
 {
     return(new Authority(basic));
 }
Beispiel #6
0
 private Authority(BasicAuthority basic)
     : base(basic.PersonId, basic.SystemPersonRoles, basic.OrganizationPersonRoles, basic.LocalPersonRoles)
 {
 }