public void GetCitiesByNameSearchString()
        {
            ICoordinateSystem     coordinateSystemRt90           = new CoordinateSystem(CoordinateSystemId.Rt90_25_gon_v);
            ICoordinateSystem     coordinateSystemGoogleMercator = new CoordinateSystem(CoordinateSystemId.GoogleMercator);
            IStringSearchCriteria criteria = new StringSearchCriteria()
            {
                SearchString = "Uppsala%"
            };

            // Get cities in RT90
            CityInformationList citiesRt90 =
                GetGeoReferenceManager(true).GetCitiesByNameSearchString(GetUserContext(),
                                                                         criteria,
                                                                         coordinateSystemRt90);

            Assert.IsTrue(citiesRt90.IsNotEmpty());


            // Get cities in Google Mercator
            CityInformationList citiesGoogleMercator =
                GetGeoReferenceManager(true).GetCitiesByNameSearchString(GetUserContext(),
                                                                         criteria,
                                                                         coordinateSystemGoogleMercator);

            Assert.IsTrue(citiesGoogleMercator.IsNotEmpty());
        }
Ejemplo n.º 2
0
        public TaxonNameSearchCriteria CreateTaxonNameSearchCriteriaObject()
        {
            var taxonNameSearchCriteria = new TaxonNameSearchCriteria();

            if (!string.IsNullOrEmpty(NameSearchString))
            {
                var nameSearchCriteria = new StringSearchCriteria();
                nameSearchCriteria.SearchString     = NameSearchString;
                nameSearchCriteria.CompareOperators = new List <StringCompareOperator>();
                if (NameCompareOperator.HasValue)
                {
                    nameSearchCriteria.CompareOperators.AddRange(GetStringCompareOperator(NameCompareOperator.Value));
                }
                else
                {
                    nameSearchCriteria.CompareOperators.AddRange(GetStringCompareOperator(DefaultNameCompareOperator));
                }

                taxonNameSearchCriteria.NameSearchString = nameSearchCriteria;
            }

            if (!string.IsNullOrEmpty(AuthorSearchString))
            {
                var authorSearchCriteria = new StringSearchCriteria();
                authorSearchCriteria.SearchString     = AuthorSearchString;
                authorSearchCriteria.CompareOperators = new List <StringCompareOperator>();
                if (AuthorCompareOperator.HasValue)
                {
                    authorSearchCriteria.CompareOperators.AddRange(GetStringCompareOperator(AuthorCompareOperator.Value));
                }
                else
                {
                    authorSearchCriteria.CompareOperators.AddRange(GetStringCompareOperator(DefaultAuthorCompareOperator));
                }

                taxonNameSearchCriteria.AuthorSearchString = authorSearchCriteria;
            }

            taxonNameSearchCriteria.IsOkForSpeciesObservation = IsOkForObsSystems;
            taxonNameSearchCriteria.IsRecommended             = IsRecommended;
            taxonNameSearchCriteria.IsUnique         = IsUnique;
            taxonNameSearchCriteria.IsValidTaxon     = IsValidTaxon;
            taxonNameSearchCriteria.IsValidTaxonName = IsValidTaxonName;

            if (NameCategoryId.HasValue && NameCategoryId.Value != -1)
            {
                taxonNameSearchCriteria.Category = taxonNameSearchCriteria.Category = CoreData.TaxonManager.GetTaxonNameCategory(
                    CoreData.UserManager.GetCurrentUser(),
                    NameCategoryId.Value);
            }

            if (RestrictToTaxonId.HasValue && RestrictToTaxonChildren)
            {
                taxonNameSearchCriteria.TaxonIds = new List <int> {
                    RestrictToTaxonId.Value
                };
            }

            return(taxonNameSearchCriteria);
        }
Ejemplo n.º 3
0
        private WebStringSearchCriteria GetStringSearchCriteria(IUserContext userContext,
                                                                StringSearchCriteria stringSearchCriteria)
        {
            WebStringSearchCriteria webStringSearchCriteria = new WebStringSearchCriteria();

            webStringSearchCriteria.CompareOperators = stringSearchCriteria.CompareOperators;
            webStringSearchCriteria.SearchString     = stringSearchCriteria.SearchString;
            return(webStringSearchCriteria);
        }
        public void GetRegionsBySearchCriteria()
        {
            RegionList           regions;
            RegionSearchCriteria regionSearchCriteria;

            // Test all parameters empty
            regionSearchCriteria = new RegionSearchCriteria();
            regions = GetRegionDataSource(true).GetRegionsBySearchCriteria(GetUserContext(), regionSearchCriteria);
            Assert.IsTrue(regions.IsNotEmpty());

            // Test region category list
            RegionCategoryList regionCategories = new RegionCategoryList();

            regionCategories.Add(new RegionCategory(1, null, null, null, null, null, 0, 0, new DataContext(GetUserContext())));
            regionSearchCriteria            = new RegionSearchCriteria();
            regionSearchCriteria.Categories = regionCategories;
            regions = GetRegionDataSource(true).GetRegionsBySearchCriteria(GetUserContext(), regionSearchCriteria);
            Assert.IsTrue(regions.IsNotEmpty());

            // Test Country ISO Codes
            List <Int32> countryIsoCodes = new List <Int32>();

            countryIsoCodes.Add(752);
            regionSearchCriteria = new RegionSearchCriteria();
            regionSearchCriteria.CountryIsoCodes = countryIsoCodes;
            regions = GetRegionDataSource(true).GetRegionsBySearchCriteria(GetUserContext(), regionSearchCriteria);
            Assert.IsTrue(regions.IsNotEmpty());

            // Test name search string
            String searchString = "U%";
            StringSearchCriteria         nameSearchString = new StringSearchCriteria();
            List <StringCompareOperator> compareOperators = new List <StringCompareOperator>();

            compareOperators.Add(StringCompareOperator.Equal);
            nameSearchString.CompareOperators = compareOperators;
            nameSearchString.SearchString     = searchString;
            regionSearchCriteria = new RegionSearchCriteria();
            regionSearchCriteria.NameSearchString = nameSearchString;
            regions = GetRegionDataSource(true).GetRegionsBySearchCriteria(GetUserContext(), regionSearchCriteria);
            Assert.IsTrue(regions.IsNotEmpty());

            // Test region type
            RegionType regionType = new RegionType(1, "", new DataContext(GetUserContext()));

            regionSearchCriteria      = new RegionSearchCriteria();
            regionSearchCriteria.Type = regionType;
            regions = GetRegionDataSource(true).GetRegionsBySearchCriteria(GetUserContext(), regionSearchCriteria);
            Assert.IsTrue(regions.IsNotEmpty());
        }
Ejemplo n.º 5
0
 public LockedUserInformationList GetLockedUserInformation(IUserContext userContext, StringSearchCriteria userNameSearchString)
 {
     throw new NotImplementedException();
 }