private void Page_Load(object sender, EventArgs e) { BaseDb db = DbFactory.ConstructDatabase(); if (db.CheckPid(pid)) { Problem p = db.GetProblem(pid); if (db.GetContest(p.TID).Future) { Hide("Соревнование, задачу с которого вы хотите просмотреть, ещё не началось. Попробуйте позже."); } else { nameLiteral.Text = "<h1> Задача " + p.ShortName + " ( #"+ pid + " ). "+ p.Name + "</h1>"; Limits l = DfTest.GetLimits(pid.ToString()); tlLiteral.Text += l.Time + " секунды"; mlLiteral.Text += l.Memory + " КБ"; olLiteral.Text += l.Output + " байт"; if (p.Text == "") { textLiteral.Visible = false; } else { textLiteral.Text += p.Text; } if (p.InputFormat == "") { infoLiteral.Visible = false; } else { infoLiteral.Text += p.InputFormat; } if (p.OutputFormat == "") { outfoLiteral.Visible = false; } else { outfoLiteral.Text += p.OutputFormat; } string str = ""; if (p.InputSample == "") { inexLiteral.Visible = false; } else { StringReader str_rdr = new StringReader(p.InputSample); while ((str = str_rdr.ReadLine()) != null) { inexLiteral.Text += str + "<br>"; } inexLiteral.Text += "</code>"; } if (p.OutputSample == "") { outexLiteral.Visible = false; } else { StringReader str_rdr2 = new StringReader(p.OutputSample); while ((str = str_rdr2.ReadLine()) != null) { outexLiteral.Text += str + "<br>"; } outexLiteral.Text += "</code>"; } if (p.Author == "") { authorLiteral.Visible = false; } else { authorLiteral.Text += p.Author; authorLiteral.Text += "<hr>"; } } } else { throw new NeJudgeInvalidParametersException("pid"); } db.Close(); }
private void Page_Load(object sender, EventArgs e) { fileContent.Visible = reportGrid.Visible = false; int sid = 0; string sstr = ""; try { sstr = Page.Request.QueryString["sid"]; sid = int.Parse(sstr); } catch (FormatException) { throw new NeJudgeInvalidParametersException("sid"); } catch (ArgumentNullException) { throw new NeJudgeInvalidParametersException("sid"); } BaseDb db = DbFactory.ConstructDatabase(); if (!db.CheckSid(sid)) { throw new NeJudgeInvalidParametersException("sid"); } string mode = Page.Request.QueryString["mode"]; if (mode == null) { throw new NeJudgeInvalidParametersException("mode"); } mode = mode.ToLower(); Submission s = db.GetSubmission(sid); if (mode == "comp-report") { fileContent.Visible = true; if (s.Result.Code == Result.WAIT || s.Result.Code == Result.RU) { ShowError("–ешение еще провер¤етс¤"); return; } if (!BaseDb.IsAdmin(Page.User)) { if (s.UID != db.GetUid(Page.User.Identity.Name) || s.Result.Code != Result.CE) { throw new NeJudgeSecurityException("Identity"); //TODO: срочно пределать } } string report = DfTest.GetReportFilename(sid.ToString()); ShowFile(report); } else if (mode == "error-report") { fileContent.Visible = true; if (s.UID != db.GetUid(Page.User.Identity.Name) || s.Result.Code != Result.FA) { throw new NeJudgeSecurityException("Identity"); } string errfile = Path.Combine( Path.Combine(Config.SubmissionsDirectory, sid.ToString()), "error.desc"); ShowFile(errfile); } else if (mode == "test-report") { } else { throw new NeJudgeInvalidParametersException("mode"); } }
private void Button1_Click(object sender, EventArgs e) { int pid = selprob.PID; using (BaseDb db = DbFactory.ConstructDatabase()) { int tid = db.GetTid(pid); if (db.GetContest(tid).Now) { if (Page.IsValid) { string extension = ""; switch (languageDropDownList.SelectedValue) { case "Pascal": extension = "pas"; break; case "C++": extension = "cpp"; break; case "C": extension = "c"; break; default: extension = "cpp"; break; } string temp = Path.GetTempFileName(); if (sourceTextBox.Text.Trim() != "") { StreamWriter sw = null; try { sw = new StreamWriter(temp); sw.WriteLine(sourceTextBox.Text.Trim()); } finally { if (sw != null) { sw.Close(); } } } else { if (fileBrowser.PostedFile != null) { fileBrowser.PostedFile.SaveAs(temp); } } int uid = db.GetUid(Page.User.Identity.Name); //TODO Language l = (Language)Enum.Parse(typeof(Language), extension, true); Submission s = new Submission(pid, uid, tid, DateTime.Now, l); int sid = db.AddSubmission(s); if (Directory.Exists(Path.Combine(Config.SubmissionsDirectory, sid.ToString()))) { Directory.Delete(Path.Combine(Config.SubmissionsDirectory, sid.ToString())); } Directory.CreateDirectory(Path.Combine(Config.SubmissionsDirectory, sid.ToString())); File.Move(temp, Path.Combine(Path.Combine( Config.SubmissionsDirectory, sid.ToString()), "sln." + extension)); //TODO:переделать DfTest dt = new DfTest(pid.ToString(), sid.ToString(), l.ToString()); Thread t = new Thread(new ThreadStart(dt.CheckSolution)); Response.Redirect("~/status.aspx?tid=" + tid, false); t.Start(); } } else { throw new NeJudgeInvalidParametersException("pid"); //"Соревнование либо закончилась, либо ещё не начиналось."; } } }
private void FillLiterals(Problem p) { nameLiteral.Text = "<h1> Задача " + p.ShortName + " ( #" + p.PID + " ). " + p.Name + "</h1>"; Limits l = DfTest.GetLimits(p.PID.ToString()); tlLiteral.Text += l.Time + " секунды"; mlLiteral.Text += l.Memory + " КБ"; olLiteral.Text += l.Output + " байт"; if (p.Text == "") { textLiteral.Visible = false; } else { textLiteral.Text += p.Text; } if (p.InputFormat == "") { infoLiteral.Visible = false; } else { infoLiteral.Text += p.InputFormat; } if (p.OutputFormat == "") { outfoLiteral.Visible = false; } else { outfoLiteral.Text += p.OutputFormat; } string str = ""; if (p.InputSample == "") { inexLiteral.Visible = false; } else { inexLiteral.Text += "<code>"; StringReader str_rdr = new StringReader(p.InputSample); while ((str = str_rdr.ReadLine()) != null) { inexLiteral.Text += str + "<br>"; } inexLiteral.Text += "</code>"; } if (p.OutputSample == "") { outexLiteral.Visible = false; } else { outexLiteral.Text += "<code>"; StringReader str_rdr2 = new StringReader(p.OutputSample); while ((str = str_rdr2.ReadLine()) != null) { outexLiteral.Text += str + "<br>"; } outexLiteral.Text += "</code>"; } if (p.Author == "") { authorLiteral.Visible = false; } else { authorLiteral.Text += p.Author; } }