public virtual async Task CreateProblemAsync(ContestProblem entity) { Db.ContestProblems.Add(entity); await Db.SaveChangesAsync(); await FixProblemCountAsync(Contest.Id, true); }
public async Task CreateAsync(ContestProblem problem) { ContestProblems.Add(problem); await Context.SaveChangesAsync(); Context.RemoveCacheEntry($"`c{problem.ContestId}`probs"); }
public ContestProblemListItemData(ContestProblem problem) { Id = problem.Problem.Id; Order = problem.Order; Title = problem.Problem.Title; SolveCount = 0; // todo replace with actual value }
public async Task DeleteAsync(ContestProblem problem) { var(cid, pid) = (problem.ContestId, problem.ProblemId); await ContestProblems .Where(cp => cp.ContestId == cid && cp.ProblemId == pid) .BatchDeleteAsync(); Context.RemoveCacheEntry($"`c{problem.ContestId}`probs"); }
private void contestProblemsListView_DoubleClick(object sender, EventArgs e) { if (contestProblemsListView.SelectedItems.Count > 0) { ContestProblem contestProblem = SelectedContest.ContestProblems.Single(cp => cp.ProblemId == Int32.Parse(contestProblemsListView.SelectedItems[0].SubItems[0].Text)); SelectedContest.ContestProblems.Remove(contestProblem); DataContext.ContestProblems.DeleteOnSubmit(contestProblem); contestProblemsListView.SelectedItems[0].Remove(); } }
public void CreateSubmission(int contest_id, int problem_no, SubmissionFormData submission_data) { // important: submission_repository must be initialized using this.context SubmissionRepository submission_repository = new SubmissionRepository(context); Contest contest = context.Contests.Include(x => x.Problems).FirstOrDefault(x => x.Id == contest_id); if (contest.EndDate < DateTime.Now) { throw new InvalidOperationException("Can not create submission to contest that has ended"); } if (contest.StartDate > DateTime.Now) { throw new InvalidOperationException("Can not create submission to contest that has not started"); } ContestProblem contest_problem = contest.Problems.FirstOrDefault(x => x.Order == problem_no); Problem problem = contest_problem.Problem; submission_repository.OnSubmissionStatusChange += (Object sender, ExecutionResultEventArgs args) => { // the submission entry is updated by SubmissionRepository, // this handler only updates the contestant // replace with real user var contestant = context.Contestants.Include(x => x.Submissions).First(x => x.Contest.Id == contest_id); contestant.Penalty = contest_service.CalclatePenalty(contestant.Submissions); contestant.SolveCount = context.ContestProblems.Count(x => x.Submissions. Count(y => y.Submission.Status.Id == Verdict.Accepted) > 0); context.SaveChanges(); }; User submitter = context.Users.First(); Submission submission = submission_repository.CreateProblemSubmission(problem.Id, submission_data); ContestSubmission contest_submission = new ContestSubmission() { Submitter = context.Contestants.First(x => x.Contest.Id == contest_id && x.User.Id == submitter.Id), Problem = contest_problem, Submission = submission, }; contest.Submissions.Add(contest_submission); context.SaveChanges(); }
/// <summary> /// 拷贝构造函数 /// </summary> /// <param name="cp">拷贝源</param> public ContestProblem(ContestProblem cp, string tit, int time, int mem, bool ia, bool shared, bool alj) { AllowJudge = alj; AllowSubmit = cp.AllowSubmit; Color = cp.Color; ContestId = cp.ContestId; ProblemId = cp.ProblemId; Rank = cp.Rank; ShortName = cp.ShortName; Title = tit; TimeLimit = time; MemoryLimit = mem; Interactive = ia; Shared = shared; Score = cp.Score; }
private void addProblemButton_Click(object sender, EventArgs e) { Problem problem = DataContext.Problems.SingleOrDefault(p => p.UrlName == problemsComboBox.Text); if (problem == null) { MessageBox.Show("Could not find a problem with that short name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { contestProblemsListView.Items.Add(new ListViewItem(new[] { problem.ProblemId.ToString(), problem.Name })); ContestProblem contestProblem = new ContestProblem(); contestProblem.ProblemId = problem.ProblemId; SelectedContest.ContestProblems.Add(contestProblem); } }
public async Task <IActionResult> Add(int cid, ContestProblem model) { if (Problems.Any(cp => cp.ShortName == model.ShortName)) { ModelState.AddModelError("xys::duplicate", "Duplicate short name for problem."); } var probDetect = await Store.CheckAvailabilityAsync(cid, model.ProblemId, User); if (!probDetect.ok) { ModelState.AddModelError("xys::prob", probDetect.msg); } if (ModelState.IsValid) { var oldprobs = Problems; model.Color = "#" + model.Color.TrimStart('#'); model.ContestId = cid; await Store.CreateAsync(model); await HttpContext.AuditAsync("attached", $"{model.ProblemId}"); var newprobs = await Store.ListAsync(cid); var nowp = newprobs.SingleOrDefault(p => p.ProblemId == model.ProblemId); await Notifier.Create(cid, nowp); foreach (var @new in newprobs) { if (@new.Rank > nowp.Rank) { await Notifier.Update(cid, @new); } } StatusMessage = $"Problem {model.ShortName} saved."; return(RedirectToAction("Home", "Jury")); } else { return(Window(model)); } }
public virtual Task <Submission> SubmitAsync( string code, Language language, ContestProblem problem, Team team, IPAddress ipAddr, string via, string username, DateTimeOffset?time) { return(Polygon.Submissions.CreateAsync( code: code, language: language.Id, problemId: problem.ProblemId, contestId: Contest.Id, teamId: team.TeamId, ipAddr: ipAddr, via: via, username: username, time: time, fullJudge: Contest.RankingStrategy == CcsDefaults.RuleIOI)); }
public static List <ContestProblem> SelectByContestID(UInt32 ContestID) { string sql = @"select ContestProblemID, oj.OJID, oj.OJName, contestproblem.ProblemID, OJProblemID, contestproblem.Title, Problem.Title as PreTitle, contestproblem.Accepted, contestproblem.Submit, Description, Input, Output, SampleInput, SampleOutput, Hint, TimeLimit, MemoryLimit, OrderID, OJName from contestproblem join problem on contestproblem.ProblemID = problem.ProblemID join oj on oj.OJID = problem.OJID where ContestID = @ContestID order by ContestProblemID"; DataTable dt = SqlHelper.ExecuteDataTable(sql, new MySqlParameter("@ContestID", ContestID)); List <ContestProblem> contestproblems = new List <ContestProblem>(); foreach (DataRow dr in dt.Rows) { ContestProblem contestproblem = new ContestProblem(); contestproblem.ContestProblemID = (uint)dr["ContestProblemID"]; contestproblem.OJID = (uint)dr["OJID"]; contestproblem.OJName = (string)dr["OJName"]; contestproblem.ProblemID = (uint)dr["ProblemID"]; contestproblem.OJProblemID = (string)dr["OJProblemID"]; contestproblem.Title = (string)dr["Title"]; contestproblem.PreTitle = (string)dr["PreTitle"]; contestproblem.Accepted = (uint)dr["Accepted"]; contestproblem.Submit = (uint)dr["Submit"]; contestproblem.Description = (string)dr["Description"]; contestproblem.Input = (string)dr["Input"]; contestproblem.Output = (string)dr["Output"]; contestproblem.SampleInput = (string)dr["SampleInput"]; contestproblem.SampleOutput = (string)dr["SampleOutput"]; contestproblem.Hint = (string)dr["Hint"]; contestproblem.TimeLimit = (string)dr["TimeLimit"]; contestproblem.MemoryLimit = (string)dr["MemoryLimit"]; contestproblem.OrderID = (char)((uint)dr["OrderID"] + 'A'); contestproblems.Add(contestproblem); } return(contestproblems); }
public async Task <IActionResult> Edit(int cid, int pid, ContestProblem model) { if (!Problems.Any(cp => cp.ProblemId == pid)) { return(NotFound()); } if (Problems.Any(cp => cp.ShortName == model.ShortName && cp.ProblemId != pid)) { ModelState.AddModelError("xys::duplicate", "Duplicate short name for problem."); } if (!ModelState.IsValid) { return(Window(model)); } await Store.UpdateAsync(cid, pid, () => new ContestProblem { Color = "#" + model.Color.TrimStart('#'), AllowSubmit = model.AllowSubmit, ShortName = model.ShortName, Score = model.Score, }); await HttpContext.AuditAsync("updated", $"{pid}"); var newprobs = await Store.ListAsync(cid); foreach (var @new in newprobs) { await Notifier.Update(cid, @new); } StatusMessage = $"Problem {model.ShortName} saved."; return(RedirectToAction("Home", "Jury")); }
public static async Task <AnalysisTwoModel> AnalysisAsync( ISubmissionStore store, Data.Contest contest, ContestProblem prob, IReadOnlyDictionary <int, (string, string)> cls)
private AnalysisTwoModel(int time, ContestProblem cp) { TotalMinutes = time; VerdictStatistics = new int[12, time + 1]; Problem = cp; }
public static IFileInfo GetFile(this IProblemStore that, ContestProblem problem, string fileName) => that.GetFile(problem.ProblemId, fileName);
public override async Task CreateProblemAsync(ContestProblem entity) { await base.CreateProblemAsync(entity); Expire("Problems"); }
public ContestProblemDetailsData(ContestProblem problem) { this.problem_details = new ProblemDetails(problem.Problem); this.Order = problem.Order; }
public virtual Task Update(int cid, ContestProblem problem) => Task.CompletedTask;
public void ProcessRequest(HttpContext context) { try { context.Response.ContentType = "text/html"; string action = context.Request["action"]; HttpCookie cookie = context.Request.Cookies["GUID"]; if (cookie == null) { context.Response.Write("<script>alert('Log in First');window.location.href='index.ashx'</script>"); return; } uint uid = CookieService.SelectByGUID(cookie.Value); if (uid == 0) { context.Response.Write("<script>alert('Log in First');window.location.href='index.ashx'</script>"); return; } #region /* * ajax * */ if (action == "check") { context.Response.ContentType = "text/plain"; uint cid = (uint)Convert.ToUInt32(context.Request["cid"]); if (ContestUserService.Select(cid, uid)) { context.Response.Write("ok"); } else { context.Response.Write("no"); } } #endregion #region /* * ajax * */ else if (action == "checkcpsd") { context.Response.ContentType = "text/plain"; uint cid = (uint)Convert.ToUInt32(context.Request["cid"]); Contest contest = ContestService.SelectByID(cid); if (contest.Type == "private" && ContestUserService.Select(cid, uid) == false) { string pp = (string)context.Request["psd"]; if (pp == contest.Password) { ContestUserService.Insert(cid, uid); context.Response.Write("ok"); } else { context.Response.Write("no"); } } else { context.Response.Write("ok"); } return; } #endregion #region else if (action == "view") { uint cid = (uint)Convert.ToUInt32(context.Request["cid"]); Contest contest = ContestService.SelectByID(cid); if (contest.Type == "private" && ContestUserService.Select(cid, uid) == false) { context.Response.Write("<script>alert('No Permission')</script>"); return; } List <ContestProblem> contestproblems; if (contest.Status == "Pending") { contestproblems = new List <ContestProblem>(); } else { contestproblems = ContestProblemService.SelectByContestID(cid); } List <Solution> solsAsc = SolutionService.SelectByContestIDAsc(cid); List <Solution> solsDesc = new List <Solution>(solsAsc); solsDesc.Reverse(0, solsAsc.Count); /* * OverView * */ foreach (ContestProblem contestproblem in contestproblems) { List <Solution> msols = SolutionService.SelectByUserContestProblem(uid, contestproblem.ContestProblemID); if (msols.Count == 0) { contestproblem.Status = ""; continue; } contestproblem.Status = "No"; foreach (Solution solution in msols) { if (solution.IsAccepted) { contestproblem.Status = "Yes"; break; } } } /* * RankList * */ List <User> us = new List <User>(); foreach (Solution sol in solsAsc) { sol.IsVisible = (sol.UserID == uid); bool ok = false; foreach (User u in us) { if (sol.UserID == u.UserID) { ok = true; break; } } if (ok == false) { User user = new User(); user.UserID = sol.UserID; user.Username = sol.Username; user.Nickname = sol.Nickname; for (int i = 0; i < contestproblems.Count; ++i) { user.Items.Add(new Item()); } us.Add(user); } } foreach (Solution sol in solsAsc) { foreach (User u in us) { if (sol.UserID == u.UserID) { uint id = (uint)sol.OrderID - 'A'; if (u.Items[(int)id].IsSolved == false) { if (sol.IsAccepted) { u.Items[(int)id].IsSolved = true; u.Items[(int)id].Time = sol.SubmitTime - contest.StartTime; } else if (sol.IsJudged) { u.Items[(int)id].Penalty++; } } break; } } } foreach (User u in us) { foreach (Item item in u.Items) { if (item.IsSolved == true) { u.ProsSolved++; u.Timer += item.Time.Add(new TimeSpan(0, (int)(20 * item.Penalty), 0)); } } } for (int i = 0; i < contestproblems.Count; ++i) { TimeSpan FB = new TimeSpan(1000, 0, 0); foreach (User u in us) { if (u.Items[i].Time < FB && u.Items[i].Time != TimeSpan.Zero) { FB = u.Items[i].Time; } } foreach (User u in us) { if (u.Items[i].Time == FB) { u.Items[i].IsFirst = true; } } } us.Sort(); for (int i = 0; i < us.Count; ++i) { us[i].Rank = (uint)i + 1; } var Data = new { problems = contestproblems, contest = contest, solutions = solsDesc, users = us, ctime = (DateTime.UtcNow - DateTime.Parse("1970-1-1")).TotalMilliseconds }; string html = CommonHelper.RenderHtml("contestView.html", Data); context.Response.Write(html); } #endregion #region else if (action == "add") { List <OJ> OJs = OJService.SelectAll(); Contest contest = new Contest(); var Data = new { OJs = OJs, edit = false, Title = "", Time = "", Length = new TimeSpan(5, 0, 0), Dec = "", Psd = "" }; string html = CommonHelper.RenderHtml("contestAdd.html", Data); context.Response.Write(html); } #endregion #region else if (action == "csearch") { string mtitle = context.Request["mtitle"].ToString(); string mcreator = context.Request["mcreator"].ToString(); string mstatus = context.Request["mstatus"].ToString(); string mtype = context.Request["mtype"].ToString(); if (mtitle == "" && mcreator == "" && mstatus == "" && mtype == "") { context.Response.Redirect("ContestDo.ashx?action=list", false); } uint Page; uint IsLast = 0; uint npp = 20; if (context.Request["Page"] == null) { Page = 1; } else { Page = Convert.ToUInt32(context.Request["Page"]); } uint num = ContestService.CountByPara(mtitle, mcreator, mstatus, mtype); uint last = Math.Max(1, (num % npp == 0 ? num / npp : num / npp + 1)); if (Page == 0 || Page >= last) { Page = last; } if (Page == last) { IsLast = 1; } List <Contest> contests = ContestService.SelectPartByPara(mtitle, mcreator, mstatus, mtype, Page, npp); var Data = new { contests = contests, mlist = false, Page = Page, IsLast = IsLast, mTitle = mtitle, mCreator = mcreator, mStatus = mstatus, mType = mtype, csearch = true }; string html = CommonHelper.RenderHtml("contestList.html", Data); context.Response.Write(html); } #endregion #region else if (action == "list") { uint Page; uint IsLast = 0; uint npp = 20; if (context.Request["Page"] == null) { Page = 1; } else { Page = Convert.ToUInt32(context.Request["Page"]); } uint num = ContestService.CountAll(); uint last = Math.Max(1, (num % npp == 0 ? num / npp : num / npp + 1)); if (Page == 0 || Page >= last) { Page = last; } if (Page == last) { IsLast = 1; } List <Contest> contests = ContestService.SelectPart(Page, npp); var Data = new { contests = contests, mlist = false, Page = Page, IsLast = IsLast, mTitle = "", mCreator = "", mStatus = "", mType = "", csearch = false }; string html = CommonHelper.RenderHtml("contestList.html", Data); context.Response.Write(html); } #endregion #region else if (action == "mlist") { uint Page; uint IsLast = 0; uint npp = 20; if (context.Request["Page"] == null) { Page = 1; } else { Page = Convert.ToUInt32(context.Request["Page"]); } uint num = ContestService.CountByUID(uid); uint last = Math.Max(1, (num % npp == 0 ? num / npp : num / npp + 1)); if (Page == 0 || Page >= last) { Page = last; } if (Page == last) { IsLast = 1; } List <Contest> contests = ContestService.SelectPartByUID(Page, npp, uid); var Data = new { contests = contests, mlist = true, Page = Page, IsLast = IsLast }; string html = CommonHelper.RenderHtml("contestList.html", Data); context.Response.Write(html); } #endregion #region else if (action == "getptitle") { /* * ajax * */ context.Response.ContentType = "text/plain"; uint oid = (uint)Convert.ToUInt64(context.Request["oid"]); string pid = context.Request["pid"].ToString(); Problem problem = ProblemService.SelectByOJProblemID(oid, pid); if (problem.ProblemID == 0) { context.Response.Write("no"); } else { JavaScriptSerializer jss = new JavaScriptSerializer(); string json = jss.Serialize(problem); context.Response.Write(json); } } #endregion #region else if (action == "addnew") { string ctitle = (string)context.Request["ctitle"]; string stime = (string)context.Request["stime"]; string tlen = (string)context.Request["tlen"]; string psd = (string)context.Request["psd"]; string dcl = (string)context.Request["dcl"]; string pid = (string)context.Request["pid"]; string ptitle = (string)context.Request["ptitle"]; for (int i = 0; i < psd.Length; ++i) { if (IsValidChar(psd[i]) == false) { return; } } if (ctitle.Length > 80 || psd.Length > 24 || dcl.Length > 400) { return; } string p_stime = @"(\d\d):(\d\d):(\d\d) (\d\d)/(\d\d)/(\d\d\d\d)"; Regex r_stime = new Regex(p_stime); Match match = r_stime.Match(stime); int hh = Convert.ToInt32(match.Groups[1].ToString()); int mm = Convert.ToInt32(match.Groups[2].ToString()); int ss = Convert.ToInt32(match.Groups[3].ToString()); int MM = Convert.ToInt32(match.Groups[4].ToString()); int dd = Convert.ToInt32(match.Groups[5].ToString()); int yyyy = Convert.ToInt32(match.Groups[6].ToString()); DateTime StartTime = new DateTime(yyyy, MM, dd, hh, mm, ss); string[] strs = tlen.Split(':'); if (Convert.ToInt32(strs[0]) > 999 || Convert.ToInt32(strs[1]) > 23 || Convert.ToInt32(strs[2]) > 59 || Convert.ToInt32(strs[3]) > 59) { return; } if (Convert.ToInt32(strs[0]) <= 0 && Convert.ToInt32(strs[1]) <= 0 && Convert.ToInt32(strs[2]) <= 0 && Convert.ToInt32(strs[3]) <= 0) { return; } DateTime EndTime = StartTime.AddDays(Convert.ToInt32(strs[0])).AddHours(Convert.ToInt32(strs[1])) .AddMinutes(Convert.ToInt32(strs[2])).AddSeconds(Convert.ToInt32(strs[3])); string[] pros = pid.Split("`".ToCharArray()); string[] protitles = ptitle.Split("`".ToCharArray()); if (pros.Length > 15 || pros.Length <= 0 || protitles.Length > 15 || protitles.Length <= 0 || pros.Length != protitles.Length) { return; } foreach (string title in protitles) { if (title.Length <= 0 || title.Length > 80) { return; } } Contest contest = new Contest(); contest.Title = ctitle; contest.Type = psd.Length > 0 ? "private" : "public"; contest.Password = psd; contest.UserID = uid; contest.StartTime = StartTime; contest.EndTime = EndTime; contest.Declaration = dcl; contest.ProsNum = (uint)pros.Length; uint cid = ContestService.Insert(contest); ContestUserService.Insert(cid, uid); List <ContestProblem> conpros = new List <ContestProblem>(); for (int i = 0; i < pros.Length; ++i) { ContestProblem conpro = new ContestProblem(); conpro.ContestID = cid; conpro.ProblemID = Convert.ToUInt32(pros[i]); conpro.Title = protitles[i]; conpro.Accepted = 0; conpro.Submit = 0; conpro.OrderID = (char)(i + 'A'); conpros.Add(conpro); } ContestProblemService.Insert(conpros); context.Response.Redirect("ContestDo.ashx?action=mlist", false); return; } #endregion #region else if (action == "editold") { string ctitle = (string)context.Request["ctitle"]; string stime = (string)context.Request["stime"]; string tlen = (string)context.Request["tlen"]; string psd = (string)context.Request["psd"]; string dcl = (string)context.Request["dcl"]; string pid = (string)context.Request["pid"]; string ptitle = (string)context.Request["ptitle"]; for (int i = 0; i < psd.Length; ++i) { if (IsValidChar(psd[i]) == false) { return; } } if (ctitle.Length > 80 || psd.Length > 24 || dcl.Length > 400) { return; } string p_stime = @"(\d\d):(\d\d):(\d\d) (\d\d)/(\d\d)/(\d\d\d\d)"; Regex r_stime = new Regex(p_stime); Match match = r_stime.Match(stime); int hh = Convert.ToInt32(match.Groups[1].ToString()); int mm = Convert.ToInt32(match.Groups[2].ToString()); int ss = Convert.ToInt32(match.Groups[3].ToString()); int MM = Convert.ToInt32(match.Groups[4].ToString()); int dd = Convert.ToInt32(match.Groups[5].ToString()); int yyyy = Convert.ToInt32(match.Groups[6].ToString()); DateTime StartTime = new DateTime(yyyy, MM, dd, hh, mm, ss); string[] strs = tlen.Split(':'); if (Convert.ToInt32(strs[0]) > 999 || Convert.ToInt32(strs[1]) > 23 || Convert.ToInt32(strs[2]) > 59 || Convert.ToInt32(strs[3]) > 59) { return; } if (Convert.ToInt32(strs[0]) <= 0 && Convert.ToInt32(strs[1]) <= 0 && Convert.ToInt32(strs[2]) <= 0 && Convert.ToInt32(strs[3]) <= 0) { return; } DateTime EndTime = StartTime.AddDays(Convert.ToInt32(strs[0])).AddHours(Convert.ToInt32(strs[1])) .AddMinutes(Convert.ToInt32(strs[2])).AddSeconds(Convert.ToInt32(strs[3])); string[] pros = pid.Split("`".ToCharArray()); string[] protitles = ptitle.Split("`".ToCharArray()); if (pros.Length > 15 || pros.Length <= 0 || protitles.Length > 15 || protitles.Length <= 0 || pros.Length != protitles.Length) { return; } foreach (string title in protitles) { if (title.Length <= 0 || title.Length > 80) { return; } } Contest contest = new Contest(); contest.Title = ctitle; contest.Type = psd.Length > 0 ? "private" : "public"; contest.Password = psd; contest.UserID = uid; contest.StartTime = StartTime; contest.EndTime = EndTime; contest.Declaration = dcl; contest.ProsNum = (uint)pros.Length; uint cid = Convert.ToUInt32(context.Request["cid"]); contest.ContestID = cid; ContestService.Update(contest); ContestProblemService.DeleteByContestID(contest.ContestID); List <ContestProblem> conpros = new List <ContestProblem>(); for (int i = 0; i < pros.Length; ++i) { ContestProblem conpro = new ContestProblem(); conpro.ContestID = cid; conpro.ProblemID = Convert.ToUInt32(pros[i]); conpro.Title = protitles[i]; conpro.Accepted = 0; conpro.Submit = 0; conpro.OrderID = (char)(i + 'A'); conpros.Add(conpro); } ContestProblemService.Insert(conpros); context.Response.Redirect("ContestDo.ashx?action=mlist", false); } #endregion #region /* * ajax * */ else if (action == "getcompilers") { context.Response.ContentType = "text/plain"; uint oid = (uint)Convert.ToUInt64(context.Request["oid"]); List <Compiler> compilers = CompilerService.SelectByOJ(oid); string ret = ""; for (int i = 0; i < compilers.Count; ++i) { if (i > 0) { ret += "|"; } ret += compilers[i].CompilerID + "&" + compilers[i].Name; } context.Response.Write(ret); } #endregion #region else if (action == "submit") { uint conid = Convert.ToUInt32(context.Request["cid"]); Contest contest = ContestService.SelectByID(conid); if (contest.EndTime <= DateTime.Now || contest.StartTime >= DateTime.Now) { context.Response.Write("<script>alert('Contest is not Running');window.location.href='ContestDo.ashx?action=view&cid=" + conid + "'</script>"); return; } string pid = (string)context.Request["pselect"]; uint cid = Convert.ToUInt32(context.Request["cselect"]); string code = (string)context.Request["code"]; if (code.Length < 50 || code.Length > 65536) { context.Response.Write("<script>alert('The Code is Too Short or Too Long');window.location.href='ContestDo.ashx?action=view&cid=" + conid + "#submit'</script>"); return; } string[] strs = pid.Split('&'); Solution solution = new Solution(); solution.ContestProblemID = Convert.ToUInt32(strs[0]); solution.CompilerID = cid; solution.SourceCode = code; solution.IsJudged = false; solution.SubmitTime = DateTime.Now; solution.UserID = Convert.ToUInt32(uid); SolutionService.Insert(solution); ContestProblemService.UpdateSubmit(solution.ContestProblemID); Problem problem = ContestProblemService.SelectByContestProblemID(solution.ContestProblemID); ProblemService.UpdateSubmit(problem.ProblemID); context.Response.Redirect("ContestDo.ashx?action=view&cid=" + conid + "#status", false); } #endregion #region /* * ajax * */ else if (action == "code") { context.Response.ContentType = "text/plain"; uint id = Convert.ToUInt32(context.Request["sid"]); Solution solution = SolutionService.SelectBySolutionID(id); if (solution.SolutionID == 0) { context.Response.Write("no"); } else { context.Response.Write(solution.SourceCode); } } #endregion #region else if (action == "edit") { uint cid = (uint)Convert.ToUInt32(context.Request["cid"]); Contest contest = ContestService.SelectByID(cid); if (DateTime.Now >= contest.StartTime) { context.Response.Write("<script>alert('Contest is Running');window.location.href='ContestDo.ashx?action=mlist'</script>"); return; } if (contest.UserID != uid) { return; } else { List <ContestProblem> conpros = ContestProblemService.SelectByContestID(cid); foreach (ContestProblem conpro in conpros) { conpro.Description = conpro.Input = conpro.Output = conpro.SampleInput = conpro.SampleOutput = conpro.Hint = null; } List <OJ> OJs = OJService.SelectAll(); TimeSpan Length = contest.EndTime - contest.StartTime; var Data = new { OJs = OJs, edit = true, pros = conpros, ID = contest.ContestID, Title = contest.Title, Time = contest.StartTime.ToString("HH:mm:ss MM/dd/yyyy"), Length = contest.EndTime - contest.StartTime, Dec = contest.Declaration, Psd = contest.Password }; string html = CommonHelper.RenderHtml("contestAdd.html", Data); context.Response.Write(html); } } #endregion #region else { context.Response.Redirect("index.ashx", false); } #endregion } catch (Exception e) { LogService.Insert(0, e); context.Response.Redirect("index.ashx", false); } }