Пример #1
0
        public ClassTableob(string html, DateTime begin, string studentnum = "10150111")
        {
            RandomColor rc = new RandomColor(studentnum);

            ClassTable = new List <List <Classob> >();
            TermBegin  = begin;
            if (ClassTable.Count == 0)
            {
                for (int i = 0; i < 8; i++)
                {
                    List <Classob> list = new List <Classob>();
                    ClassTable.Add(list);
                }
            }
            Regex regex = new Regex("<table[^>]*>.*</Table>");
            Match m     = regex.Match(html);

            regex = new Regex("<tr[^>]*>.*?</tr[^>]*>");
            MatchCollection mc        = regex.Matches(m.Value);
            string          teacher   = "";
            string          classname = "";
            string          date      = "";
            string          room      = "";
            Color           thiscolor = rc.Next();

            for (int trnum = 1; trnum < mc.Count; trnum++)
            {
                m = mc[trnum];
                string now = m.Value;
                if (Regex.IsMatch(now, "tr height=24"))
                {
                    thiscolor = rc.Next();
                    regex     = new Regex("<td[^>]*rowspan=(?<howmanytimes>\\d+)[^>]*>(?<class>[^<]*)</td><td[^>]*>\\d+</td><td[^>]*>(?<teacher>[^<]*)</td><td[^>]*>(?<date>[^<]*)</td><td [^>]*>(?<room>[^<]*)</td><td[^>]*>[^<]*</td><td[^>]*>[^<]*</td><td[^>]*>[^<]*</td></tr>");
                    m         = regex.Match(now);
                    GroupCollection gc = m.Groups;
                    teacher   = gc["teach"].Value;
                    classname = gc["class"].Value;
                    date      = gc["date"].Value;
                    room      = gc["room"].Value;
                    Classob nowclass = new Classob(teacher, classname, date, room, thiscolor);
                    ClassTable[nowclass.weekcode].Add(nowclass);
                }
                else
                {
                    regex = new Regex("<td[^>]*>(?<date>[^<]*)(<td[^>]*>(?<room>[^<]*))?");
                    m     = regex.Match(now);
                    GroupCollection gc = m.Groups;
                    date = gc["date"].Value;
                    if (!string.IsNullOrEmpty(gc["room"].Value))
                    {
                        room = gc["room"].Value;
                    }
                    Classob nowclass = new Classob(teacher, classname, date, room, thiscolor);
                    ClassTable[nowclass.weekcode].Add(nowclass);
                }
            }
            sort();
        }
Пример #2
0
        public List <List <Classob> > GetThisWeekClassTable(DateTime today)
        {
            List <List <Classob> > result = new List <List <Classob> >();
            int weeknum = getweeknum(today);

            for (int i = 0; i < ClassTable.Count; i++)
            {
                List <Classob> thisday = new List <Classob>();
                for (int k = 0; k < ClassTable[i].Count; k++)
                {
                    Classob now = ClassTable[i][k];
                    if (now.isToday(weeknum))
                    {
                        thisday.Add(now);
                    }
                }
                result.Add(thisday);
            }
            return(result);
        }