/// <summary> /// Get number of unique taxa for species observations /// that matches the search criteria. /// </summary> /// <param name="searchCriteria">The search criteria for the species observations.</param> /// <returns>Taxa count.</returns> public static Int32 GetTaxaCountBySpeciesObservations(SpeciesObservationSearchCriteria searchCriteria) { WebSpeciesObservationSearchCriteria webSearchCriteria; // Check arguments. searchCriteria.CheckNotNull("searchCriteria"); // Get data from web service. webSearchCriteria = GetSpeciesObservationSearchCriteria(searchCriteria); return(WebServiceClient.GetTaxaCountBySpeciesObservations(webSearchCriteria)); }
/// <summary> /// Get all taxa for the species observations /// that matches the search criteria. /// </summary> /// <param name="searchCriteria">The search criteria for the species observations.</param> /// <returns>Taxa information.</returns> public static TaxonList GetTaxaBySpeciesObservations(SpeciesObservationSearchCriteria searchCriteria) { WebSpeciesObservationSearchCriteria webSearchCriteria; List <WebTaxon> webTaxa; // Check arguments. searchCriteria.CheckNotNull("searchCriteria"); // Get data from web service. webSearchCriteria = GetSpeciesObservationSearchCriteria(searchCriteria); webTaxa = WebServiceClient.GetTaxaBySpeciesObservations(webSearchCriteria); return(TaxonManager.GetTaxa(webTaxa)); }
/// <summary> /// Convert a SpeciesObservationSearchCriteria to a /// WebSpeciesObservationSearchCriteria. /// </summary> /// <param name="searchCriteria">The SpeciesObservationSearchCriteria.</param> /// <returns>The WebSpeciesObservationSearchCriteria.</returns> private static WebSpeciesObservationSearchCriteria GetSpeciesObservationSearchCriteria(SpeciesObservationSearchCriteria searchCriteria) { WebDataField dataField; WebSpeciesObservationSearchCriteria webSearchCriteria; webSearchCriteria = new WebSpeciesObservationSearchCriteria(); webSearchCriteria.IsAccuracySpecified = searchCriteria.HasAccuracy; #if DATA_SPECIFIED_EXISTS webSearchCriteria.IsAccuracySpecifiedSpecified = true; #endif if (webSearchCriteria.IsAccuracySpecified) { webSearchCriteria.Accuracy = searchCriteria.Accuracy; #if DATA_SPECIFIED_EXISTS webSearchCriteria.AccuracySpecified = true; #endif } webSearchCriteria.IsBirdNestActivityLevelSpecified = searchCriteria.HasBirdNestActivityLevel; #if DATA_SPECIFIED_EXISTS webSearchCriteria.IsBirdNestActivityLevelSpecifiedSpecified = true; #endif if (webSearchCriteria.IsBirdNestActivityLevelSpecified) { webSearchCriteria.BirdNestActivityLevel = searchCriteria.BirdNestActivityLevel; #if DATA_SPECIFIED_EXISTS webSearchCriteria.BirdNestActivityLevelSpecified = true; #endif } webSearchCriteria.Counties = GeographicManager.GetCounties(searchCriteria.Counties); webSearchCriteria.DatabaseIds = null; if (searchCriteria.DatabaseIds.IsNotEmpty()) { webSearchCriteria.DatabaseIds = searchCriteria.DatabaseIds; } webSearchCriteria.IncludeNeverFoundObservations = searchCriteria.IncludeNeverFoundObservations; #if DATA_SPECIFIED_EXISTS webSearchCriteria.IncludeNeverFoundObservationsSpecified = true; #endif webSearchCriteria.IncludeNotRediscoveredObservations = searchCriteria.IncludeNotRediscoveredObservations; #if DATA_SPECIFIED_EXISTS webSearchCriteria.IncludeNotRediscoveredObservationsSpecified = true; #endif webSearchCriteria.IncludePositiveObservations = searchCriteria.IncludePositiveObservations; #if DATA_SPECIFIED_EXISTS webSearchCriteria.IncludePositiveObservationsSpecified = true; #endif if (webSearchCriteria.DataFields.IsNull()) { webSearchCriteria.DataFields = new List <WebDataField>(); } dataField = new WebDataField(); dataField.Name = "IncludeUncertainTaxonDetermination"; dataField.Type = WebDataType.Boolean; dataField.Value = searchCriteria.IncludeUncertainTaxonDetermination.WebToString(); webSearchCriteria.DataFields.Add(dataField); webSearchCriteria.LocationSearchString = searchCriteria.LocalitySearchString; webSearchCriteria.IsRectangleSpecified = searchCriteria.HasBoundingBox; #if DATA_SPECIFIED_EXISTS webSearchCriteria.IsRectangleSpecifiedSpecified = true; #endif if (webSearchCriteria.IsRectangleSpecified) { webSearchCriteria.EastCoordinate = searchCriteria.MaxEastCoordinate; webSearchCriteria.NorthCoordinate = searchCriteria.MaxNorthCoordinate; webSearchCriteria.WestCoordinate = searchCriteria.MaxWestCoordinate; webSearchCriteria.SouthCoordinate = searchCriteria.MaxSouthCoordinate; #if DATA_SPECIFIED_EXISTS webSearchCriteria.EastCoordinateSpecified = true; #endif #if DATA_SPECIFIED_EXISTS webSearchCriteria.NorthCoordinateSpecified = true; #endif #if DATA_SPECIFIED_EXISTS webSearchCriteria.WestCoordinateSpecified = true; #endif #if DATA_SPECIFIED_EXISTS webSearchCriteria.SouthCoordinateSpecified = true; #endif } webSearchCriteria.ObservationEndDate = searchCriteria.ObservationEndDate; #if DATA_SPECIFIED_EXISTS webSearchCriteria.ObservationEndDateSpecified = true; #endif webSearchCriteria.ObservationStartDate = searchCriteria.ObservationStartDate; #if DATA_SPECIFIED_EXISTS webSearchCriteria.ObservationStartDateSpecified = true; #endif webSearchCriteria.ObserverSearchString = searchCriteria.ObserverSearchString; webSearchCriteria.UseOfObservationDate = searchCriteria.UseOfObservationDate; #if DATA_SPECIFIED_EXISTS webSearchCriteria.UseOfObservationDateSpecified = true; #endif webSearchCriteria.RegistrationEndDate = searchCriteria.RegistrationEndDate; #if DATA_SPECIFIED_EXISTS webSearchCriteria.RegistrationEndDateSpecified = true; #endif webSearchCriteria.RegistrationStartDate = searchCriteria.RegistrationStartDate; #if DATA_SPECIFIED_EXISTS webSearchCriteria.RegistrationStartDateSpecified = true; #endif webSearchCriteria.UseOfRegistrationDate = searchCriteria.UseOfRegistrationDate; #if DATA_SPECIFIED_EXISTS webSearchCriteria.UseOfRegistrationDateSpecified = true; #endif webSearchCriteria.Provinces = GeographicManager.GetProvinces(searchCriteria.Provinces); webSearchCriteria.TaxonIds = null; if (searchCriteria.TaxonIds.IsNotEmpty()) { webSearchCriteria.TaxonIds = searchCriteria.TaxonIds; } webSearchCriteria.UserRoleId = searchCriteria.UserRoleId; #if DATA_SPECIFIED_EXISTS webSearchCriteria.UserRoleIdSpecified = true; #endif return(webSearchCriteria); }
/// <summary> /// Get SpeciesObservations that fulfill the search criteria. /// </summary> /// <param name="searchCriteria">The search criteria for the species observations.</param> /// <returns>Information about species observations that fulfill the search criteria.</returns> public static SpeciesObservationInformation GetSpeciesObservations(SpeciesObservationSearchCriteria searchCriteria) { Int32 index, speciesObservationIdsIndex; List <Int64> speciesObservationIds; SpeciesObservationInformation information; WebSpeciesObservationInformation tempWebInformation, webInformation; WebSpeciesObservationSearchCriteria speciesObservationSearchCriteria; // Check arguments. searchCriteria.CheckNotNull("searchCriteria"); // Get data from web service. speciesObservationSearchCriteria = GetSpeciesObservationSearchCriteria(searchCriteria); webInformation = WebServiceClient.GetSpeciesObservations(speciesObservationSearchCriteria); information = new SpeciesObservationInformation(); if (webInformation.SpeciesObservations.IsEmpty() && webInformation.SpeciesObservationIds.IsNotEmpty()) { // Get species observations in parts. speciesObservationIds = new List <Int64>(); index = 0; for (speciesObservationIdsIndex = 0; speciesObservationIdsIndex < webInformation.SpeciesObservationIds.Count; speciesObservationIdsIndex++) { speciesObservationIds.Add(webInformation.SpeciesObservationIds[speciesObservationIdsIndex]); if (++index == webInformation.MaxSpeciesObservationCount) { // Get one part of species observations. tempWebInformation = WebServiceClient.GetSpeciesObservationsById(speciesObservationIds, speciesObservationSearchCriteria.UserRoleId); foreach (WebSpeciesObservation webSpeciesObservation in tempWebInformation.SpeciesObservations) { information.SpeciesObservations.Add(GetSpeciesObservation(webSpeciesObservation)); } if ((webInformation.SpeciesObservationIds.Count - 1 - speciesObservationIdsIndex) < webInformation.MaxSpeciesObservationCount) { speciesObservationIds = new List <Int64>(); } index = 0; speciesObservationIds.Clear(); } } if (speciesObservationIds.IsNotEmpty()) { tempWebInformation = WebServiceClient.GetSpeciesObservationsById(speciesObservationIds, speciesObservationSearchCriteria.UserRoleId); foreach (WebSpeciesObservation webSpeciesObservation in tempWebInformation.SpeciesObservations) { information.SpeciesObservations.Add(GetSpeciesObservation(webSpeciesObservation)); } } } else if (webInformation.SpeciesObservations.IsNotEmpty()) { foreach (WebSpeciesObservation webSpeciesObservation in webInformation.SpeciesObservations) { information.SpeciesObservations.Add(GetSpeciesObservation(webSpeciesObservation)); } } return(information); }