/// <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>
        /// 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);
        }