Example #1
0
        public void Updata()
        {
            INIFILE INIinfo = new INIFILE(Path, "info.ini");
            String URL = GetRoundURL();
            HTML.HTML html = new HTML.HTML(URL);
            List<Hashtable> info = html.GetDFSDocument();

            //获取name
            for (int i = 0; i < info.Count; i++)
            {
                Hashtable tmp = info[i];
                if ((string)tmp["Type"] == "TAG")
                    if ((string)tmp["Value"] == "option")
                        if (checkURL((string)tmp["value"]) == true)
                        {
                            INIinfo.WriteString("contest", "name", (string)info[i + 1]["Value"]);
                            break;
                        }
            }

            //获取DIV信息
            DivList.Clear();
            int op = 0;
            bool find = true;
            while (find)
            {
                find = false;
                for (; op < info.Count && find == false; op++)
                {
                    Hashtable tmp = info[op];
                    if ((string)tmp["Type"] == "TAG")
                        if ((string)tmp["Value"] == "a")
                            if ((string)tmp["name"] == "\"problem_stats\"")
                            {
                                DivList.Add(new Div(ID, string.Format("Div{0}", DivList.Count + 1)));
                                int CountTR = 0;
                                for (; op < info.Count && CountTR < 2; op++)
                                {
                                    tmp = info[op];
                                    if ((string)tmp["Type"] == "TAG")
                                        if ((string)tmp["Value"] == "tr")
                                            CountTR++;
                                }
                                int CountTD = 0;
                                for (; op < info.Count && CountTD < 6; op++)
                                {
                                    tmp = info[op];
                                    if ((string)tmp["Type"] == "TAG")
                                        if ((string)tmp["Value"] == "td")
                                            CountTD++;
                                }
                                //获取题目信息
                                while (true)
                                {
                                    tmp = info[op];
                                    if ((string)tmp["Type"] == "TAG"
                                        && (string)tmp["Value"] == "tr")
                                    {
                                        CountTD = 0;
                                        for (int i = op + 1; i < info.Count; i++)
                                        {
                                            tmp = info[i];
                                            if ((string)tmp["Value"] == "td")
                                                CountTD++;
                                            else if ((string)tmp["Value"] == "tr")
                                                break;
                                        }
                                        if (CountTD != 7) break;
                                        Problem problem = new Problem(ID, DivList.Last().Name, (string)info[op +6]["Value"]);
                                        String problemids = (string)info[op + 5]["href"];
                                        problem.SetID(problemids.Split('=', '&')[3]);
                                        problem.Updata();
                                        op += 21;
                                    }
                                    else
                                        break;
                                }
                                find = true;
                                op--;
                            }
                }
            }

            UpdataComplete = true;
            Load();
        }
Example #2
0
 public void SetID(string ID)
 {
     INIFILE inifile = new INIFILE(Path, "info.ini");
     inifile.WriteString("problem", "id", ID);
     LoadInfo();
 }
Example #3
0
 private void LoadInfo()
 {
     INIFILE info = new INIFILE(Path, "info.ini");
     Name = info.GetString("contest", "name", "null");
 }
Example #4
0
 private void LoadInfo()
 {
     INIFILE inifile = new INIFILE(Path, "info.ini");
     ID = inifile.GetString("problem", "id", "null");
 }