예제 #1
0
        private static async Task <FileObject> PerformOneIterationOfPhaseTwoAsync(
            AnalysisIterationContextPhaseTwo iterationContext)
        {
            iterationContext.ThrowIfNull(nameof(iterationContext));

            _logger.Info("Preparing to run one iteration of phase two.");

            var fileDeleter = new FileDeleter(iterationContext.FinalOutputFile);

            // Contract: the analysis program is located in the same directory as our app.
            var processLaunchContext = ProcessLaunchContext.Create(
                file: iterationContext.Args.AnalysisProgramName,
                args: iterationContext.AnalysisInputArgs,
                showWindow: iterationContext.LaunchContext.ShowAnalysisWindow
                );

            _logger.Info(
                $"Starting analysis program. Launch context: {processLaunchContext.ToLogString()}"
                );
            using (var analysisRunner = ProgramRunner.RunProgram(processLaunchContext))
            {
                _logger.Info("Waiting to finish one iteration of phase two.");
                await analysisRunner.WaitAsync();
            }

            DataObject <OutputFileData> data =
                iterationContext.FileWorker.ReadDataFile(iterationContext.FinalOutputFile);

            _logger.Info("Finished one iteration of phase two.");
            return(new FileObject(fileDeleter, data));
        }
예제 #2
0
        public static async Task <FileObject> PerformOneIterationOfPhaseOneAsync(ParametersPack args,
                                                                                 AnalysisLaunchContext launchContext, LocalFileWorker fileWorker)
        {
            args.ThrowIfNull(nameof(args));
            launchContext.ThrowIfNull(nameof(launchContext));
            fileWorker.ThrowIfNull(nameof(fileWorker));

            _logger.Info("Preparing to run one iteration of phase one.");

            // Contract: output files are located in the same directory as our app.
            IReadOnlyList <FileInfo> finalOutputFiles = args.GetOutputFilenames(phaseNumber: 1);

            CheckExpectedFilenamesNumber(upperBound: 2, finalOutputFiles);

            var fileDeleter = new FileDeleter(finalOutputFiles);

            // Contract: the analysis program is located in the same directory as our app.
            var processLaunchContext = ProcessLaunchContext.Create(
                file: args.AnalysisProgramName,
                args: args.PackAsInputArgumentsForPhaseOne(),
                showWindow: launchContext.ShowAnalysisWindow
                );

            _logger.Info(
                $"Starting analysis program. Launch context: {processLaunchContext.ToLogString()}"
                );
            using (var analysisRunner = ProgramRunner.RunProgram(processLaunchContext))
            {
                _logger.Info("Waiting to finish one iteration of phase one.");
                await analysisRunner.WaitAsync();
            }

            // The first data file is iteration result, the last is common analysis data file.
            // We don't need to read/use the last one.
            FileInfo finalOutputFile = finalOutputFiles.First();

            DataObject <OutputFileData> data = fileWorker.ReadDataFile(finalOutputFile);

            _logger.Info("Finished one iteration of phase one.");
            return(new FileObject(fileDeleter, data));
        }