/// <summary> /// 获取题目数据 /// </summary> /// <param name="pid">题目ID</param> /// <param name="dataPath">题目数据路径</param> /// <param name="error">错误信息</param> /// <returns>获取是否成功</returns> public static Boolean TryGetProblemDataPath(String pid, out String dataPath, out String error) { dataPath = String.Empty; try { error = JudgeStatusManager.GetJudgeServerLoginStatus(); if (!String.IsNullOrEmpty(error)) { return(false); } Int32 problemID = pid.ToInt32(0); String path = ProblemDataManager.GetProblemDataRealPath(problemID); if (String.IsNullOrEmpty(path)) { error = "Problem data does not exist!"; return(false); } dataPath = path; return(true); } catch (System.Exception ex) { error = ex.Message; return(false); } }
/// <summary> /// 更新评测状态 /// </summary> /// <param name="sid">提交ID</param> /// <param name="pid">题目ID</param> /// <param name="username">用户名</param> /// <param name="result">评测结果</param> /// <param name="detail">出错信息</param> /// <param name="tcost">花费时间</param> /// <param name="mcost">花费内存</param> /// <param name="error">错误信息</param> /// <returns>是否更新成功</returns> public static Boolean TryUpdateSolutionStatus(String sid, String pid, String username, String result, String detail, String tcost, String mcost, out String error) { try { error = JudgeStatusManager.GetJudgeServerLoginStatus(); if (!String.IsNullOrEmpty(error)) { return(false); } SolutionEntity entity = new SolutionEntity() { SolutionID = Int32.Parse(sid), ProblemID = pid.ToInt32(0), UserName = username, Result = (ResultType)result.ToByte(0), TimeCost = tcost.ToInt32(0), MemoryCost = mcost.ToInt32(0) }; if (entity.Result > ResultType.Accepted)//评测失败 { Boolean hasProblemData = !String.IsNullOrEmpty(ProblemDataManager.GetProblemDataRealPath(entity.ProblemID)); //没有题目的不重新评测 Boolean canAutoRejudge = hasProblemData; Int32 triedTimes = 0; if (!_rejudgeTimesMap.TryGetValue(entity.SolutionID, out triedTimes)) { triedTimes = 0; } if (triedTimes > AUTO_REJUDGE_MAX_TIMES) { _rejudgeTimesMap.Remove(entity.SolutionID); canAutoRejudge = false; } else { _rejudgeTimesMap[entity.SolutionID] = triedTimes + 1; } entity.Result = canAutoRejudge ? ResultType.RejudgePending : ResultType.JudgeFailed; } SolutionManager.JudgeUpdateSolutionAllResult(entity, detail); return(true); } catch (System.Exception ex) { error = ex.Message; return(false); } }