public override IList <Person> GetAllPersonsInRegion(Region region, bool recursive) { IList <Person> persons = new List <Person>(); using (var transaction = new TransactionScope(_configuration)) { // Find all the sites for this region, and sub regions. IList <Site> sites = SiteManager.GetAllSitesByRegion(region, recursive); foreach (Site site in sites) { var ds = new PersonSiteDataStore(transaction); IList <PersonSite> personSites = ds.FindPersonsBySite(site.Id, false); IList <string> sysAdmins = GetAdminIds(); foreach (PersonSite personSite in personSites) { // Only consider if this person is assigned to this site. if (personSite.IsAssigned) { if (persons.FirstOrDefault(x => x.Id.Equals(personSite.Person.Id)) == null) { if (!sysAdmins.Contains(personSite.Person.Id)) { persons.Add(personSite.Person); } } } } } } return(persons); }
public override IList <Person> GetPersonsByRegionName(string regionName, bool recursive) { IList <Region> regions = SiteManager.GetAllRegionsByName(regionName); using (var transaction = new TransactionScope(_configuration)) { IList <Person> persons = new List <Person>(); foreach (Region region in regions) { IList <Site> sites = SiteManager.GetAllSitesByRegion(region, recursive); // Find all persons at these sites. var psDS = new PersonSiteDataStore(transaction); foreach (Site site in sites) { IList <PersonSite> personAtSites = psDS.FindPersonsBySite(site.Id, false); if (persons == null) { IEnumerable <Person> ppl = from x in personAtSites select x.Person; persons = ppl.ToList <Person>(); } else { foreach (PersonSite personSite in personAtSites) { persons.Add(personSite.Person); } } } if (recursive) { // Find all child regions. var rDS = new RegionDataStore(transaction); IList <Region> childRegions = rDS.FindByParentRegion(region.Id); foreach (Region subRegion in childRegions) { IList <Person> subPersons = GetPersonsByRegionName(subRegion.Name, recursive); foreach (Person subPerson in subPersons) { persons.Add(subPerson); } } } } return(persons); } }
public override IList <Person> GetAllPersonsInSite(Site site) { IList <Person> persons = new List <Person>(); using (var transaction = new TransactionScope(_configuration)) { // Find all the sites for this region, and sub regions. var ds = new PersonSiteDataStore(transaction); IList <PersonSite> personSites = ds.FindPersonsBySite(site.Id, false); IList <string> sysAdmins = GetAdminIds(); foreach (PersonSite personSite in personSites) { if (persons.FirstOrDefault(x => x.Id.Equals(personSite.Person.Id)) == null) { if (!sysAdmins.Contains(personSite.Person.Id)) { persons.Add(personSite.Person); } } } } return(persons); }
public override IList <Person> GetPersonsByRegionType(RegionType regionType) { IList <Region> regions = SiteManager.GetAllRegionsByRegionType(regionType); using (var transaction = new TransactionScope(_configuration)) { IList <Person> persons = new List <Person>(); foreach (Region region in regions) { IList <Site> sites = SiteManager.GetAllSitesByRegion(region, false); // Find all persons at these sites. var psDS = new PersonSiteDataStore(transaction); foreach (Site site in sites) { IList <PersonSite> personAtSites = psDS.FindPersonsBySite(site.Id, false); if (persons == null) { IEnumerable <Person> ppl = from x in personAtSites select x.Person; persons = ppl.ToList <Person>(); } else { foreach (PersonSite personSite in personAtSites) { persons.Add(personSite.Person); } } } } return(persons); } }