public ArchiveVideo(JObject json, Archive.Archive archive, Guid sessionId) : base(json) { var pathArr = Meta["attachments"].ToObject <string[]>() ?? throw new ArgumentException("Video is missing 'attachments'"); var path = "" + sessionId + pathArr[0]; _archive = archive; var offset = Meta["start_time"].Value <long>(); // Find the file in the archive _zipEntry = _archive.FindFile(path) ?? throw new ZipException($"Video file '{path}' not found in archive"); var estimatedVideoLength = 0L; if (Meta.TryGetValue("video_length", out var value)) { estimatedVideoLength = value.Value <long>(); } // Create the video datapoint _video = new ArchiveVideoVideo(_zipEntry, _archive, path, offset, estimatedVideoLength) { Name = "Video" }; AddDataPoint(_video); IsSaved = true; }
private async Task <ArchiveTableInformation> ParseTableInformation(JObject json, Archive.Archive archive, Guid sessionId) { // Find the properties in the JSON ArchiveStructure.GetUserMeta(json, out var meta, out var user); var pathArr = meta["attachments"].ToObject <string[]>() ?? throw new ArgumentException("Table is missing 'attachments'"); var path = "" + sessionId + pathArr[0]; // Find the file in the archive var zipEntry = archive.FindFile(path) ?? throw new ZipException($"Table file '{path}' not found in archive"); var tableInformation = new ArchiveTableInformation { ZipEntry = zipEntry, Columns = new List <DataField>(), Uri = path, Units = new List <string>(), TimeUnit = "", }; // Open the table file using (var stream = await archive.OpenFile(zipEntry)) using (var reader = new ParquetReader(stream)) { var fields = reader.Schema.GetDataFields(); var rawUnits = new string[0]; if (meta.ContainsKey("units")) { rawUnits = meta["units"].Select(unit => unit.Value <string>()).ToArray(); } // Find all the column information int idx = 0; foreach (var field in fields) { // Fetch unit for current column string currUnit = ""; if (idx < rawUnits.Length) { currUnit = rawUnits[idx]; } idx++; if (field.Name.Equals("time", StringComparison.OrdinalIgnoreCase)) { tableInformation.Time = field; tableInformation.TimeUnit = currUnit; } else { tableInformation.Columns.Add(field); tableInformation.Units.Add(currUnit); } } } if (meta.ContainsKey("is_world_clock")) { tableInformation.IsWorldSynchronized = meta["is_world_clock"].Value <bool>(); } // Return the collected info return(tableInformation); }