예제 #1
0
        public bool ParseScore(String htmlData)
        {
            htmlData = htmlData.Replace(" ", "");
            MatchCollection m = Regex.Matches(htmlData,
                "<td[^>]*><div[^>]+>([^>]*<a[^>]*>)*([^<]+)(</a>[^>]*)*</div></td>",
                RegexOptions.Multiline | RegexOptions.IgnoreCase);
            int count = m.Count;
            if (count > 0)
            {
                Score tmp = new Score();
                for (int i = 0; i < count; i += 10)
                {
                    tmp.term = m[i].Groups[2].ToString().Trim();
                    tmp.cid = m[i + 1].Groups[2].ToString().Trim();
                    tmp.name = m[i + 2].Groups[2].ToString().Trim();
                    tmp.teacher = m[i + 3].Groups[2].ToString().Trim();
                    tmp.kind = m[i + 4].Groups[2].ToString().Trim();
                    tmp.credit = Convert.ToSingle(m[i + 5].Groups[2].ToString().Trim());
                    string hours = m[i + 6].Groups[2].ToString().Trim();
                    tmp.score = Convert.ToSingle(m[i + 7].Groups[2].ToString().Trim());
                    if (hours.EndsWith("周"))
                    {
                        hours = hours.Remove(hours.Length - 1, 1);
                        tmp.hours = Convert.ToInt32(hours) * 5;
                    }
                    else if (hours.EndsWith("次"))
                    {
                        hours = hours.Remove(hours.Length - 1, 1);
                        tmp.hours = Convert.ToInt32(hours);
                    }
                    else if (hours == "")
                        tmp.hours = 0;
                    else
                        tmp.hours = Convert.ToInt32(hours);

                    tmp.other = m[i + 8].Groups[2].ToString().Trim();
                    if (tmp.other == "补考")
                    {
                        tmp.name += "【补考】";
                    }
                    //if (ignore.ContainsKey(tmp.name))
                    //{
                    //    tmp.name += "【" +tmp.term+ "】";
                    //}
                    while (ignore.ContainsKey(tmp.name))
                    {
                        tmp.name += "【" + tmp.term + "】";
                    }
                    score.Add(tmp);
                    if (tmp.score == 0)
                        ignore.Add(tmp.name, true);
                    else
                        ignore.Add(tmp.name, false);
                }
                return true;
            }
            else
                return false;
        }
예제 #2
0
        public bool Load( String[] data )
        {
            Clear();
            bool other = false;
            foreach (string tmp in data)
            {
                if (tmp == "--------" || tmp == "")
                {
                    other = true;
                    continue;
                }

                if (other)
                {
                    is_important.Add(tmp, true);
                }
                else
                {
                    string[] vals = tmp.Split('#');
                    Score s = new Score();
                    s.cid = vals[0];
                    s.name = vals[1];
                    s.teacher = vals[2];
                    s.term = vals[3];
                    s.kind = vals[4];
                    s.credit = Convert.ToSingle(vals[5]);
                    s.hours = Convert.ToInt32(vals[6]);
                    s.score = Convert.ToSingle(vals[7]);
                    s.other = vals[8];
                    score.Add(s);
                    //ignore.Add(s.name, false);
                    if (s.score == 0)
                        ignore.Add(s.name, true);
                    else
                        ignore.Add(s.name, false);
                }
            }
            return true;
        }