コード例 #1
0
        /// <summary>
        /// 评测此JudgeTask
        /// </summary>
        private void Judge(JudgeContext context)
        {
            JudgeTask task = context.Task;

            ITaskSubmitter submitter = FetcherFactory.CreateTaskSubmitter();

            try
            {
                UpdateTestData(context);

                using (BaseJudger judger = JudgerFactory.Create(context))
                {
                    LogStartJudgeTask(task.SubmitId);
                    judger.Judge();
                }

                LogJudgeResult(context.Result);
            }
            catch (Exception ex) //判题失败
            {
                LogJudgeFailed(ex, task.SubmitId);
                context.Result = CreateFailedJudgeResult(context, ex.ToString());
                throw ex;
            }
            finally
            {
                submitter.Submit(context);
            }
        }
コード例 #2
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;
            }
        }
コード例 #3
0
        private void UpdateTestData(JudgeContext context)
        {
            JudgeTask task = context.Task;

            // 检查测试数据是否为最新
            if (!TestDataManager.CheckData(task.ProblemId, task.DataVersion))
            {
                LogInvalidTestData(task.ProblemId);

                ITestDataFetcher fetcher = FetcherFactory.CreateTestDataFetcher();
                TestDataManager.WriteTestData(task.ProblemId, fetcher.Fetch(context));

                LogTestDataFetched(task.ProblemId);
            }
        }
コード例 #4
0
 /// <summary>
 /// NDisconf初始化
 /// 该方法理应在所有代码执行之前就被调用,否则可能会出现配置调用顺序错误
 /// </summary>
 /// <param name="path"></param>
 private async Task Init(string path)
 {
     this._setting       = this.GetSetting(path);
     this._fetcher       = FetcherFactory.GetFetcher(this._setting);
     this._preservations = new IPreservation[] {
         new FilePreservation(this._setting.Preservation),
         new ItemPreservation(this._setting.Preservation)
     };
     if (this._setting.EnableRemote)
     {
         await this._fallBackPolicy.ExecuteAsync(async() =>
         {
             await RecoverAllConfigs().ConfigureAwait(false);
         }, new Dictionary <string, object>
         {
             { "Action", "RecoverAllConfigs" },
         }).ConfigureAwait(false);
     }
 }
コード例 #5
0
 public void TestFetchAll()
 {
     var fetcher = FetcherFactory.Create(BrowserEnum.OPERA);
     var records = fetcher.FetchAll().ToList();
 }
コード例 #6
0
 /// <summary>
 /// 评测服务
 /// </summary>
 public JudgeService()
 {
     _taskFetcher        = FetcherFactory.CreateTaskFetcher();
     _workTimer          = new Timer(Config.TaskFetchInterval);
     _workTimer.Elapsed += OnWork;
 }