Пример #1
0
            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;
                }
            }
Пример #2
0
        private void NavigateTo(object obj)
        {
            Task.Run(() =>
            {
                if (!ID.HasValue)
                {
                    return;
                }

                var fileName = AppDataManager.GetLogFilePath(ID.Value);
                if (!File.Exists(fileName))
                {
                    return;
                }

                Process.Start(fileName);
            });
        }