public void InitDatabaseTest() { DatabaseReader reader = GeoConnection2.InitDatabaseReader(null); List <TestItem> testItems = new List <TestItem> { new TestItem() { IP = "62.2.105.148", CountryCode = "CH", City = "Goldau", Latitude = 47.0476, Longitude = 8.5462 }, // upc gateway new TestItem() { IP = "52.142.84.61", CountryCode = "IE", City = "Dublin", Latitude = 53.3338, Longitude = -6.2488 }, // microsoft ireland new TestItem() { IP = "52.200.121.83", CountryCode = "US", City = "Ashburn", Latitude = 39.0481, Longitude = -77.4728 }, // origin new TestItem() { IP = "2001:4860:4860::8888", CountryCode = "US", City = null, Latitude = 37.751, Longitude = -97.822 }, // google dns }; testItems.ForEach(item => { var city = reader.City(item.IP); Assert.IsNotNull(city); Log($"IP={item.IP}, IsoCode={city.Country.IsoCode}, CountryName={city.Country.Name}, MostSpecifiySubivision={city.MostSpecificSubdivision.Name}, MostSpecifiySubivision.IsoCode={city.MostSpecificSubdivision.IsoCode}" + $", City={city.City.Name}, {city.Postal.Code}, Latitude={city.Location.Latitude}, Longitude={city.Location.Longitude}, Population={city.Location.PopulationDensity}"); Assert.IsTrue(item.CountryCode == city.Country.IsoCode); Assert.IsTrue(item.City == city.City.Name); Assert.AreEqual(item.Latitude, city.Location.Latitude); Assert.AreEqual(item.Longitude, city.Location.Longitude); }); }
private void AddOrUpdateConnection(IPHelper.I_OWNER_MODULE b) { var ic = _connectionsRoutes.Count % LineChart.ColorsDic.Count; var br = new SolidColorBrush(LineChart.ColorsDic[ic]); GeoConnection2 existingRoute = _connectionsRoutes.SingleOrDefault(l => l.RemoteAddress.Equals(b.RemoteAddress)); if (existingRoute == null) { _connectionsRoutes.Add(new GeoConnection2(b) { Brush = br }); } }
private void AddOrUpdateConnection(IConnectionOwnerInfo b) { var ic = ConnectionsRoutes.Count % LineChart.ColorsDic.Count; var br = new SolidColorBrush(LineChart.ColorsDic[ic]); GeoConnection2 existingRoute = ConnectionsRoutes.SingleOrDefault(l => l.RemoteAddress.Equals(b.RemoteAddress)); if (existingRoute is null) { ConnectionsRoutes.Add(new GeoConnection2(b) { Brush = br }); } }
async void Map_Loaded(object sender, RoutedEventArgs e) { if (!GeoConnection2.CheckDB()) { MessageBox.Show("The IP database cannot be found. The Map feature is disabled.", "Missing database"); return; } var ok = await GeoConnection2.InitCache(); initialPoint.SetValue(MapLayer.PositionProperty, CurrentCoordinates); ProgressStack.Visibility = Visibility.Collapsed; timer.Tick += timer_Tick; await Dispatcher.InvokeAsync(() => timer_Tick(null, null)); }