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

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

            // Build lookup tables

            var orgLookup = new Dictionary<int, BasicOrganization>();
            foreach (BasicOrganization organization in organizationLine)
            {
                orgLookup[organization.OrganizationId] = organization;
            }

            var roleLookup = new Dictionary<RoleType, bool>();
            foreach (RoleType roleType in roleTypes)
            {
                roleLookup[roleType] = true;
            }

            // Create list

            var 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();
        }
Пример #3
0
 public static Authority FromBasic (BasicAuthority basic)
 {
     return new Authority(basic);
 }
Пример #4
0
 public static BasicGeography[] GetNodesInAuthorityForOrganization (BasicAuthority authority, int organizationId)
 {
     return GetNodesInAuthorityForOrganization(authority, organizationId, RoleTypes.AllRoleTypes);
 }
Пример #5
0
 private Authority (BasicAuthority basic)
     : base(basic.PersonId, basic.SystemPersonRoles, basic.OrganizationPersonRoles, basic.LocalPersonRoles)
 {
 }