public static ArtDatabanken.Data.ArtDatabankenService.TaxonNameList GetSomeTaxonNames()
        {
            // Get several taxa names.
            var searchCriteria = new ArtDatabanken.Data.ArtDatabankenService.TaxonNameSearchCriteria();

            searchCriteria.NameSearchString = "%björn%";
            return(ArtDatabanken.Data.ArtDatabankenService.TaxonManager.GetTaxonNamesBySearchCriteria(searchCriteria));
        }
Пример #2
0
 private ArtDatabanken.Data.ArtDatabankenService.TaxonNameSearchCriteria GetSearchCriteria(Boolean refresh)
 {
     if (_searchCriteria.IsNull() || refresh)
     {
         _searchCriteria = new ArtDatabanken.Data.ArtDatabankenService.TaxonNameSearchCriteria();
     }
     return(_searchCriteria);
 }
        public void GetTaxonNamesBySearchCriteria()
        {
            ArtDatabanken.Data.ArtDatabankenService.TaxonNameList           taxonNames;
            ArtDatabanken.Data.ArtDatabankenService.TaxonNameSearchCriteria searchCriteria;

            foreach (WebService.SearchStringComparisonMethod nameSearchMethod in Enum.GetValues(typeof(WebService.SearchStringComparisonMethod)))
            {
                // Get no taxa names.
                searchCriteria = new ArtDatabanken.Data.ArtDatabankenService.TaxonNameSearchCriteria();
                searchCriteria.NameSearchString = "No taxon name";
                searchCriteria.NameSearchMethod = nameSearchMethod;
                taxonNames = ArtDatabanken.Data.ArtDatabankenService.TaxonManager.GetTaxonNamesBySearchCriteria(searchCriteria);
                Assert.IsNull(taxonNames);

                // Get one taxon name.
                if (nameSearchMethod != WebService.SearchStringComparisonMethod.Contains)
                {
                    searchCriteria = new ArtDatabanken.Data.ArtDatabankenService.TaxonNameSearchCriteria();
                    searchCriteria.NameSearchString = "björn";
                    searchCriteria.NameSearchMethod = nameSearchMethod;
                    taxonNames =
                        ArtDatabanken.Data.ArtDatabankenService.TaxonManager.GetTaxonNamesBySearchCriteria(
                            searchCriteria);
                    Assert.IsNotNull(taxonNames);
                    Assert.AreEqual(taxonNames.Count, 1);
                }

                // Get several taxa names.
                if (nameSearchMethod != WebService.SearchStringComparisonMethod.Exact)
                {
                    searchCriteria = new ArtDatabanken.Data.ArtDatabankenService.TaxonNameSearchCriteria();
                    searchCriteria.NameSearchString = "björn%";
                    searchCriteria.NameSearchMethod = nameSearchMethod;
                    taxonNames = ArtDatabanken.Data.ArtDatabankenService.TaxonManager.GetTaxonNamesBySearchCriteria(searchCriteria);
                    Assert.IsNotNull(taxonNames);
                    Assert.IsTrue(taxonNames.Count > 1);
                }
            }

            // Test iterativ search.
            searchCriteria = new ArtDatabanken.Data.ArtDatabankenService.TaxonNameSearchCriteria();
            searchCriteria.NameSearchString = "björn";
            searchCriteria.NameSearchMethod = WebService.SearchStringComparisonMethod.Iterative;
            taxonNames = ArtDatabanken.Data.ArtDatabankenService.TaxonManager.GetTaxonNamesBySearchCriteria(searchCriteria);
            Assert.IsNotNull(taxonNames);
            Assert.AreEqual(taxonNames.Count, 1);

            searchCriteria.NameSearchString = "björ";
            taxonNames = ArtDatabanken.Data.ArtDatabankenService.TaxonManager.GetTaxonNamesBySearchCriteria(searchCriteria);
            Assert.IsNotNull(taxonNames);
            Assert.IsTrue(taxonNames.Count > 1);

            searchCriteria.NameSearchString = "jörn";
            taxonNames = ArtDatabanken.Data.ArtDatabankenService.TaxonManager.GetTaxonNamesBySearchCriteria(searchCriteria);
            Assert.IsNotNull(taxonNames);
            Assert.IsTrue(taxonNames.Count > 1);
        }
        public static ArtDatabanken.Data.ArtDatabankenService.TaxonName GetTaxonName()
        {
            ArtDatabanken.Data.ArtDatabankenService.TaxonNameList taxonNames;

            var searchCriteria = new ArtDatabanken.Data.ArtDatabankenService.TaxonNameSearchCriteria();

            searchCriteria.NameSearchString = "björn";
            taxonNames = ArtDatabanken.Data.ArtDatabankenService.TaxonManager.GetTaxonNamesBySearchCriteria(searchCriteria);
            return(taxonNames[0]);
        }
Пример #5
0
        /// <summary>
        /// Get taxon names that matches the search criteria.
        /// </summary>
        /// <param name="searchCriteria">The taxon name search criteria.</param>
        /// <returns>Taxon names.</returns>
        /// <exception cref="ArgumentException">Thrown if search criteria is not valid.</exception>
        public static TaxonNameList GetTaxonNamesBySearchCriteria(TaxonNameSearchCriteria searchCriteria)
        {
            List <WebTaxonName>        webTaxonNames;
            WebTaxonNameSearchCriteria webSearchCriteria;

            // Check arguments.
            searchCriteria.CheckNotNull("searchCriteria");
            searchCriteria.CheckData();

            // Create WebSearchCriteria.
            webSearchCriteria = new WebTaxonNameSearchCriteria();
            webSearchCriteria.NameSearchMethod = searchCriteria.NameSearchMethod;
#if DATA_SPECIFIED_EXISTS
            webSearchCriteria.NameSearchMethodSpecified = true;
#endif
            webSearchCriteria.NameSearchString = searchCriteria.NameSearchString;

            // Get data from web service.
            webTaxonNames = WebServiceClient.GetTaxonNamesBySearchCriteria(webSearchCriteria);
            return(GetTaxonNames(webTaxonNames));
        }
Пример #6
0
 public TaxonNameSearchCriteriaTest()
 {
     _searchCriteria = null;
 }