void ProcessSubmission(Submission s)
        {
            User    u = User.GetUser(s.UserID);
            Contest c = Contest.GetContest(Problem.GetProblem(s.ProblemID).ContestID);

            ProcessSubmission(s, u, new ContestRegistration() /*u.GetRegistration(c.ID)*/);             //TODO:очевидно
        }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //TODO: Test !IsPostBack - unsuccessful
            if (!IsPostBack)
            {
                cont = "document.getElementById('" + contestsDDL.ClientID + "').options[0].value";                 //contestID == 0 && problemID == 0
                prob = "0";

                if (contestID != 0)
                {
                    cont = String.Format("{0}:{1}", contestID, Contest.GetContest(contestID).Time);
                    prob = problemID.ToString();
                }

                ContestTime type = ContestTime.None;
                if (current)
                {
                    type |= ContestTime.Current;
                }
                if (past)
                {
                    type |= ContestTime.Past;
                }
                if (forthcoming)
                {
                    type |= ContestTime.Forthcoming;
                }

                foreach (Contest c in Contest.GetContests(type))
                {
                    contestsDDL.Items.Add(new ListItem(c.Name, String.Format("{0}:{1}", c.ID, c.Time)));
                }

                if (contestID != 0)
                {
                    contestsDDL.SelectedValue = cont;
                }
            }
            if (contestsDDL.Items.Count != 0)
            {
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "selc", "function SelectedContestChanged(arg, context){" +
                                                            Page.ClientScript.GetCallbackEventReference(this, "arg", "ProcessCallbackResult", "context", true) + ";" + fcalling + ";}", true);
                string script = "SelectedContestChanged(";
                if (contestID != 0)
                {
                    script += "\"" + cont + "\",'ddl');";
                }
                else
                {
                    script += cont + ",'ddl');";
                }

                Page.ClientScript.RegisterStartupScript(GetType(), "initproblemsDDL", script, true);
                contestsDDL.Attributes.Add("onchange", "javascript:SelectedContestChanged(this.options[this.selectedIndex].value,'ddl');");
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(GetType(), "check", "CheckContestLack()", true);
            }
        }
Example #3
0
        public void TestProblemAndContest()
        {
            DateTime begin = new DateTime(2007, 9, 13, 16, 0, 0);
            DateTime end   = new DateTime(2007, 10, 16, 16, 0, 0);
            Contest  c     = new Contest(begin, end, "To hell with the monkeys!");

            c.Store();
            c.Name      = "You gotta do what you gotta do";
            c.Beginning = c.Ending = DateTime.Now;
            c.Store();
            Contest temp = Contest.GetContest(c.ID);

            Assert.AreEqual(true, Contest.ValidateID(c.ID));
            Assert.AreEqual(false, Contest.ValidateID(34875893));

            Problem p = new Problem(c.ID, "A", "Knowledge brings fear", 1000, 2000, 3000, "input.txt", "output.txt");

            p.Statement     = new ProblemStatement(createMess("problem"));
            p.TesterParams  = new AcmTesterParameters(12, ".in", ".out");
            p.CheckerParams = new CheckerParameters();
            p.Store();

            Assert.AreNotEqual(null, p.Statement);
            Assert.AreNotEqual(null, p.TesterParams);
            Assert.AreNotEqual(null, p.CheckerParams);

            p.Name = "Apples";
            p.Store();
            Assert.AreEqual(true, Problem.ValidateID(p.ID));

            p.Remove();
            c.Remove();
        }
Example #4
0
        private void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                RequirementsProcessor rp = new RequirementsProcessor(GetType());
                rp.ProcessRequirements();
                //Page.Response.AddHeader("Refresh","300");
                if (rp.ContestIDDefined)
                {
                    selcon.ContestID = rp.ContestID;

                    Contest con = Contest.GetContest(rp.ContestID);
                    if (con.Time == ContestTime.Forthcoming)
                    {
                        throw new NeJudgeException("Нельзя просмотреть монитор будущего соревнования");
                    }
                    DateTime cur_time = TimeUtils.ZeroDateTime(DateTime.Now);
                    DateTime t_begin  = TimeUtils.ZeroDateTime(con.Beginning);
                    DateTime t_end    = TimeUtils.ZeroDateTime(con.Ending);

                    // Последнее обновление
                    TimeSpan dur       = TimeUtils.ZeroTimeSpan(t_end - t_begin);
                    TimeSpan elapsed   = TimeUtils.ZeroTimeSpan((cur_time - t_begin < dur) ? cur_time - t_begin : dur);
                    TimeSpan estimated = TimeUtils.ZeroTimeSpan(dur - elapsed);
                    if (elapsed >= dur)
                    {
                        st_label.InnerHtml += "<span style='color:red;font-size:small;display:block;'>(Соревнование окончено)</span>";
                    }
                    refresh.Text = TimeUtils.BeautifyTimeSpan(elapsed, false);
                    // Продолжительность соревнования
                    period.Text = TimeUtils.BeautifyTimeSpan(dur, false);
                    left.Text   = TimeUtils.BeautifyTimeSpan(estimated, false);


                    ContestTypeHandler h   = Factory.GetHandlerInstance(con.Type);
                    DataTable[]        dts = h.MonitorManager.Build(con.ID);
                    for (int i = 0; i < dts.Length; i++)
                    {
                        DataTable dt = dts[i];
                        monitorPH.Controls.Add(new LiteralControl(dt.TableName));
                        DataGrid gv = new DataGrid();
                        gv.Width                = new Unit(100.0, UnitType.Percentage);
                        gv.CellPadding          = 5;
                        gv.HeaderStyle.CssClass = "gridHeader";
                        gv.DataSource           = dt;
                        gv.DataBind();
                        h.MonitorManager.PaintDataGrid(gv, i, dt.Columns.Count - 3);
                        monitorPH.Controls.Add(gv);
                        if (i != dts.Length - 1)
                        {
                            monitorPH.Controls.Add(new LiteralControl("<br />"));
                        }
                    }
                }
                else
                {
                    info.Visible = false;
                }
            }
        }
Example #5
0
        protected void sendMessageB_Click(object sender, EventArgs e)
        {
            int     pid = selprob.ProblemID;
            Contest c   = Contest.GetContest(Problem.GetProblem(pid).ContestID);

            if (c.Time == ContestTime.Current)
            {
                if (Page.IsValid)
                {
                    Message m = null;
                    if (User.IsInRole("User"))
                    {
                        m = new Message(pid, User.Identity.Name, DateTime.Now, MessageType.Question, messageTB.Text, "");
                    }
                    else
                    {
                        m = new Message(pid, User.Identity.Name, DateTime.Now, MessageType.Clarification, "", messageTB.Text);
                    }
                    m.Store();
                    Response.Redirect(UrlRenderer.RenderQuestionsUrl(Problem.GetProblem(pid).ContestID));
                }
            }
            else
            {
                throw new NeJudgeInvalidParametersException("pid");                 //"—оревнование либо закончилось, либо ещЄ не начиналась."
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                RequirementsProcessor rp = new RequirementsProcessor(GetType());
                rp.ProcessRequirements();

                if (rp.ContestIDDefined)
                {
                    selcon.Visible = false;
                    Contest t = Contest.GetContest(rp.ContestID);
                    if (!Page.User.IsInRole("Administrator") && t.Time == ContestTime.Forthcoming)
                    {
                        throw new NeJudgeInvalidParametersException("problemID");
                    }
                    //"Соревнование, которое вы хотите просмотреть, ещё не началось. Попробуйте позже."
                    problemsPH.Controls.Add(new LiteralControl("<div align='center'><h1 style='color:#418ade;'>" + t.Name + "</h1></div>"));
                    foreach (Problem p in Problem.GetProblems(t.ID))
                    {
                        problemsPH.Controls.Add(new LiteralControl("<hr/>"));
                        ProblemView pv = (ProblemView)LoadControl("~/UC/problemview.ascx");
                        pv.ProblemID = p.ID;
                        problemsPH.Controls.Add(pv);
                        problemsPH.Controls.Add(new LiteralControl("<br/>"));
                    }
                }
                else
                {
                    problemsPH.Visible = false;
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ProblemIDValidator pv = new ProblemIDValidator();
                pv.Process();

                if (pv.ParameterDefined)
                {
                    selprob.Visible  = false;
                    goButton.Visible = false;
                    Problem p = Problem.GetProblem(pv.ValidatedValue);
                    Contest t = Contest.GetContest(p.ContestID);

                    if (!Page.User.IsInRole("Administrator") && t.Time == ContestTime.Forthcoming)
                    {
                        throw new NeJudgeInvalidParametersException("problemID");
                    }
                    //"Соревнование, задачу с которого вы хотите просмотреть, ещё не началось. Попробуйте позже."
                    problemView.ProblemID = p.ID;
                }
                else
                {
                    problemView.Visible = false;
                }
            }
        }
Example #8
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            Problem p = Problem.GetProblem(selprob.ProblemID);

            if (Contest.GetContest(p.ContestID).Time == ContestTime.Current)
            {
                if (Page.IsValid)
                {
                    Submission s = new Submission(p.ID, (sourceTextBox.Text.Trim() != "") ? sourceTextBox.Text.Trim():
                                                  Encoding.UTF8.GetString(file.FileBytes), User.Identity.Name,
                                                  languageDropDownList.SelectedValue, DateTime.Now);
                    s.Store();

                    /*try
                     * {
                     *      INeTester tst = (INeTester) Activator.GetObject(typeof (INeTester),
                     *              "tcp://localhost:8008/NeTester/Tester.rem");
                     *      tst.EnqueueSubmission(s.ID);
                     * }
                     * catch ( Exception ex )
                     * {
                     *      //TODO: testerFail.Message = "Проверка решения временно невозможна. Пожалуйста, повторите попытку позднее";
                     *      s.Outcome = OutcomeManager.CannotJudge;
                     *      s.Store();
                     * }*/
                    Response.Redirect("status.aspx?contestID=" + p.ContestID, false);
                }
            }
            else
            {
                throw new NeJudgeInvalidParametersException("problemID");
            }
            //"Соревнование либо закончилась, либо ещё не начиналось.";
        }
 public void RaiseCallbackEvent(string eventArgument)
 {
     result = "";
     try
     {
         string[] tmp = eventArgument.Split(':');
         if (tmp.Length == 2)
         {
             int contestID;
             if (int.TryParse(tmp[0], out contestID))
             {
                 result += "--Ћюбой--^ALL|";
                 ContestTypeHandler h = Factory.GetHandlerInstance(Contest.GetContest(contestID).Type);
                 foreach (string outcome in h.OutcomeManager.GetOutcomes())
                 {
                     result += string.Format("{0}^{1}|", h.OutcomeManager.GetPrintableValue(outcome), outcome);
                 }
             }
             else
             {
                 result = "ќшибка в обработке Callback^1";
             }
         }
     }
     catch { result = "ќшибка в обработке Callback^1"; }
 }
        public void EnqueueSubmission(int ID)
        {
            Submission sm = Submission.GetSubmission(ID);
            Contest    c  = Contest.GetContest(Problem.GetProblem(sm.ProblemID).ContestID);

            if (!testers.ContainsKey(c.ID))
            {
                testers[c.ID] = Factory.GetHandlerInstance(c.Type).TesterManager.CreateTester();
            }

            testers[c.ID].EnqueueSubmission(sm);
        }
Example #11
0
        public LightweightRow GetStatusInformation(int submissionID)
        {
            int contestID = GetContestIDBySubmissionID(submissionID);

            if (log.IsDebugEnabled)
            {
                string type = Contest.GetContest(contestID).Type;
                log.DebugFormat("Creating status for submission {0} (contest type {1})", submissionID, type);
            }

            return(GetHandler(contestID).StatusBuilder.GetInformation(submissionID));
        }
Example #12
0
        ContestTypeHandler GetHandler(int contestID)
        {
            if (!handlers.ContainsKey(contestID))
            {
                string type = Contest.GetContest(contestID).Type;
                log.DebugFormat("Creating handler for contest {0} with type {1}", contestID, type);
                handlers[contestID] = Factory.CreateContestHandler(type, contestID);

                //handlers[contestID].MonitorBuilder.Initialize();
            }

            return(handlers[contestID]);
        }
Example #13
0
        public static DataTable GetRows(int maximumRows, int startRowIndex, object filter)
        {
            SubmissionsFilter filt = (SubmissionsFilter)filter;
            int cid = filt.ContestID;

            filt.From = startRowIndex + 1;             //( page - 1 ) * statusGrid.PageSize + 1;
            filt.To   = startRowIndex + maximumRows;   //page * statusGrid.PageSize;

            DataTable dt = new DataTable();

            dt.Columns.Add("ID");
            dt.Columns.Add("Время");
            dt.Columns.Add("Команда");
            dt.Columns.Add("Задача");
            dt.Columns.Add("Язык");
            dt.Columns.Add("Статус");

            Contest            con = Contest.GetContest(cid);
            ContestTypeHandler h   = Factory.GetHandlerInstance(con.Type);

            string[] headers = h.StatusManager.GetHeaders();
            foreach (string s in headers)
            {
                dt.Columns.Add(s);
            }
            foreach (Submission s in Submission.GetSubmissions(filt))
            {
                DataRow dr = dt.NewRow();
                dr["ID"]      = s.ID;
                dr["Время"]   = TimeUtils.BeautifyTimeSpan(s.Time - con.Beginning, true);
                dr["Команда"] = User.GetUser(s.UserID).Name;
                dr["Задача"]  = String.Format("<a href='{0}'>{1}</a>", UrlRenderer.RenderProblemUrl(s.ProblemID),
                                              Problem.GetProblem(s.ProblemID).ShortName);
                dr["Язык"]   = Language.GetLanguage(s.LanguageID).Name;
                dr["Статус"] = h.OutcomeManager.GetPrintableValue(s.Outcome);

                string[] ins = h.StatusManager.GetInfo(s);
                for (int i = 0; i < headers.Length; i++)
                {
                    dr[i + 6] = ins[i];
                }
                dt.Rows.Add(dr);
            }
            return(dt);
        }
        public DataTable[] Build(int contestID)
        {
            contest = Contest.GetContest(contestID);
            data    = new Dictionary <string, UserData>();
            SubmissionsFilter f = new SubmissionsFilter(contestID);

            foreach (Submission s in Submission.GetSubmissions(f))
            {
                if (Problem.GetProblem(s.ProblemID).ContestID == contestID)
                {
                    ProcessSubmission(s);
                }
            }
            DataTable[] dts = new DataTable[] { FormatMonitor(contest), FormatStatistics(contest) };
            dts[0].TableName = "Монитор";
            dts[1].TableName = "Статистика";
            return(dts);
        }
Example #15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                RequirementsProcessor rp = new RequirementsProcessor(GetType());
                rp.ProcessRequirements();

                if (rp.ProblemIDDefined)
                {
                    selprob.ProblemID = rp.ProblemID;

                    Problem p = Problem.GetProblem(rp.ProblemID);
                    Contest t = Contest.GetContest(p.ContestID);

                    if (!Page.User.IsInRole("Administrator") && t.Time == ContestTime.Forthcoming)
                    {
                        throw new NeJudgeInvalidParametersException("problemID");
                    }
                    //"Соревнование, задачу с которого вы хотите просмотреть, ещё не началось. Попробуйте позже."
                    problemView.ProblemID = p.ID;
                    #region Возня со ссылками

                    InitLinks(rp.ProblemID);
                    if (Page.User.IsInRole("Administrator"))
                    {
                        editHL.Visible = true;
                        HideLinks();
                    }
                    else
                    {
                        if (Page.User.IsInRole("Anonymous") || t.Time == ContestTime.Past)
                        {
                            HideLinks();
                        }
                    }

                    #endregion
                }
                else
                {
                    problemTable.Visible = false;
                }
            }
        }
Example #16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ContestIDValidator cv = new ContestIDValidator();
                cv.Process();

                if (cv.ParameterDefined)
                {
                    if (Contest.GetContest(cv.ValidatedValue).Time == ContestTime.Forthcoming && !Page.User.IsInRole("Administrator"))
                    {
                        throw new NeJudgeInvalidParametersException("contestID");
                    }
                    //Hide("Ёто соревнование начнетс¤ через " + HtmlFunctions.BeautifyTimeSpan(db.GetContest(tid).Beginning - DateTime.Now, false) + ". —ейчас задачи посмотреть нельз¤.");

                    #region —сылочки (Visible в зависимости от роли)

                    statHL.NavigateUrl  = UrlRenderer.RenderStatusUrl(cv.ValidatedValue);
                    quesHL.NavigateUrl  = UrlRenderer.RenderQuestionsUrl(cv.ValidatedValue);
                    monHL.NavigateUrl   = UrlRenderer.RenderMonitorUrl(cv.ValidatedValue);
                    editHL.NavigateUrl  = UrlRenderer.RenderEditContestUrl(cv.ValidatedValue);
                    printHL.NavigateUrl = UrlRenderer.RenderPrintContestUrl(cv.ValidatedValue);

                    if (Page.User.IsInRole("Anonymous"))
                    {
                        statHL.Visible = false;
                        quesHL.Visible = false;
                    }
                    if (Page.User.IsInRole("Administrator"))
                    {
                        editHL.Visible = true;
                    }

                    #endregion
                }
                else
                {
                    monHL.Visible   = false;
                    statHL.Visible  = false;
                    quesHL.Visible  = false;
                    printHL.Visible = false;
                }
            }
        }
Example #17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.User.IsInRole("Anonymous"))
            {
                throw new NeJudgeSecurityException("User, Administrator, Judge");
            }
            if (!IsPostBack)
            {
                //Page.Response.AddHeader("Refresh", "90");
                RequirementsProcessor rp = new RequirementsProcessor(GetType());
                rp.ProcessRequirements();

                /*SubmissionsFilter*/ f = new SubmissionsFilter(0);
                if (rp.OutcomeDefined)
                {
                    f.Outcome = rp.Outcome;
                }
                f.UserID = (rp.UserIDDefined && User.IsInRole("Judge")) ? rp.UserID : User.Identity.Name;

                if (rp.ContestIDDefined)
                {
                    if (Contest.GetContest(rp.ContestID).Time == ContestTime.Forthcoming && !Page.User.IsInRole("Judge"))
                    {
                        throw new NeJudgeSecurityException("Ќевозможно просмотреть submissions будущего соревновани¤");
                    }

                    f.ContestID = rp.ContestID;
                    f.ProblemID = (rp.ProblemIDDefined) ? rp.ProblemID : 0;
                    int page;
                    int.TryParse(Request.QueryString["page"], out page);
                    statusGV.PageIndex = (page >= 1) ? page - 1 : 0;
                }
                else
                {
                    statusGV.Visible = false;
                }

                filter.Filter = f;
                //Context.Items["filter"] = f;
            }
        }
Example #18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!User.IsInRole("Judge") && !User.IsInRole("User"))
            {
                throw new NeJudgeSecurityException("User, Judge");
            }
            if (!IsPostBack)
            {
                RequirementsProcessor rp = new RequirementsProcessor(GetType());
                rp.ProcessRequirements();

                //Page.Response.AddHeader("Refresh", "90");
                MessagesFilter mf = new MessagesFilter(rp.ContestIDDefined?rp.ContestID:0, MessageType.Question);
                if (rp.UserIDDefined && User.IsInRole("Judge"))
                {
                    mf.UserID = rp.UserID;
                }
                mf.RequiredEmptyJuryMessage =
                    Request.QueryString["answered"] == null ||
                    Request.QueryString["answered"].ToLower() != "true";
                if (rp.ContestIDDefined)
                {
                    if (Contest.GetContest(rp.ContestID).Time == ContestTime.Forthcoming)
                    {
                        throw new NeJudgeInvalidParametersException("contestID", "Нельзя просмотреть вопросы будущего соревнования");
                    }

                    mf.ContestID   = rp.ContestID;
                    mf.ProblemID   = (rp.ProblemIDDefined) ? rp.ProblemID : 0;
                    selmess.Filter = mf;

                    questionsGV.Columns[6].Visible = User.IsInRole("Judge");
                    Bind();
                }
                else
                {
                    questionsGV.Visible = false;
                    selmess.Filter      = mf;
                }
            }
        }
Example #19
0
        protected void Page_Load(object sender, EventArgs e)
        {
            RequirementsProcessor rp = new RequirementsProcessor(GetType());

            rp.ProcessRequirements();

            if (rp.SubmissionIDDefined)
            {
                Submission      sm  = Submission.GetSubmission(rp.SubmissionID);
                ITestLogManager itm =
                    Factory.GetHandlerInstance(
                        Contest.GetContest(Problem.GetProblem(sm.ProblemID).ContestID).Type
                        ).TestLogManager;

                TestLogGrid         = itm.BuildTestLogGrid(sm);
                TestLogGrid.Visible = true;
            }
            else
            {
                TestLogGrid.Visible = false;
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         RequirementsProcessor rp = new RequirementsProcessor(GetType());
         rp.ProcessRequirements();
         if (rp.ModeDefined)
         {
             if (rp.Mode == "edit")
             {
                 contest = Contest.GetContest(rp.ContestID);
             }
             mv.SetActiveView(contestParams);
             monthsDDL.Attributes.Add("onchange", "SelectedMonthChanged(this.options[this.selectedIndex].value)");
         }
         else
         {
             menu.Visible  = false;
             mv.Visible    = false;
             saveB.Visible = false;
         }
     }
 }
Example #21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                RequirementsProcessor rp = new RequirementsProcessor(GetType());
                rp.ProcessRequirements();

                if (rp.ModeDefined)
                {
                    if (rp.Mode == "create")
                    {
                        if ((Contest.GetContest(rp.ContestID).Time & (ContestTime.Past | ContestTime.Current)) != 0)
                        {
                            throw new NeJudgeInvalidParametersException("contestID", "Нельзя создать задачу в текущем или прошедшем соревновании");
                        }

                        selprob.ContestID = rp.ContestID;
                        problem           = new Problem();
                        problem.ContestID = rp.ContestID;
                    }
                    else if (rp.Mode == "edit")
                    {
                        selprob.ProblemID = rp.ProblemID;
                        problem           = Problem.GetProblem(rp.ProblemID);
                    }
                    problem.LoadStatement();

                    mv.SetActiveView(contentsParams);
                }
                else
                {
                    mv.Visible    = false;
                    menu.Visible  = false;
                    saveB.Visible = false;
                }
            }
        }
        public DataGrid BuildTestLogGrid(Submission subm)
        {
            Contest con = Contest.GetContest(Problem.GetProblem(subm.ProblemID).ContestID);

            oMan = Factory.GetHandlerInstance(con.Type).OutcomeManager;

            DataTable dt = new DataTable();

            dt.Columns.Add("№ теста");
            dt.Columns.Add("Результат");
            dt.Columns.Add("Комментарий чекера");
            dt.Columns.Add("Время работы");
            dt.Columns.Add("Память");

            subm.LoadLog();
            for (int i = 0; i < subm.Log.TestCollection.Count; ++i)
            {
                DataRow dr = dt.NewRow();
                dr[0] = i;
                dr[1] = FormatResult(subm.Log.TestCollection[i].RunResult,
                                     subm.Log.TestCollection[i].CheckStatus);
                dr[2] = subm.Log.TestCollection[i].CheckerComment;
                dr[3] = subm.Log.TestCollection[i].RunResult.TimeWorked;
                dr[4] = subm.Log.TestCollection[i].RunResult.MemoryUsed;
                dt.Rows.Add(dr);
            }

            DataGrid ret = new DataGrid();

            ret.Width                = new Unit(100.0, UnitType.Percentage);
            ret.CellPadding          = 5;
            ret.HeaderStyle.CssClass = "gridHeader";
            ret.DataSource           = dt;
            ret.DataBind();

            return(ret);
        }