internal JobContext(CommandLineSandbox shell, CancellationToken cancellationToken, ProgressViewModel progress, HistoryEventVM eventVM, OutputVM output) { Shell = shell; Progress = progress; OutputVM = output; CancellationToken = cancellationToken; Information = new T(); DbConnection = AppDataManager.ConnectToSqlite(); try { HistoryVM = eventVM; eventVM.Insert(DbConnection); if (!HistoryVM.ID.HasValue) { throw new InvalidOperationException("No ID obtained for Job from DB."); } string logPath = AppDataManager.GetLogFilePath(HistoryVM.ID.Value); output.Cls(); output.StartWritingLog(logPath); } catch (Exception e) { log.ErrorFormat($"Exception while trying to setup context for command '{eventVM.Command}': {e.Message}"); DbConnection.Dispose(); throw; } }
public HistoryEventVM CreateHistoryEvent() { var vm = new HistoryEventVM(this); lock (Entries) Entries.Insert(0, vm); return(vm); }