Exemple #1
0
        /// <summary>
        /// 评测此JudgeTask
        /// </summary>
        private void Judge(JudgeTask task)
        {
            ITaskSubmitter submitter = FetcherFactory.CreateTaskSubmitter();

            try
            {
                // 检查测试数据是否为最新
                if (!TestDataManager.CheckData(task.ProblemID, task.DataVersion))
                {
                    ITestDataFetcher fetcher = FetcherFactory.CreateTestDataFetcher();
                    TestDataManager.WriteTestData(task.ProblemID, fetcher.Fetch(task.ProblemID));
                }

                JudgeResult result;
                using (MainJudger judger = new MainJudger(task))
                {
                    result = judger.Judge();
                }

                submitter.Submit(result);
            }
            catch (Exception ex)//判题失败
            {
                submitter.Submit(CreateFailedJudgeResult(task, ex.ToString()));
                throw ex;
            }
        }
        private void Judge(JudgeContext context)
        {
            JudgeTask      task      = context.Task;
            ITaskSubmitter submitter = AdapterFactory.CreateTaskSubmitter();

            try
            {
                UpdateTestData(context);

                using (BaseJudger judger = JudgerFactory.Create(context))
                {
                    LogStartJudgeTask(task.SubmitId);
                    judger.Judge();
                }
            }
            catch (ExpectedJudgeStopException)
            { }
            catch (Exception ex) // 判题失败
            {
                context.Result = CreateFailedJudgeResult(context, ex.ToString());
                throw;
            }
            finally
            {
                LogJudgeResult(context.Result);
                submitter.Submit(context);
            }
        }