Exemplo n.º 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;
                }
            }
Exemplo n.º 2
0
        public MainVM(SettingsVM settings, ICollection <SourceDirectory> sourceDirectories)
        {
            Guard.NotNull(settings);
            _ts        = TaskScheduler.FromCurrentSynchronizationContext();
            HistoryVM  = new HistoryVM(this);
            OutputVM   = new OutputVM(this);
            SettingsVM = settings;
            WireupCommands();

            if (sourceDirectories != null)
            {
                foreach (var src in sourceDirectories)
                {
                    SourceDirectories.Add(new SourceDirectoryVM(this, src));
                }
            }

            System.Windows.Data.BindingOperations.EnableCollectionSynchronization(SourceDirectories, SourceDirectories);
            ThemeHelper.ApplyTheme(SettingsVM.Theme);
        }
Exemplo n.º 3
0
 public void Dispose()
 {
     OutputVM.EndWritingLog();
     DbConnection.Dispose();
 }