private void Page_Load(object sender, EventArgs e) { if (!BaseDb.IsAdmin(Page.User)) { throw new NeJudgeSecurityException("Administrator"); } if (!IsPostBack) { try { pid = int.Parse(Request.QueryString["pid"]); } catch { pid = -1; } try { tid = int.Parse(Request.QueryString["tid"]); } catch { tid = -1; } BaseDb db = DbFactory.ConstructDatabase(); if (db.CheckPid(pid)) { tid = db.GetTid(pid); Problem p = db.GetProblem(pid); problemNameTextBox.Text = Server.HtmlDecode(p.Name); problemTextTextBox.Text = Server.HtmlDecode(p.Text); inputFormatTextBox.Text = Server.HtmlDecode(p.InputFormat); outputFormatTextBox.Text = Server.HtmlDecode(p.OutputFormat); inputSampleTextbox.Text = Server.HtmlDecode(p.InputSample); outputSampleTextbox.Text = Server.HtmlDecode(p.OutputSample); authorTextBox.Text = Server.HtmlDecode(p.Author); } else if (db.CheckTid(tid)) { pid = -1; finishButton.Text = "Добавить задачу"; if (db.GetContest(tid).Old) { throw new NeJudgeInvalidParametersException("tid"); } } else { throw new NeJudgeInvalidParametersException("tid"); } db.Close(); } }
private void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { RequirementsProcessor rp = new RequirementsProcessor(GetType(), Context); rp.ProcessRequirements(); selprob.AddHidableControl(goButton); if (rp.PidDefined) { selprob.PID = rp.ProblemID; BaseDb db = DbFactory.ConstructDatabase(); Problem p = db.GetProblem(rp.ProblemID); Contest t = db.GetContest(p.TID); db.Close(); if (!BaseDb.IsAdmin(Page.User) && t.Future) { throw new NeJudgeInvalidParametersException("pid"); //"Соревнование, задачу с которого вы хотите просмотреть, ещё не началось. Попробуйте позже." } #region Возня со ссылками InitLinks(rp.ProblemID); if (BaseDb.IsAdmin(Page.User)) { Hyperlink2.Text = "Редактировать"; Hyperlink2.NavigateUrl = "../editproblem.aspx?pid=" + rp.ProblemID + "&ret=p"; Hyperlink3.Visible = Hyperlink4.Visible = false; } else { if (BaseDb.IsAnonymous(Page.User) || t.Old) { Hyperlink2.Visible = Hyperlink3.Visible = Hyperlink4.Visible = false; } } #endregion FillLiterals(p); } else { Hide(); } } }
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(); }