/// <summary> /// Get web search criteria. /// </summary> /// <param name="userContext">User context.</param> /// <param name="searchCriteria">Search criteria.</param> /// <returns>Web search criteria.</returns> private WebRegionSearchCriteria GetSearchCriteria(IUserContext userContext, IRegionSearchCriteria searchCriteria) { WebRegionSearchCriteria webSearchCriteria; webSearchCriteria = new WebRegionSearchCriteria(); List <WebRegionCategory> webRegionCategories; webRegionCategories = null; if (searchCriteria.Categories.IsNotEmpty()) { webRegionCategories = new List <WebRegionCategory>(); foreach (IRegionCategory regionCategory in searchCriteria.Categories) { webRegionCategories.Add(GetRegionCategory(userContext, regionCategory)); } } webSearchCriteria.Categories = webRegionCategories; webSearchCriteria.CountryIsoCodes = searchCriteria.CountryIsoCodes; if (searchCriteria.NameSearchString.IsNotNull()) { webSearchCriteria.NameSearchString = GetStringSearchCriteria(userContext, searchCriteria.NameSearchString); } if (searchCriteria.Type.IsNotNull()) { webSearchCriteria.Type = GetRegionType(userContext, searchCriteria.Type); } return(webSearchCriteria); }
/// <summary> /// Get regions that matches the search criterias. /// </summary> /// <param name="clientInformation">Information about the client that makes this web service call.</param> /// <param name="searchCriteria">Region search criterias.</param> /// <returns>Regions that matches the search criterias.</returns> public List <WebRegion> GetRegionsBySearchCriteria(WebClientInformation clientInformation, WebRegionSearchCriteria searchCriteria) { using (ClientProxy client = new ClientProxy(this, 1)) { return(client.Client.GetRegionsBySearchCriteria(clientInformation, searchCriteria)); } }
/// <summary> /// Check that data is valid. /// </summary> /// <param name="searchCriteria">This region search criteria.</param> public static void CheckData(this WebRegionSearchCriteria searchCriteria) { if (searchCriteria.Categories.IsNotEmpty()) { foreach (WebRegionCategory category in searchCriteria.Categories) { category.CheckData(); } } }
/// <summary> /// Get regions that matches the search criterias. /// </summary> /// <param name="userContext">User context.</param> /// <param name="searchCriteria">Region search criterias.</param> /// <returns>Regions that matches the search criterias.</returns> public RegionList GetRegionsBySearchCriteria(IUserContext userContext, IRegionSearchCriteria searchCriteria) { List <WebRegion> webRegions; WebRegionSearchCriteria webRegionSearchCriteria = new WebRegionSearchCriteria(); webRegionSearchCriteria = GetSearchCriteria(userContext, searchCriteria); WebCoordinateSystem webCoordinateSystem = new WebCoordinateSystem(); webRegions = WebServiceProxy.GeoReferenceService.GetRegionsBySearchCriteria(GetClientInformation(userContext), webRegionSearchCriteria); return(GetRegions(userContext, webRegions)); }
/// <summary> /// Get regions that matches the search criterias. /// </summary> /// <param name="clientInformation">Information about the client that makes this web service call.</param> /// <param name="searchCriteria">Region search criterias.</param> /// <returns>Regions that matches the search criterias.</returns> public List <WebRegion> GetRegionsBySearchCriteria( WebClientInformation clientInformation, WebRegionSearchCriteria searchCriteria) { using (WebServiceContext context = GetWebServiceContext(clientInformation)) { try { return (ArtDatabanken.WebService.GeoReferenceService.Data.RegionManager.GetRegionsBySearchCriteria( context, searchCriteria)); } catch (Exception exception) { LogException(clientInformation, context, exception); LogParameter(context, "SearchCriteria", searchCriteria.WebToString()); throw; } } }
public void GetRegionsBySearchCriteria() { List <Int32> countryIsoCodes; List <WebRegion> regions; List <WebRegionCategory> allRegionCategories, regionCategories; String nameSearchString; WebRegionCategory regionCategory; WebRegionSearchCriteria searchCriteria; WebRegionType regionType; WebStringSearchCriteria stringSearchCriteria; allRegionCategories = WebServiceProxy.GeoReferenceService.GetRegionCategories(GetClientInformation(), false, 0); // Test - All parameters are empty. // All regions are returned. searchCriteria = new WebRegionSearchCriteria(); regions = WebServiceProxy.GeoReferenceService.GetRegionsBySearchCriteria(GetClientInformation(), searchCriteria); Assert.IsTrue(regions.IsNotEmpty()); // Test - CountryIsoCodes. searchCriteria = new WebRegionSearchCriteria(); countryIsoCodes = new List <Int32>(); countryIsoCodes.Add(allRegionCategories[0].CountryIsoCode); searchCriteria.CountryIsoCodes = countryIsoCodes; regions = WebServiceProxy.GeoReferenceService.GetRegionsBySearchCriteria(GetClientInformation(), searchCriteria); Assert.IsTrue(regions.IsNotEmpty()); // Name search string. searchCriteria = new WebRegionSearchCriteria(); nameSearchString = "U%"; stringSearchCriteria = new WebStringSearchCriteria(); stringSearchCriteria.SearchString = nameSearchString; searchCriteria.NameSearchString = stringSearchCriteria; regions = WebServiceProxy.GeoReferenceService.GetRegionsBySearchCriteria(GetClientInformation(), searchCriteria); Assert.IsTrue(regions.IsNotEmpty()); // Check that every region name starts with letter "U" foreach (WebRegion region in regions) { Assert.IsTrue(region.Name.Substring(0, 1).Equals("U")); } // Test - Region categories. searchCriteria = new WebRegionSearchCriteria(); regionCategories = new List <WebRegionCategory>(); regionCategory = allRegionCategories[2]; regionCategories.Add(regionCategory); searchCriteria.Categories = regionCategories; regions = WebServiceProxy.GeoReferenceService.GetRegionsBySearchCriteria(GetClientInformation(), searchCriteria); Assert.IsTrue(regions.IsNotEmpty()); // Check that all regions belong to the specified category. foreach (WebRegion region in regions) { Assert.AreEqual(regionCategory.Id, region.CategoryId); } // Test - Region type. searchCriteria = new WebRegionSearchCriteria(); regionType = WebServiceProxy.GeoReferenceService.GetRegionTypes(GetClientInformation())[0]; searchCriteria.Type = regionType; regions = WebServiceProxy.GeoReferenceService.GetRegionsBySearchCriteria(GetClientInformation(), searchCriteria); Assert.IsTrue(regions.IsNotEmpty()); }