示例#1
0
 public static void UpdateOrganization(int ParentOrganizationId, string NameInternational, string Name,
                                       string NameShort, string Domain, string MailPrefix, int AnchorGeographyId, bool AcceptsMembers,
                                       bool AutoAssignNewMembers, int DefaultCountryId, int OrganizationId)
 {
     OrganizationCache.UpdateOrganization(ParentOrganizationId, NameInternational, Name, NameShort, Domain,
                                          MailPrefix, AnchorGeographyId, AcceptsMembers, AutoAssignNewMembers, DefaultCountryId,
                                          OrganizationId);
 }
示例#2
0
        public static Organizations GetAllOrganizationsAvailableAtGeography(int geographyId)
        {
            List <BasicGeography> nodeList = new List <BasicGeography>();

            nodeList.AddRange(GeographyCache.GetGeographyLine(geographyId));
            nodeList.AddRange(GeographyCache.GetGeographyTree(geographyId));

            return(FromIdentities(OrganizationCache.GetOrganizationsIdsInGeographies(nodeList.ToArray())));
        }
示例#3
0
 private void AddChildren(RadTreeNodeCollection coll, int parentIdentity)
 {
     BasicOrganization[] orgs = OrganizationCache.GetOrganizationChildren(parentIdentity);
     foreach (BasicOrganization org in orgs)
     {
         RadTreeNode node = new RadTreeNode(org.Name, org.Identity.ToString());
         SetAuthorityForNode(node);
         node.ExpandMode = TreeNodeExpandMode.WebService;
         coll.Add(node);
     }
 }
示例#4
0
 public static Organization Create(int parentOrganizationId, string nameInternational, string name, string nameShort, string domain, string mailPrefix, int anchorGeographyId, bool acceptsMembers, bool autoAssignNewMembers, int defaultCountryId)
 {
     return(FromIdentityAggressive(OrganizationCache.CreateOrganization(parentOrganizationId,
                                                                        nameInternational,
                                                                        name,
                                                                        nameShort,
                                                                        domain,
                                                                        mailPrefix,
                                                                        anchorGeographyId,
                                                                        acceptsMembers,
                                                                        autoAssignNewMembers,
                                                                        defaultCountryId)));
 }
示例#5
0
        public UptakeGeography[] GetUptakeGeographies(bool others)
        {
            BasicUptakeGeography[] basics = SwarmDb.GetDatabaseForReading().GetOrganizationUptakeGeographies(Identity, others);
            List <UptakeGeography> retVal = new List <UptakeGeography>();

            foreach (BasicUptakeGeography b in basics)
            {
                try
                {
                    UptakeGeography ug = UptakeGeography.FromBasic(b);
                    if (ug.Organization != null && ug.Geography != null && ug.Organization.ParentIdentity != -1)
                    {
                        retVal.Add(UptakeGeography.FromBasic(b));
                    }
                }
                catch
                {
                    //catch bad references
                }
            }

            if (others)
            {
                Dictionary <int, BasicOrganization> allOrgs = OrganizationCache.GetOrganizationHashtable(Organization.RootIdentity);
                foreach (BasicOrganization bo in allOrgs.Values)
                {
                    if (bo.Identity > 0)
                    {
                        BasicUptakeGeography myAnchor = new BasicUptakeGeography(bo.Identity, bo.AnchorGeographyId);
                        retVal.Add(UptakeGeography.FromBasic(myAnchor));
                    }
                }
            }
            else
            {
                BasicUptakeGeography myAnchor = new BasicUptakeGeography(Identity, AnchorGeographyId);
                if (retVal.Find(delegate(UptakeGeography ug) { return(ug.GeoId == AnchorGeographyId); }) == null)
                {
                    retVal.Add(UptakeGeography.FromBasic(myAnchor));
                }
            }

            return(retVal.ToArray());
        }
示例#6
0
 public void DeleteUptakeGeography(int geoId)
 {
     OrganizationCache.DeleteOrgUptakeGeography(this.Identity, geoId);
 }
示例#7
0
 public void AddUptakeGeography(int geoId)
 {
     OrganizationCache.AddOrgUptakeGeography(this.Identity, geoId);
 }
示例#8
0
 public static Organization FromIdentity(int identity)
 {
     return(FromBasic(OrganizationCache.GetOrganization(identity)));
     //return FromBasic(SwarmDb.GetDatabaseForReading().GetOrganization(identity));
 }
示例#9
0
 public Organizations GetTree()
 {
     return(Organizations.FromArray(OrganizationCache.GetOrganizationTree(Identity)));
     //return Organizations.FromArray(SwarmDb.GetDatabaseForReading().GetOrganizationTree(Identity));
 }
示例#10
0
 public static Organizations GetOrganizationsAvailableAtGeography(int geographyId)
 {
     BasicGeography[] nodeLine = GeographyCache.GetGeographyLine(geographyId);
     return(FromIdentities(OrganizationCache.GetOrganizationsIdsInGeographies(nodeLine)));
 }
示例#11
0
 public static Organizations GetAll()
 {
     return(FromArray(OrganizationCache.GetAll()));
 }
示例#12
0
        public static People FilterPeopleToMatchAuthority(People people, Authority authority, int gracePeriod)
        {
            // First: If sysadmin, return the whole list uncensored.

            if (IsSystemAdministrator(authority))
            {
                return(people);
            }

            SwarmDb databaseRead = SwarmDb.GetDatabaseForReading();

            if (gracePeriod == -1)
            {
                gracePeriod = Membership.GracePeriod;
            }

            Dictionary <int, List <BasicMembership> > membershipTable =
                databaseRead.GetMembershipsForPeople(people.Identities, gracePeriod);
            Dictionary <int, int> geographyTable = databaseRead.GetPeopleGeographies(people.Identities);

            Dictionary <int, Person> clearedPeople = new Dictionary <int, Person>();

            // TODO: Add org admin role, able to see previous members that aren't anonymized yet

            // Clear by organization roles

            foreach (BasicPersonRole role in authority.OrganizationPersonRoles)
            {
                Dictionary <int, BasicOrganization> clearedOrganizations =
                    OrganizationCache.GetOrganizationHashtable(role.OrganizationId);

                foreach (Person person in people)
                {
                    // Is the organization cleared in this officer's role for this to-be-viewed member?

                    if (membershipTable.ContainsKey(person.Identity))
                    {
                        foreach (BasicMembership membership in membershipTable[person.Identity])
                        {
                            if (clearedOrganizations.ContainsKey(membership.OrganizationId)
                                &&
                                authority.HasPermission(Permission.CanSeePeople, membership.OrganizationId,
                                                        person.GeographyId, Flag.Default))
                            {
                                if (membership.Active ||
                                    (membership.Expires > DateTime.Now.AddDays(-gracePeriod) &&
                                     membership.Expires.AddDays(1) > membership.DateTerminated
                                     &&
                                     authority.HasPermission(Permission.CanSeeExpiredDuringGracePeriod,
                                                             membership.OrganizationId, person.GeographyId, Flag.Default)))
                                {
                                    clearedPeople[person.Identity] = person;
                                    break;
                                }
                            }
                        }
                    }

                    /* -- commented out. This means "does the current authority have Org Admin privileges over Person"?
                     * else if (CanSeeNonMembers)
                     * { //person isn't member anywhere
                     *  clearedPeople[person.Identity] = person;
                     * }*/
                }
            }


            // Clear by node roles:
            //
            // For each node role, check if each member is in a cleared geography AND a cleared organization.
            // If so, permit view of this member. (A person in a branch of a geographical area for organizations X and Z
            // should see only people of those organizations only on those nodes.)


            foreach (BasicPersonRole role in authority.LocalPersonRoles)
            {
                Dictionary <int, BasicGeography> clearedGeographies =
                    GeographyCache.GetGeographyHashtable(role.GeographyId);
                Dictionary <int, BasicOrganization> clearedOrganizations =
                    OrganizationCache.GetOrganizationHashtable(role.OrganizationId);

                foreach (Person person in people)
                {
                    // Is the node AND the organization cleared in this officer's role for this to-be-viewed member?

                    if (membershipTable.ContainsKey(person.Identity))
                    {
                        foreach (BasicMembership membership in membershipTable[person.Identity])
                        {
                            int organizationClear = 0;
                            int geographyClear    = 0;
                            if (clearedOrganizations.ContainsKey(membership.OrganizationId))
                            {
                                organizationClear = membership.OrganizationId;

                                if (clearedGeographies.ContainsKey(geographyTable[person.Identity]))
                                {
                                    geographyClear = geographyTable[person.Identity];
                                }

                                if (organizationClear > 0 &&
                                    geographyClear > 0
                                    &&
                                    authority.HasPermission(Permission.CanSeePeople, organizationClear, geographyClear,
                                                            Flag.Default))
                                {
                                    if (membership.Active ||
                                        (membership.Expires > DateTime.Now.AddDays(-gracePeriod) &&
                                         membership.Expires.AddDays(1) > membership.DateTerminated
                                         &&
                                         authority.HasPermission(Permission.CanSeeExpiredDuringGracePeriod,
                                                                 membership.OrganizationId, person.GeographyId, Flag.Default)))
                                    {
                                        clearedPeople[person.Identity] = person;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }


            // End: Assemble an array of the resulting cleared people

            People result = new People();

            foreach (Person clearedPerson in clearedPeople.Values)
            {
                result.Add(clearedPerson);
            }

            return(result);
        }
示例#13
0
        public static Memberships FilterMembershipsToMatchAuthority(Memberships memberships, Geography personGeography,
                                                                    Authority authority)
        {
            // First: If sysadmin, return the whole list uncensored.

            if (IsSystemAdministrator(authority))
            {
                return(memberships);
            }

            Dictionary <int, Membership> clearedMemberships = new Dictionary <int, Membership>();

            //
            foreach (BasicPersonRole role in authority.OrganizationPersonRoles)
            {
                Dictionary <int, BasicOrganization> clearedOrganizations =
                    OrganizationCache.GetOrganizationHashtable(role.OrganizationId);

                foreach (Membership membership in memberships)
                {
                    bool organizationClear = clearedOrganizations.ContainsKey(membership.OrganizationId);

                    if (organizationClear
                        &&
                        authority.HasPermission(Permission.CanViewMemberships, membership.OrganizationId,
                                                membership.Person.GeographyId, Flag.Default))
                    {
                        clearedMemberships[membership.Identity] = membership;
                    }
                }
            }


            foreach (BasicPersonRole role in authority.LocalPersonRoles)
            {
                Dictionary <int, BasicGeography> clearedGeographies =
                    GeographyCache.GetGeographyHashtable(role.GeographyId);
                Dictionary <int, BasicOrganization> clearedOrganizations =
                    OrganizationCache.GetOrganizationHashtable(role.OrganizationId);

                bool geographyClear = clearedGeographies.ContainsKey(personGeography.Identity);
                geographyClear = geographyClear &&
                                 authority.HasPermission(Permission.CanViewMemberships, role.OrganizationId,
                                                         personGeography.Identity, Flag.Default);

                if (geographyClear)
                {
                    foreach (Membership membership in memberships)
                    {
                        bool organizationClear = clearedOrganizations.ContainsKey(membership.OrganizationId);

                        if (organizationClear)
                        {
                            clearedMemberships[membership.Identity] = membership;
                        }
                    }
                }
            }


            // Assemble the array

            Memberships result = new Memberships();

            foreach (Membership membership in clearedMemberships.Values)
            {
                result.Add(membership);
            }

            return(result);
        }
 public static void RefreshHybridUrl(DataRow inputRow, DataTable dataTable, DataObjectStore store)
 {
     OrganizationCache.ExpireEntry("EntHasTargetDeliveryDomain");
     OrganizationCache.ExpireEntry("EntTargetDeliveryDomain");
 }
 public static void ExpireServiceInstanceCache(DataRow inputRow, DataTable dataTable, DataObjectStore store)
 {
     OrganizationCache.ExpireEntry("ServiceInstance");
 }