Example #1
0
        /*static List<Round> ReadRounds(Dictionary<String, Round> roundInfo)
         * {
         *  string roundsFileName = "NewRounds.txt";
         *  List<Round> rounds = new List<Round>();
         *  StreamReader reader = new StreamReader(roundsFileName);
         *  while (!reader.EndOfStream)
         *  {
         *      string s = reader.ReadLine();
         *      rounds.Add(roundInfo[s]);
         *  }
         *  reader.Close();
         *  return rounds;
         * }*/


        static void UpdateRound(Round round, Dictionary <String, String> ZJUers, List <Round> tour, List <Round> srm,
                                Dictionary <String, CoderStat> stats, List <Record> ratingRecordList, List <Record> challengeInfoList,
                                List <Record> volRecordList, List <Record> divWinnerList, List <Record> onsiteList, Dictionary <CoderStat, List <Record> > coderInfo)
        {
            string      URL = "http://www.topcoder.com/tc?module=BasicData&c=dd_round_results&rd=" + round.roundID;
            XmlDocument xml = XmlHelper.LoadXML(URL, round.roundID + ".xml");

            if (xml == null)
            {
                return;
            }
            XmlNode      rootNode = xml.LastChild;
            List <Coder> div1 = new List <Coder>(), div2 = new List <Coder>();

            foreach (XmlNode node in rootNode.ChildNodes)
            {
                Coder coder = Coder.ParseCoderWithXML(node);
                if (coder != null && ZJUers.Keys.Contains(coder.handle))
                {
                    coder.id = ZJUers[coder.handle];
                    CoderStat coderStat = null;
                    Record    record    = new Record();
                    record.coder = coder;
                    record.round = round;
                    if (stats.Keys.Contains(coder.id))
                    {
                        coderStat = stats[coder.id];
                        coderStat.UpdateStat(coder, round);
                        coderInfo[coderStat].Add(record);
                    }
                    else
                    {
                        coderStat = CoderStat.NewCoderStat(coder, round);
                        stats.Add(coder.id, coderStat);
                        coderInfo[coderStat] = new List <Record>();
                        coderInfo[coderStat].Add(record);
                    }
                    if (coder.division == 1)
                    {
                        foreach (Coder other in div1)
                        {
                            coderStat.DualWith(coder, other);
                            stats[other.id].DualWith(other, coder);
                        }
                        div1.Add(coder);
                    }
                    else
                    {
                        foreach (Coder other in div2)
                        {
                            coderStat.DualWith(coder, other);
                            stats[other.id].DualWith(other, coder);
                        }
                        div2.Add(coder);
                    }
                    if (Convert.ToDouble(coder.challengePoints) > 0)
                    {
                        challengeInfoList.Add(record);
                    }
                    if (ratingRecordList.Count == 0 || coder.newRating > ratingRecordList.Last().coder.newRating)
                    {
                        ratingRecordList.Add(record);
                    }
                    if (coder.vol >= 600)
                    {
                        volRecordList.Add(record);
                    }
                    if (coder.divRank == 1)
                    {
                        divWinnerList.Add(record);
                    }
                    if (IsOnsite(round.name))
                    {
                        onsiteList.Add(record);
                    }
                }
            }
            if (div1.Count != 0 || div2.Count != 0)
            {
                div1.Sort(new Comparison <Coder>(Coder.CompareByRank));
                div2.Sort(new Comparison <Coder>(Coder.CompareByRank));
                HTMLGenerator.GenerateHTMLForRound(round, div1, div2);
                if (round.type.Equals("Single Round Match"))
                {
                    srm.Add(round);
                }
                else
                {
                    tour.Add(round);
                }
            }
        }