public Guid StartProcessing(WorkItem wi) { using var db = new LiteDatabase(fileService.GetAppFilePath(AppFile.mediaInfo)); var history = new MediaHistory(); ILiteCollection <MediaHistory> histories = default; try { histories = db.GetCollection <MediaHistory>(); history = histories.Query().Include(x => x.Entries).Where(x => x.FilePath == wi.SourceFile).FirstOrDefault(); } catch (InvalidCastException) { db.DropCollection(HISTORYTABLE); histories = db.GetCollection <MediaHistory>(); //todo: report on screen } if (history == default) { history = new MediaHistory() { FilePath = wi.SourceFile }; histories.Insert(history); } history.Entries ??= new(); var processingHistory = new ProcessingHistory() { Arguments = wi.Arguments.ToList(), DestinationFilePath = wi.DestinationFile, FilterID = wi.Job.FilterID, Preset = wi.Job.PresetName }; var entry = new HistoryEntry() { HistoryID = Guid.NewGuid(), Started = DateTime.Now, Type = "Processed", ProcessingHistory = processingHistory }; history.Entries.Add(entry); histories.EnsureIndex(x => x.Id); histories.Update(history); return(entry.HistoryID); }
public void AddHistory(long appId, DateTime?assignedTime, DateTime dateLeft, int employeeId, int stepId, int outComeCode) { var prohis = new ProcessingHistory(); prohis.ApplicationId = appId; prohis.AssignedTime = assignedTime; prohis.FinishedTime = dateLeft; prohis.EmployeeId = employeeId; prohis.StepId = stepId; prohis.OutComeCode = outComeCode; db.ProcessingHistories.Add(prohis); db.SaveChanges(); }