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; }
public void ExecutableName_ForUnknown_EmptyString() { var task = new Archive.Archive(); task.Command = "Unknown"; Assert.AreEqual(String.Empty, task.ExecutableName()); }
public void ExecutableName_ForTar_Tar() { var task = new Archive.Archive(); task.Command = "Tar"; Assert.AreEqual("tar", task.ExecutableName()); }
public ArchiveVideoVideo(ZipEntry zipEntry, Archive.Archive archive, string path, long startTime, long videoLength) { _zipEntry = zipEntry; _archive = archive; URI = path; _streamFactory = _archive.OpenFileFactory(_zipEntry); VideoTime = new ArchiveVideoTime(_streamFactory, path, startTime, videoLength); }
public void Arguments_ForUnknown_EmptyString() { var task = new Archive.Archive(); task.Command = "Unknown"; task.OutputFileName = "MyOutputFile.tar.gz"; Assert.AreEqual(String.Empty, task.Arguments()); }
public void Arguments_ForTar_CorrectAndIncludeFileName() { var task = new Archive.Archive(); task.Command = "Tar"; task.OutputFileName = "MyOutputFile.tar.gz"; Assert.AreEqual("-cvzf MyOutputFile.tar.gz", task.Arguments()); }
public void TrimBaseFromFilePath_WithBaseNoTrailingSlash_ExcludesBasePath() { var task = new Archive.Archive(); task.BasePath = "/trim/this/path"; var result = task.TrimBaseFromFilePath("/trim/this/path/myproject/here"); Assert.AreEqual("myproject/here", result); }
public void TrimBaseFromFilePath_WithBase_ExcludesBasePath() { var task = new Archive.Archive { BasePath = "/trim/this/path/" }; var result = task.TrimBaseFromFilePath("/trim/this/path/myproject/here"); Assert.AreEqual("myproject/here", result); }
public Core() { Setting.LoadSetting(); Setting.LoadWorkInfo(); TimerArchive.Elapsed += TimerArchive_Elapsed; TimerArchive.AutoReset = true; Archive = new Archive.Archive(Setting.ListDataParams); inputWork = new Input.Work(Setting.inputCUDR, Setting.inputGS, Setting.ListStages); inputWork.OnChangedState += InputWork_OnChangedState; }
public void FlattenFilePaths_TwoItems_TrimsAndStringCorrect() { using (var e = new EnvironmentForTest()) { var task = new Archive.Archive(); task.BasePath = e.BasePath; task.InputFilePaths = e.TwoItemsWithBasePath("a.cs", "b.cs"); var result = task.FlattenFilePaths(task.InputFilePaths, ' ', false); Assert.AreEqual("a.cs b.cs", result); } }
public void FlattenFilePaths_TwoItemsForceQuote_TrimsAndQuotesStringCorrect() { using (new EnvironmentForTest()) { var task = new Archive.Archive { BasePath = EnvironmentForTest.BasePath, InputFilePaths = EnvironmentForTest.TwoItemsWithBasePath("a.cs", "b.cs") }; var result = task.FlattenFilePaths(task.InputFilePaths, ' ', true); Assert.AreEqual("\"a.cs\" \"b.cs\"", result); } }
internal ArchiveTable(JObject json, Archive.Archive archive, Guid sessionId, ArchiveTableInformation tableInformation) : base(json) { IsSaved = true; _archive = archive; _zipEntry = tableInformation.ZipEntry; _sessionId = sessionId; if (tableInformation.Time == null) { throw new ArgumentException("Table does not have a column named 'Time'"); } var streamTask = archive.OpenFile(_zipEntry); streamTask.Wait(); using (var reader = new ParquetReader(streamTask.Result)) { _reader = new RememberingParquetReader(reader); } AddColumns(tableInformation); }
public async Task <ArchiveStructure> CreateFromJSON(JObject json, Archive.Archive archive, Guid sessionId) { var information = await ParseTableInformation(json, archive, sessionId); return(new ArchiveTable(json, archive, sessionId, information)); }
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); }