Ejemplo n.º 1
0
 public static void InitializeClient()
 {
     ApiClient   = new HttpClient();
     path        = Generator.GenerateCppFile();
     compilePath = CompilerCpp.CompileCppFile(path);
     word        = ProgramRunner.RunProgram(compilePath);
 }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 /// <param name="args">The command-line arguments.</param>
 public static void Main(string[] args)
 {
     var programRunner = new ProgramRunner(
         ActionToRun,
         ServiceName,
         GetServiceToRun);
     programRunner.RunProgram(args);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        /// <param name="args">The command-line arguments.</param>
        public static void Main(string[] args)
        {
            var logger = Bootstrapper.Resolve<ILogger>();
            logger.Info("Starting Windows service.");
            var programRunner = new ProgramRunner(
                TheAction,
                ServiceName,
                GetServiceToRun);

            try
            {
                programRunner.RunProgram(args);
            }
            catch (Exception e)
            {
                logger.Error(e, "Unhandled exception in Windows service.");
            }

            logger.Info("Stopping Windows service.");
        }
Ejemplo n.º 5
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));
        }