Example #1
0
        /// <summary>
        /// Searches the cabs nearby.
        /// </summary>
        /// <returns>System.Threading.Tasks.Task.</returns>
        private async Task SearchCabsNearby()
        {
            var geolocator = new Geolocator();
            var pos        = await geolocator.GetGeopositionAsync().AsTask();

            var locationPoint = new LocationPoint
            {
                Latitude  = pos.Coordinate.Point.Position.Latitude,
                Longitude = pos.Coordinate.Point.Position.Longitude
            };
            var searchResult = this.searchClient.SearchDocuments <GpsSensorRecord>(
                "*",
                SearchDocument.FilterTextForDistanceFromPoint("geoCoordinates", locationPoint, 100));

            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 near you...";
            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());
        }