コード例 #1
0
ファイル: Authorization.cs プロジェクト: SwarmCorp/Swarmops
        private static bool IsSystemAdministrator (BasicAuthority authority)
        {
            foreach (BasicPersonRole role in authority.SystemPersonRoles)
            {
                if (role.Type == RoleType.SystemAdmin)
                {
                    return true;
                }
            }

            return false;
        }
コード例 #2
0
ファイル: Authorization.cs プロジェクト: SwarmCorp/Swarmops
        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
ファイル: Authority.cs プロジェクト: SwarmCorp/Swarmops
 public static Authority FromBasic (BasicAuthority basic)
 {
     return new Authority(basic);
 }
コード例 #4
0
ファイル: Authorization.cs プロジェクト: SwarmCorp/Swarmops
 public static BasicGeography[] GetNodesInAuthorityForOrganization (BasicAuthority authority, int organizationId)
 {
     return GetNodesInAuthorityForOrganization(authority, organizationId, RoleTypes.AllRoleTypes);
 }
コード例 #5
0
ファイル: Authority.cs プロジェクト: SwarmCorp/Swarmops
 private Authority (BasicAuthority basic)
     : base(basic.PersonId, basic.SystemPersonRoles, basic.OrganizationPersonRoles, basic.LocalPersonRoles)
 {
 }