private bool UpdateGeoIpDataOverrided(TimeSpan timeout, IPAddress ip) { GeoIpResult geoIpData = GeoIpManager.GetGeoIpData(new GeoIpOptions() { Ip = ip, Id = GeoIpManager.IpHashProvider.ComputeGuid(ip), MillisecondsTimeout = timeout == TimeSpan.MaxValue ? -1 : (int)Math.Min(timeout.TotalMilliseconds, int.MaxValue) }); if (geoIpData.ResolveState != GeoIpResolveState.Resolved || geoIpData.GeoIpData == null) { return(false); } Tracker.Current.Session.Interaction.SetGeoData(geoIpData.GeoIpData); Tracker.Current.Session.Interaction.UpdateLocationReference(); return(true); }
private static GeoIpResult ConvertJsonToResult(Stream stream) { var serializer = CreateJsonSerializer(); using (var reader = new JsonTextReader(new StreamReader(stream))) { dynamic json = serializer.Deserialize<dynamic>(reader); GeoIpResult result = new GeoIpResult() { City = json.cityName, Region = json.regionName, Country = json.countryName, CountryCode = json.countryCode, Latitude = json.latitude ?? 0, Longitude = json.longitude ?? 0, PostalCode = json.zipCode, }; return result; } }