Exemple #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 static string CellToHtml(LightweightCell cell)
        {
            if (cell is PlaintextCell)
            {
                PlaintextCell cur = (PlaintextCell)cell;
                return(FormatText(cur.Text, cur.Kind, CssHelper.GenericPositiveCssClass, CssHelper.GenericNegativeCssClass));
            }
            else if (cell is HyperlinkCell)
            {
                HyperlinkCell cur = (HyperlinkCell)cell;
                int           id  = cur.LinkObjectID;
                string        url = string.Empty;

                switch (cur.LinkType)
                {
                case HyperlinkCell.LinkObjectType.Contest:
                    url = UrlRenderer.RenderContestUrl(id);
                    break;

                case HyperlinkCell.LinkObjectType.Monitor:
                    url = UrlRenderer.RenderMonitorUrl(id);
                    break;

                case HyperlinkCell.LinkObjectType.Problem:
                    url = UrlRenderer.RenderProblemUrl(id);
                    break;

                case HyperlinkCell.LinkObjectType.Submission:
                    url = UrlRenderer.RenderTestlogUrl(id);
                    break;

                default:
                    throw new ArgumentException(string.Format("Invalid link object type {0}", cur.LinkType));
                }

                return(string.Format("<a href='{0}'>{1}</a>", HttpContext.Current.Request.MapPath(url), cur.Text));
            }
            else if (cell is OutcomeInfoCell)
            {
                OutcomeInfoCell cur = (OutcomeInfoCell)cell;

                return(FormatText(cur.Info.PrintableValue, cur.Info.Kind, CssHelper.GenericPositiveCssClass,
                                  CssHelper.GenericNegativeCssClass));
            }
            else if (cell is MonitorCell)
            {
                MonitorCell cur = (MonitorCell)cell;

                string ret = FormatText(cur.Text, cur.Kind, CssHelper.MonitorPositiveCssClass,
                                        CssHelper.MonitorNegativeCssClass);

                if (cur.ShowTime)
                {
                    ret += string.Format("<span class='{0}'>{1}</span>", CssHelper.TimeSpanCssClass,
                                         TimeUtils.BeautifyTimeSpan(cur.Time, true));
                }

                return(ret);
            }
            else
            {
                throw new ArgumentException(string.Format("Invalid cell type {0}", cell.GetType()));
            }
        }