private bool ProcessLocationUpdate(EDEvent edEvent) { EDLocation currentLocation = edEvent.Location(); if (currentLocation == null) { return(false); } if (SessionStartLocation == null) { SessionStartLocation = currentLocation; } _telemetry["CurrentAltitude"] = EDLocation.DistanceToString(edEvent.Altitude); if ((int)edEvent.Altitude > MaximumAltitude) { MaximumAltitude = (int)edEvent.Altitude; _telemetry["MaximumAltitude"] = EDLocation.DistanceToString(MaximumAltitude); } else if (!_playerIsInSRV && (int)edEvent.Altitude < MinimumAltitude) { MinimumAltitude = (int)edEvent.Altitude; _telemetry["MinimumAltitude"] = EDLocation.DistanceToString(MinimumAltitude); } if (_lastLocation == null) { _lastLocation = currentLocation; return(false); } if (_lastLocation.Latitude.Equals(currentLocation.Latitude) && _lastLocation.Longitude.Equals(currentLocation.Longitude)) { return(false); } _telemetry["CurrentLatitude"] = currentLocation.Latitude.ToString(); _telemetry["CurrentLongitude"] = currentLocation.Longitude.ToString(); // Update distance/speed statistics if (CalculateDistances(currentLocation)) { CalculateSpeed(currentLocation, edEvent.TimeStamp); if (SessionStartTime == DateTime.MinValue) { // We set session start time on first detected movement SessionStartTime = DateTime.UtcNow; _telemetry["SessionStartTime"] = SessionStartTime.ToString("HH:mm:ss"); _telemetry["SessionDate"] = SessionStartTime.ToShortDateString(); } return(true); } return(false); }
public void SaveSession() { if (String.IsNullOrEmpty(SessionSaveFolder)) { return; } string saveFile = SessionSaveFolder; if (!saveFile.EndsWith("\\")) { saveFile = $"{saveFile}\\"; } saveFile = $"{saveFile}{SessionStartTime.ToString("yyyyMMddhhmmss")} Session.json"; try { File.WriteAllText(saveFile, this.ToString()); } catch { } }