コード例 #1
0
 private void UpdateSoftware(SoftwareInfo software)
 {
     software.Category = CategoryProvider.GetCategory(software);
     software.Source   = SourceProvider.GetSource(software);
     software.Build    = BuildProvider.GetBuild(software);
     software.Compiler = CompilerProvider.GetCompiler(software);
     software.Encoding = EncodingProvider.GetEncoding(software);
 }
コード例 #2
0
ファイル: Module.cs プロジェクト: fsfish/slipstream
        private Assembly CompileSourceFiles()
        {
            LoggerProvider.EnvironmentLogger.Info(String.Format(
                                                      "Compiling source files of the module [{0}]...", this.Name));

            var sourceFiles = new HashSet <string>();

            if (!string.IsNullOrEmpty(this.ProjectFile))
            {
                var projectParser = new DefaultProjectFileParser();
                var pfd           = projectParser.Parse(System.IO.Path.Combine(this.Path, this.ProjectFile));
                foreach (var sourceFile in pfd.SourceFilenames)
                {
                    sourceFiles.Add(System.IO.Path.Combine(this.Path, sourceFile));
                }
            }

            if (this.SourceFiles != null)
            {
                foreach (var file in this.SourceFiles)
                {
                    sourceFiles.Add(System.IO.Path.Combine(this.Path, file));
                }
            }

            //编译模块程序
            if (sourceFiles.Count > 0)
            {
                var compiler  = CompilerProvider.GetCompiler(this.SourceLanguage);
                var stopwatch = new Stopwatch();
                stopwatch.Start();
                var projectFilePath = System.IO.Path.Combine(this.Path, this.ProjectFile);
                var a = compiler.BuildProject(projectFilePath);
                stopwatch.Stop();
                var time = stopwatch.Elapsed;
                LoggerProvider.EnvironmentLogger.Info(String.Format("Elapsed time: [{0}]", time));
                LoggerProvider.EnvironmentLogger.Info(String.Format(
                                                          "The module [{0}] has been compiled successfully.", this.Name));
                return(a);
            }
            else
            {
                return(null);
            }
        }
コード例 #3
0
        public override async Task ExecuteAsync()
        {
            // 获取并锁定解答的详情。
            _sfull = await _client.Lock(_spush.Id);

            if (_sfull == null)
            {
                _log.InfoExt(() => $"Failed to lock {_spush.Id}, move next.");
                return;
            }
            await UpdateQuestionData();

            var           compiler = CompilerProvider.GetCompiler(_spush.Language);
            CompileResult asm      = compiler.Compile(_sfull.Source);

            if (asm.HasErrors)
            {
                await _client.Update(ClientJudgeModel.CreateCompileError(_spush.Id, asm.Output));

                return;
            }
            else
            {
                await _client.UpdateInLock(_spush.Id, SolutionState.Judging);
            }

            IEnumerable <QuestionData> datas;

            using (var db = new JudgerDbContext())
            {
                var dataIds = _sfull.QuestionDatas
                              .Select(x => x.Id).ToArray();
                datas = await db.FindDatasByIds(dataIds);
            }

            // Judging
            using (compiler)
            {
                await Judge(datas, asm, compiler.GetEncoding());
            }
        }
コード例 #4
0
        public override async Task ExecuteAsync()
        {
            _lockM = await _client.LockProcess2(_spush.Id);

            if (_lockM == null)
            {
                _log.InfoExt($"Failed to lock {_spush.Id}, move next.");
                return;
            }
            await UpdateQuestionProcess2Code();

            // _fullM 里面包含 评测进程 的源代码,因此它是 compiler1;
            // _lockM 里面包含 待评测进程 的源代码,因此它是 compiler2。
            using (var judgerCompiler = CompilerProvider.GetCompiler(_fullM.Language))
                using (var judgedCompiler = CompilerProvider.GetCompiler(_spush.Language))
                {
                    CompileResult res1 = judgerCompiler.Compile(_fullM.Code);
                    if (res1.HasErrors)
                    {
                        await _client.Update(ClientJudgeModel.CreateCompileError(_spush.Id, res1.Output)); // 评测代码 编译失败,属系统错误

                        return;
                    }

                    CompileResult res2 = judgedCompiler.Compile(_lockM.Source);
                    if (res2.HasErrors)
                    {
                        await _client.Update(ClientJudgeModel.CreateCompileError(_spush.Id, res2.Output)); // 待评测代码 编译失败,属用户错误

                        return;
                    }

                    await _client.UpdateInLock(_spush.Id, SolutionState.Judging);

                    await Judge(res1, res2, judgedCompiler.GetEncoding());
                }
        }