コード例 #1
0
ファイル: TestsService.cs プロジェクト: kvasnyk/CILantro
        public async Task <string> GenerateOutput(Guid testId, GenerateOutputBindingModel model)
        {
            var test = await GetTestAsync(testId);

            var testExePath = _paths.TestsData.Execs[test.Name].MainExePaths.Absolute;

            var processStartInfo = new ProcessStartInfo(testExePath)
            {
                RedirectStandardOutput = true,
                RedirectStandardInput  = true,
                RedirectStandardError  = true,
                WindowStyle            = ProcessWindowStyle.Hidden,
                CreateNoWindow         = true
            };

            var process = Process.Start(processStartInfo);

            await process.StandardInput.WriteAsync(model.Input);

            await process.StandardInput.FlushAsync();

            var output = await process.StandardOutput.ReadToEndAsync();

            if (!process.HasExited)
            {
                process.Kill();
            }

            return(output);
        }
コード例 #2
0
ファイル: TestsController.cs プロジェクト: kvasnyk/CILantro
 public async Task <string> GenerateOutputAsync([FromRoute] Guid testId, [FromBody] GenerateOutputBindingModel model)
 {
     return(await _testsService.GenerateOutput(testId, model));
 }