/// <summary> /// Get taxa that belongs to authority. /// All child taxa are also included. /// </summary> /// <param name="context">Web service request context.</param> /// <param name="authority">Check access right in this authority.</param> /// <returns>Taxa that belongs to authority.</returns> public virtual Dictionary <Int32, WebTaxon> GetTaxaByAuthority(WebServiceContext context, WebAuthority authority) { Dictionary <Int32, WebTaxon> taxonDictionary; List <WebTaxon> taxa; String taxaInAuthorityCacheKey; // Get cached information. taxaInAuthorityCacheKey = Settings.Default.TaxaInAuthorityCacheKey + Settings.Default.CacheKeyDelimiter + authority.Id; taxonDictionary = (Dictionary <Int32, WebTaxon>)(context.GetCachedObject(taxaInAuthorityCacheKey)); if (taxonDictionary.IsNull()) { // Get taxa from taxon service. if (authority.TaxonGUIDs.IsEmpty()) { taxonDictionary = new Dictionary <Int32, WebTaxon>(); } else { taxa = GetChildTaxaByGuids(context, authority.TaxonGUIDs); taxonDictionary = GetDictionary(taxa); } // Add information to cache. context.AddCachedObject(taxaInAuthorityCacheKey, taxonDictionary, DateTime.Now + new TimeSpan(0, 1, 0, 0), CacheItemPriority.BelowNormal); } return(taxonDictionary); }
/// <summary> /// Test if access rights to species observations are /// easy or complex to handle. /// </summary> /// <param name="authority">Authority to test.</param> /// <returns>True, if access rights to species observations are easy to handle.</returns> private static Boolean IsSimpleSpeciesObservationAccessRights(WebAuthority authority) { if (authority.Identifier != AuthorityIdentifier.Sighting.ToString()) { // Authority is not related to species observations. return(true); } if (authority.RegionGUIDs.IsNotEmpty() || authority.TaxonGUIDs.IsNotEmpty()) { // Complex species observation access rights found. return(false); } // No complex species observation access rights found. return(true); }