public static GeoData GetEnterprise(string ClientIP) { using (var reader = new DatabaseReader(_EnterpriseDbPath)) { return(new GeoData(reader.Enterprise(ClientIP))); //// Use the Enterprise(ip) method to do a lookup in the Enterprise database //var response = reader.Enterprise(ClientIP); //var country = response.Country; //Console.WriteLine(country.IsoCode); // 'US' //Console.WriteLine(country.Name); // 'United States' //Console.WriteLine(country.Names["zh-CN"]); // '美国' //Console.WriteLine(country.Confidence); // 99 //var subdivision = response.MostSpecificSubdivision; //Console.WriteLine(subdivision.Name); // 'Minnesota' //Console.WriteLine(subdivision.IsoCode); // 'MN' //Console.WriteLine(subdivision.Confidence); // 77 //var city = response.City; //Console.WriteLine(city.Name); // 'Minneapolis' //Console.WriteLine(city.Confidence); // 11 //var postal = response.Postal; //Console.WriteLine(postal.Code); // '55455' //Console.WriteLine(postal.Confidence); // 5 //var location = response.Location; //Console.WriteLine(location.Latitude); // 44.9733 //Console.WriteLine(location.Longitude); // -93.2323 //Console.WriteLine(location.AccuracyRadius); // 50 } }
public void Enterprise_ValidResponse() { using var reader = new DatabaseReader(_enterpriseDatabaseFile); var ipAddress = "74.209.24.0"; var response = reader.Enterprise(ipAddress); Assert.Equal(11, response.City.Confidence); Assert.Equal(99, response.Country.Confidence); Assert.False(response.Country.IsInEuropeanUnion); Assert.Equal(6252001, response.Country.GeoNameId); Assert.Equal(27, response.Location.AccuracyRadius); Assert.False(response.RegisteredCountry.IsInEuropeanUnion); Assert.False(response.RepresentedCountry.IsInEuropeanUnion); Assert.Equal("Cable/DSL", response.Traits.ConnectionType); Assert.True(response.Traits.IsLegitimateProxy); Assert.Equal(ipAddress, response.Traits.IPAddress); Assert.Equal("74.209.16.0/20", response.Traits.Network?.ToString()); response = reader.Enterprise("149.101.100.0"); Assert.Equal("310", response.Traits.MobileCountryCode); Assert.Equal("004", response.Traits.MobileNetworkCode); }
public void Enterprise_ValidResponse() { using (var reader = new DatabaseReader(_enterpriseDatabaseFile)) { var ipAddress = "74.209.24.0"; var response = reader.Enterprise(ipAddress); Assert.Equal(11, response.City.Confidence); Assert.Equal(99, response.Country.Confidence); Assert.Equal(6252001, response.Country.GeoNameId); Assert.Equal(27, response.Location.AccuracyRadius); Assert.Equal("Cable/DSL", response.Traits.ConnectionType); Assert.True(response.Traits.IsLegitimateProxy); Assert.Equal(ipAddress, response.Traits.IPAddress); } }
public void Enterprise_ValidResponse() { using (var reader = new DatabaseReader(_enterpriseDatabaseFile)) { var ipAddress = "74.209.24.0"; var response = reader.Enterprise(ipAddress); Assert.That(response.City.Confidence, Is.EqualTo(11)); Assert.That(response.Country.Confidence, Is.EqualTo(99)); Assert.That(response.Country.GeoNameId, Is.EqualTo(6252001)); Assert.That(response.Location.AccuracyRadius, Is.EqualTo(27)); Assert.That(response.Traits.ConnectionType, Is.EqualTo("Cable/DSL")); Assert.IsTrue(response.Traits.IsLegitimateProxy); Assert.That(response.Traits.IPAddress, Is.EqualTo(ipAddress)); } }