/// <summary>
        /// Get all county information objects.
        /// </summary>
        /// <returns>All county information objects.</returns>
        public static CountyList GetCounties()
        {
            CountyList counties = null;

            for (Int32 getAttempts = 0; (counties.IsNull()) && (getAttempts < 3); getAttempts++)
            {
                LoadCounties();
                counties = Counties;
            }
            return(counties);
        }
        /// <summary>
        /// Get counties from web service.
        /// </summary>
        private static void LoadCounties()
        {
            CountyList counties;

            if (Counties.IsNull())
            {
                // Get data from web service.
                counties = new CountyList();
                foreach (WebCounty webCounty in WebServiceClient.GetCounties())
                {
                    counties.Add(new County(webCounty.Id,
                                            webCounty.Name,
                                            webCounty.Identifier,
                                            webCounty.IsNumberSpecified,
                                            webCounty.Number,
                                            webCounty.IsCountyPart,
                                            webCounty.PartOfCountyId));
                }
                Counties = counties;
            }
        }
        /// <summary>
        /// Convert a CountyList to a WebCounty array.
        /// </summary>
        /// <param name="counties">The CountyList.</param>
        /// <returns>The WebCounty array.</returns>
        internal static List <WebCounty> GetCounties(CountyList counties)
        {
            County           county;
            Int32            countyIndex;
            WebCounty        webCounty;
            List <WebCounty> webCounties;

            webCounties = null;
            if (counties.IsNotEmpty())
            {
                webCounties = new List <WebCounty>();
                for (countyIndex = 0; countyIndex < counties.Count; countyIndex++)
                {
                    county       = counties[countyIndex];
                    webCounty    = new WebCounty();
                    webCounty.Id = county.Id;
#if DATA_SPECIFIED_EXISTS
                    webCounty.IdSpecified = true;
#endif
                    webCounty.Name              = county.Name;
                    webCounty.Identifier        = county.Identifier;
                    webCounty.IsNumberSpecified = county.HasNumber;
#if DATA_SPECIFIED_EXISTS
                    webCounty.IsNumberSpecifiedSpecified = true;
#endif
                    webCounty.Number       = county.Number;
                    webCounty.IsCountyPart = county.IsCountyPart;
#if DATA_SPECIFIED_EXISTS
                    webCounty.IsCountyPartSpecified = true;
#endif
                    webCounty.PartOfCountyId = county.PartOfCountyId;
#if DATA_SPECIFIED_EXISTS
                    webCounty.PartOfCountyIdSpecified = true;
#endif
                    webCounties.Add(webCounty);
                }
            }
            return(webCounties);
        }
Esempio n. 4
0
        /// <summary>
        /// Create a SpeciesObservationSearchCriteria instance.
        /// </summary>
        public SpeciesObservationSearchCriteria()
        {
            Accuracy = Int32.MinValue;
            BirdNestActivityLevel = Int32.MinValue;
            Counties    = new CountyList();
            DatabaseIds = new List <Int32>();
            HasAccuracy = false;
            HasBirdNestActivityLevel           = false;
            HasBoundingBox                     = false;
            IncludeNeverFoundObservations      = false;
            IncludeNotRediscoveredObservations = false;
            IncludePositiveObservations        = true;
            IncludeUncertainTaxonDetermination = true;
            LocalitySearchString               = null;
            MaxEastCoordinate                  = Int32.MinValue;
            MaxWestCoordinate                  = Int32.MinValue;
            MaxNorthCoordinate                 = Int32.MinValue;
            MaxSouthCoordinate                 = Int32.MinValue;
            Provinces = new ProvinceList();
            TaxonIds  = new List <Int32>();

            if (UserManager.IsUserLoggedIn())
            {
                UserRoleId = UserManager.GetUser().Roles[0].Id;
            }
            else
            {
                UserRoleId = Int32.MinValue;
            }

            ObservationEndDate    = DateTime.MinValue;
            ObservationStartDate  = DateTime.MinValue;
            ObserverSearchString  = null;
            UseOfObservationDate  = WebUseOfDate.NotSet;
            RegistrationEndDate   = DateTime.MinValue;
            RegistrationStartDate = DateTime.MinValue;
            UseOfRegistrationDate = WebUseOfDate.NotSet;
        }