/// <summary> /// Launches the search of a new geolocation /// </summary> void ButtonClicked() { GeocodingAPI api = new GeocodingAPI(); api.Geocode(text.text, (List <double> result) => { map.ShowMap((float)result[0], (float)result[1]); }); }
public MissionService(string connectionString, string dbName, string collectionName, GeocodingAPI geocodingApi) { _geocodingApi = geocodingApi; var client = new MongoClient(connectionString); var database = client.GetDatabase(dbName); _database = database; _collectionName = collectionName; _missions = database.GetCollection <Mission>(collectionName); }
/// <summary> /// Test a user's website /// </summary> /// <param name="url"></param> /// <param name="browser"></param> /// <param name="city"></param> /// <param name="state"></param> /// <param name="provider"></param> /// <param name="requests"></param> public void TestWebsite(string url, string browser, string city, string state, string provider, string requests) { //Locks the thread so multiple drivers are not being used at the same time lock (wtLock) { Driver driver = new Driver(); //Get today's date DateTime now = DateTime.Now; int norequests = Convert.ToInt32(requests); //If either is empty, then use the ipv4 information to get computer's location if (!browser.Equals("firefox") || String.IsNullOrEmpty(city) || String.IsNullOrEmpty(state)) { //Get ipv4 information IPAddress ipv4 = Array.FindLast( Dns.GetHostEntry(string.Empty).AddressList, a => a.AddressFamily == AddressFamily.InterNetwork); IPAddressAPI ipa = new IPAddressAPI(); driver.LoadDriver(url, ipa.GetLocation(ipv4.ToString()).city, ipa.GetLocation(ipv4.ToString()).state, browser, provider, norequests); } else { //Get coordinates using the Geocoding API GeocodingAPI ga = new GeocodingAPI(); //Get the proper capitalization of state and city state = state.ToUpper(); city = city.ToLower(); //Get the latitude and longitude of the city and state IList <double> coord = ga.GetLocationCoords(city, state); double lat = coord[0]; double lng = coord[1]; string path = Path.Combine(Directory.GetCurrentDirectory(), "Selenium/location.json"); //Update JSON with the correct latitude and longitude of the chosen dest. string json = System.IO.File.ReadAllText(path); dynamic jsonObj = Newtonsoft.Json.JsonConvert.DeserializeObject(json); jsonObj["location"]["lat"] = lat; jsonObj["location"]["lng"] = lng; string output = Newtonsoft.Json.JsonConvert.SerializeObject(jsonObj, Newtonsoft.Json.Formatting.Indented); System.IO.File.WriteAllText(path, output); driver.LoadDriver(url, city, state, browser, provider, norequests); } } }
public MissionController(IMissionService missionService, GeocodingAPI geocodingApi) { _geocodingApi = geocodingApi; _missionService = missionService; }