public LogbookEntry ExpandTrack(Guid aircraftId, LogbookEntry logbookEntry) { IList <LogbookLocation> track = ToLogbookLocations( _logbookEntryTrackDao.GetTrack(GetLogbookEntryFile(aircraftId, logbookEntry.StartDateTime, "track", "csv"))); logbookEntry.Update(track); return(logbookEntry); }
public LogbookEntry GetEntryFromAcmiFile(FileInfo acmiFile) { /* copy to temp */ FileInfo tmpFile = acmiFile.CopyTo(Path.GetTempFileName(), true); /* unzip */ string unzipDir = Path.Combine(tmpFile.DirectoryName, "XPlaneLauncher", Path.GetRandomFileName()); ZipFile.ExtractToDirectory(tmpFile.FullName, unzipDir); FileInfo unzippedFile = new DirectoryInfo(unzipDir).GetFiles().First(); /* parse */ AcmiDto acmiDto = _acmiService.ParseFile(unzippedFile); /* remove tmp file */ tmpFile.Delete(); unzippedFile.Directory?.Delete(true); double trackLength = 0; for (int index = 0; index < acmiDto.Track.Count; index++) { Location location = acmiDto.Track[index]; Location nextLocation = acmiDto.Track.ElementAtOrDefault(index + 1); if (nextLocation != null) { trackLength += location.GreatCircleDistance(nextLocation); } } trackLength = Length.FromMeters(trackLength).NauticalMiles; /* Take year from recording time as year for reference time - currently ignore february 29th problems*/ acmiDto.ReferenceTime = new DateTime( acmiDto.RecordingTime.Year, acmiDto.ReferenceTime.Month, acmiDto.ReferenceTime.Day, acmiDto.ReferenceTime.Hour, acmiDto.ReferenceTime.Minute, acmiDto.ReferenceTime.Second); LogbookEntry autoLogEntry = new LogbookEntry( LogbookEntryType.AcmiZip, acmiDto.RecordingTime, acmiDto.RecordingTime.Add(acmiDto.Duration), acmiDto.Duration, acmiDto.Track, trackLength); autoLogEntry.Update(acmiFile.Name); return(autoLogEntry); }
private void CreateEntry( LogbookEntryType entryType, Guid aircraftId, DateTime startDateTime, DateTime endDateTime, TimeSpan duration, IList <LogbookLocation> track, double distanceNauticalMiles, string notes) { LogbookEntry newEntry = new LogbookEntry(entryType, startDateTime, endDateTime, duration, track, distanceNauticalMiles); newEntry.Update(notes); FileInfo logbookEntryFile = GetLogbookEntryFile(aircraftId, startDateTime, "log", "json"); FileInfo logbookEntryTrackFile = GetLogbookEntryFile(aircraftId, startDateTime, "track", "csv"); /* Persist entry to json*/ _logbookEntryDao.SaveWithoutTrack(logbookEntryFile, newEntry); /* Persist track as GeoJSON */ _logbookEntryTrackDao.Save(logbookEntryTrackFile, LocationsToEntries(newEntry.Track)); }
/// <summary> /// Initialisiert eine neue Instanz der <see cref="T:System.Object" />-Klasse. /// </summary> public LogListDesignViewModel() { LogEntries = new ObservableCollection <LogbookEntry>(); LogbookEntry logbookEntry = new LogbookEntry( LogbookEntryType.Manual, new DateTime(2020, 1, 1, 19, 45, 0), new DateTime(2020, 1, 2, 15, 42, 0), TimeSpan.FromHours(2.5), new List <LogbookLocation>(), 42.21); logbookEntry.Update( $"Some multiline{Environment.NewLine}Notes with some more text in it to fill the line and see if its wraps automatically."); LogEntries.Add(logbookEntry); LogEntries.Add(logbookEntry); LogEntries.Add(logbookEntry); LogEntries.Add(logbookEntry); SelectedEntry = LogEntries[1]; }