//Os fluxos abaixo foram executados na ordem em que se apresentam //Step 1 //Busca uma lista de coordenadas no arquivo KML //Para cada coordenada busca dados de lugares na api do Foursquare (Parametro true para salvar respostas das consultas no banco de dados, ou nada, para não salvar) //Converte o resultado da consulta em um objeto do sistema, verifica se ele já existe no banco e insere (ou não) no banco de dados private static void RequestAndStorePlaces(IVenueService venueService) { IList <string> coordinates = KMLReader.GetCoordiates(); foreach (var latLon in coordinates) { RawVanuesData rawVenues = FoursquareClient.GetVenues(latLon, true); foreach (var rawVenue in rawVenues.Response.Venues) { venueService.Insert(new Venue(rawVenue)); } } }
/// <summary> /// Refresh NearByLocations with Foursquare GeoCoordinate Service /// </summary> internal void RefreshNearByLocations() { GeoCoordinate gpsPosition = _watcher.Position.Location; MyLocationsVM.IsRefreshing = true; MyLocationsVM.NearByLocations.Clear(); if (string.IsNullOrEmpty(SettingsVM.Instance.FoursquareClientID) || string.IsNullOrEmpty(SettingsVM.Instance.FoursquareClientSecret)) { throw new Exception("Foursquare keys are missing, please provide Client ID and Client Secret from http://www.foursquare.com for using forsquare api v2"); } FoursquareClient fc = new FoursquareClient(SettingsVM.Instance.FoursquareClientID, SettingsVM.Instance.FoursquareClientSecret); fc.GetNearbyVenuesFailed += (object sender, EventArgs e) => { if (MessageBox.Show("foursquare is unreachable right now, do you want to try again?", "searching for nearby locations", MessageBoxButton.OKCancel) == MessageBoxResult.OK) { RefreshNearByLocations(); } }; fc.GetNearbyVenuesCompleted += (List <Nearby> nearbys) => { MyLocationsVM.IsRefreshing = false; LastRadius = SettingsVM.Instance.SearchRadius; var nearbysSorted = from p in nearbys orderby p.location.distance ascending select p; MyLocationsVM.NearByLocations.Clear(); foreach (Nearby n in nearbysSorted) { MyLocationsVM.NearByLocations.Add(new LocationsVM.Location(n.name, new GeoCoordinate(n.location.lat, n.location.lng), n.location.address, n.location.city, n.location.distance, n.categories != null ? (n.categories.Count > 0 ? n.categories[0].icon : "") : "")); } }; fc.GetNearbyVenuesAsync(gpsPosition.Latitude, gpsPosition.Longitude, SettingsVM.Instance.SearchRadius); }
public void Cleanup() { client = null; }
public void Initialize() { client = new FoursquareClient(); }
/// <summary> /// Initializes a new instance of the login form with a specified OAuth client. /// </summary> /// <param name="client">Instance of the OAuth client.</param> /// <param name="autoLogout">Disables saving and restoring authorization cookies in WebBrowser. Default: false.</param> /// <param name="loadUserInfo">Indicates the need to make a request for recive the user profile or not. Default: false.</param> /// <param name="responseType">Allows to set the type of response that is expected from the server. Default: <see cref="ResponseType.Token"/>.</param> public FoursquareLogin(FoursquareClient client, bool autoLogout = false, bool loadUserInfo = false, string responseType = "token") : base(client, autoLogout, loadUserInfo, responseType) { this.Height = 595; this.Icon = Properties.Resources.foursquare; }
public FoursqureViewModel(ISettingsService settingsService, INavigationService navigationService) { _settingsService = settingsService; _navigationService = navigationService; _foursquareClient = new FoursquareClient(); }