/// <summary> /// Single result of a batch Quova request for location data is appended to the /// csv file listed in code. Change this as needed. /// </summary> /// <param name="id"></param> /// <param name="quova"></param> private void WriteToCSVFile(string id, Quova quova) { _count++; if (_count == 16) _count = 16; if (!_textWriteOnce) { FileInfo t = new FileInfo("C:\\Temp\\Results2.csv"); _streamWriter = t.CreateText(); _streamWriter.WriteLine("ID,IP,Lat,Lon,City,State,Country,Continent"); _streamWriter.AutoFlush = true; _textWriteOnce = true; } else { //NB: Quova limits 2 requests per second System.Threading.Thread.Sleep(500); _streamWriter.WriteLine(id + ", " + quova.ipinfo.ip_address + ", " + quova.ipinfo.Location.latitude + ", " + quova.ipinfo.Location.longitude + ", " + quova.ipinfo.Location.CityData.city + ", " + quova.ipinfo.Location.StateData.state + ", " + quova.ipinfo.Location.CountryData.country + ", " + quova.ipinfo.Location.continent); } }
private void PopulateTextBox(Quova quovaResult) { if (quovaResult == null) return; _lat = quovaResult.ipinfo.Location.latitude; _lon = quovaResult.ipinfo.Location.longitude; txtLocationData.Text = "IP Address: " + quovaResult.ipinfo.ip_address + "\r\n"; txtLocationData.Text += "IP Type: " + quovaResult.ipinfo.ip_type + "\r\n"; txtLocationData.Text += "\r\n"; txtLocationData.Text += "Network" + "\r\n"; txtLocationData.Text += "ASN: " + quovaResult.ipinfo.network.asn + "\r\n"; txtLocationData.Text += "Carrier: " + quovaResult.ipinfo.network.carrier + "\r\n"; txtLocationData.Text += "Connection Type: " + quovaResult.ipinfo.network.connection_type + "\r\n"; txtLocationData.Text += "Domain: " + quovaResult.ipinfo.network.Domain.sld + "\r\n"; txtLocationData.Text += "IP Routing Type: " + quovaResult.ipinfo.network.ip_routing_type + "\r\n"; txtLocationData.Text += "Line Speed: " + quovaResult.ipinfo.network.line_speed + "\r\n"; txtLocationData.Text += "Organization: " + quovaResult.ipinfo.network.organization + "\r\n"; txtLocationData.Text += "\r\n"; txtLocationData.Text += "Coordinates" + "\r\n"; txtLocationData.Text += "Latitude: " + quovaResult.ipinfo.Location.latitude + "\r\n"; txtLocationData.Text += "Longitude: " + quovaResult.ipinfo.Location.longitude + "\r\n"; txtLocationData.Text += "\r\n"; txtLocationData.Text += "Location" + "\r\n"; txtLocationData.Text += "MSA" + quovaResult.ipinfo.Location.msa + "\r\n"; txtLocationData.Text += "Area Code: " + quovaResult.ipinfo.Location.CityData.area_code + "\r\n"; txtLocationData.Text += "City: " + quovaResult.ipinfo.Location.CityData.city + "\r\n"; txtLocationData.Text += "City CF: " + quovaResult.ipinfo.Location.CityData.city_cf + "\r\n"; txtLocationData.Text += "Postal Code: " + quovaResult.ipinfo.Location.CityData.postal_code + "\r\n"; txtLocationData.Text += "Time Zone: " + quovaResult.ipinfo.Location.CityData.time_zone + "\r\n"; txtLocationData.Text += "\r\n"; txtLocationData.Text += "State Data" + "\r\n"; txtLocationData.Text += "State: " + quovaResult.ipinfo.Location.StateData.state + "\r\n"; txtLocationData.Text += "State CF: " + quovaResult.ipinfo.Location.StateData.state_cf + "\r\n"; txtLocationData.Text += "State Code: " + quovaResult.ipinfo.Location.StateData.state_code + "\r\n"; txtLocationData.Text += "\r\n"; txtLocationData.Text += "Country Data" + "\r\n"; txtLocationData.Text += "Country: " + quovaResult.ipinfo.Location.CountryData.country + "\r\n"; txtLocationData.Text += "Country CF: " + quovaResult.ipinfo.Location.CountryData.country_cf + "\r\n"; txtLocationData.Text += "Country Code: " + quovaResult.ipinfo.Location.CountryData.country_code + "\r\n"; txtLocationData.Text += "\r\n"; txtLocationData.Text += "Continent Data" + "\r\n"; txtLocationData.Text += "Continent: " + quovaResult.ipinfo.Location.continent + "\r\n"; //I hate to do it, but this is simply a one liner to create a map. Uri uri = new Uri("https://maps.google.com/maps?q=" + _lat + "," + _lon + "&hl=en&t=m&z=14"); webBrowser1.Url = uri; }