Beispiel #1
0
        public MainViewModel(
            IAmalgamationManagementService iAmalgamationManagementService,
            IMessengerService messengerService,
            IWindowService windowService,
            IDialogInteractionService dialogInteractionService,
            IWindowsProcessService windowsProcessService,
            ISettingsService settingsService,
            ILogger logger)
        {
            _amalgamationManagementService = iAmalgamationManagementService;
            _messengerService         = messengerService;
            _windowService            = windowService;
            _dialogInteractionService = dialogInteractionService;
            _messengerService.Register <TaskProgressMessage>(this, HandleTaskProgressMessage);
            _messengerService.Register <AmalgamationSummary>(this, x => AmalgamationSummary = x);
            _windowsProcessService = windowsProcessService;
            _settingsService       = settingsService;
            _logger = logger;

            ChooseFileCommand         = new RelayCommand(ShowChooseFileDialog);
            AmalgamateFilesCommand    = new AsyncCommand(AmalgamateFiles, () => CanMerge);
            OutputDirectoryCommand    = new RelayCommand(() => ProcessStart(OutputDirectory));
            SettingsNavigationCommand = new RelayCommand(SettingsNavigate);
            AboutNavigationCommand    = new RelayCommand(AboutNavigate);
            RemoveFileCommand         = new RelayCommand <object>(RemoveFile);

            MergeAnotherSetOfFilesCommand = new RelayCommand(() => CurrentStage = StageKeys.ChooseFile);
            CancelCommand = new RelayCommand(Cancel, () => (CurrentStage == StageKeys.Processing) && (!_cancellationTokenSource?.IsCancellationRequested ?? false));
        }
Beispiel #2
0
        public async void TimeTracker()
        {
            var containerBuilder = BuildContainerBuilder();

            using (var container = containerBuilder.Build())
            {
                _amalgamationManagementService = container.Resolve <IAmalgamationManagementService>();
                _fileService = container.Resolve <IFileService>();
                _jsonSerializationService = container.Resolve <IJsonSerializationService>();
                _dateTimeProvider         = container.Resolve <IDateTimeProvider>();

                var cancellationToken = default(CancellationToken);

                Stopwatch timer = new Stopwatch();
                timer.Start();
                await _amalgamationManagementService.ProcessAsync(Directory.GetFiles(_testDataDirectory, "*.xml"), _testDataDirectory, cancellationToken);

                timer.Stop();

                var outputPath = new DirectoryInfo(_testDataDirectory).GetDirectories().OrderByDescending(d => d.LastWriteTimeUtc).FirstOrDefault().FullName;

                using (var stream = await _fileService.OpenWriteStreamAsync($"TimeTracker{_dateTimeProvider.GetNowUtc().ToString("yyyyMMdd-HHmmss")}.txt", outputPath, cancellationToken))
                {
                    var timeConsumed = $" total time elapsed to file merge {timer.Elapsed.TotalSeconds} seconds";
                    _jsonSerializationService.Serialize(timeConsumed, stream);
                }
            }
        }