Beispiel #1
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);
        }
        private static void addFilterParams(SqlCommand comm, object customParam)
        {
            SubmissionsFilter filter = (SubmissionsFilter)customParam;

            if (filter.RequiredProblemID)
            {
                comm.Parameters.AddWithValue("@pid", filter.ProblemID);
            }
            if (filter.RequiredUserID)
            {
                comm.Parameters.AddWithValue("@uid", filter.UserID);
            }
            if (filter.RequiredOutcome)
            {
                comm.Parameters.AddWithValue("@ou", filter.Outcome.ToString());
            }
            comm.Parameters.AddWithValue("@cid", filter.ContestID);
        }
        public override Submission[] GetSubmissions(SubmissionsFilter filter)
        {
            string command = "SELECT * FROM (SELECT ROW_NUMBER() OVER (ORDER BY ID DESC)" +
                             " AS RowID,ID,ProblemID,UserID,LanguageID,Time,Outcome FROM (SELECT Submissions.ID,Submissions.ProblemID," +
                             "Submissions.UserID,Submissions.LanguageID,Submissions.Time,Submissions.Outcome " +
                             "FROM Submissions,Contests,Problems" +
                             " WHERE Submissions.ProblemID=Problems.ID AND Problems.ContestID = Contests.ID AND Contests.ID=@cid";

            if (filter.RequiredUserID)
            {
                command += " AND Submissions.UserID=@uid";
            }
            if (filter.RequiredOutcome)
            {
                command += " AND Submissions.Outcome=@ou";
            }
            if (filter.RequiredProblemID)
            {
                command += " AND Submissions.ProblemID = @pid";
            }

            command += ") AS T2) AS T";

            if (filter.RequiredPaging)
            {
                command += string.Format(" WHERE RowID between {0} and {1}", filter.From, filter.To);
            }
            else
            {
                command += " ORDER BY RowID DESC";
            }

            List <Submission> list = new List <Submission>();

            using (MsSqlQuery q = new MsSqlQuery(_connectionString))
                using (SqlDataReader rdr = q.ExecuteReader(command.ToString(), addFilterParams, filter))
                {
                    while (rdr.Read())
                    {
                        list.Add(FromReader(rdr));
                    }
                }
            return(list.ToArray());
        }
        public override int GetSubmissionsCount(SubmissionsFilter filter)
        {
            string command = "SELECT COUNT(*) FROM (SELECT Submissions.ID FROM Submissions,Contests,Problems" +
                             " WHERE Submissions.ProblemID=Problems.ID AND Problems.ContestID = Contests.ID AND Contests.ID=@cid";

            if (filter.RequiredUserID)
            {
                command += " AND Submissions.UserID=@uid";
            }
            if (filter.RequiredOutcome)
            {
                command += " AND Submissions.Outcome=@ou";
            }
            if (filter.RequiredProblemID)
            {
                command += " AND Submissions.ProblemID = @pid";
            }

            command += ") AS T2";

            using (MsSqlQuery q = new MsSqlQuery(_connectionString))
                return((int)q.ExecuteScalar(command, addFilterParams, filter));
        }
Beispiel #6
0
 public abstract int GetSubmissionsCount(SubmissionsFilter filter);
Beispiel #7
0
 public abstract Submission[] GetSubmissions(SubmissionsFilter filter);