/// <summary> /// Searches the cabs in area. /// </summary> /// <param name="area">The area.</param> /// <returns>System.Threading.Tasks.Task.</returns> private async Task SearchCabsInArea(string area) { var locationData = new LocationData(BingApiKey).GetBoundingBoxCoordinates($"{area},India").Result; var searchResult = this.searchClient.SearchDocuments <GpsSensorRecord>( "*", SearchDocument.FilterTextForLocationBounds("geoCoordinates", locationData)); if (!searchResult.Any()) { await this.SendErrorMessageAsync("No cabs available"); return; } var tilelist = searchResult.Select( result => new VoiceCommandContentTile { ContentTileType = VoiceCommandContentTileType.TitleOnly, Title = result.VehicleId }).ToList(); var successmessage = new VoiceCommandUserMessage(); successmessage.DisplayMessage = successmessage.SpokenMessage = $"Found the following cabs in {area}..."; var response = VoiceCommandResponse.CreateResponse(successmessage, tilelist); await this.voiceCommandServiceConnection.ReportSuccessAsync(response); }
public void SearchDocumentsTest() { var locationData = new LocationData(ConfigurationManager.AppSettings[ConfigurationKeys.BingMapsKey]); var searchServiceName = ConfigurationManager.AppSettings[ConfigurationKeys.SearchServiceName]; var searchServiceKey = ConfigurationManager.AppSettings[ConfigurationKeys.SearchServiceKey]; var searchClient = new SearchDocument(searchServiceName, searchServiceKey); var data = locationData.GetBoundingBoxCoordinates("Delhi,India").Result; var searchResult = searchClient.SearchDocuments <GpsSensorRecord>("*", SearchDocument.FilterTextForLocationBounds("geoCoordinates", data)); var locationPoint = new LocationPoint { Latitude = 28.644979476928711, Longitude = 77.2164306640625 }; var searchByDistance = searchClient.SearchDocuments <GpsSensorRecord>("*", SearchDocument.FilterTextForDistanceFromPoint("geoCoordinates", locationPoint, 100)); Assert.IsTrue(searchResult.Any()); Assert.IsTrue(searchByDistance.Any()); var dataUsa = locationData.GetBoundingBoxCoordinates("Washington,USA").Result; var searchResultUsa = searchClient.SearchDocuments <GpsSensorRecord>("*", SearchDocument.FilterTextForLocationBounds("geoCoordinates", dataUsa)); Assert.IsTrue(searchResultUsa.Any()); }