Esempio n. 1
0
        private void GetUnitTimes(int wNumber)
        {
            try
            {
                var     webGet     = new HtmlWeb();
                DbStore ourDbStore = new DbStore();
                // load wccca page
                var document = webGet.Load("http://www.wccca.com/PITSv2/units.aspx?cn=" + wNumber);

                // Get all tables in the document
                HtmlNodeCollection tables = document.DocumentNode.SelectNodes("//table");

                // Iterate all rows in the first table
                HtmlNodeCollection rows = tables[0].SelectNodes(".//tr");
                //HtmlNode ourNode = tables[0].SelectSingleNode("//td").InnerText;

                for (int i = 0; i < rows.Count; ++i)
                {
                    // build a dictionary with all our values
                    Dictionary <int, string> unitTimes = new Dictionary <int, string>();

                    UnitTime ourUnitTime = new UnitTime();

                    // Iterate all columns in this row
                    HtmlNodeCollection cols = rows[i].SelectNodes(".//tr");



                    for (int j = 0; j < cols.Count; ++j)
                    {
                        unitTimes.Add(j, cols[j].InnerText);
                        ourDbStore.StoreUnitTime(unitTimes);
                    }

                    // write it to record

                    //unitTimes.Clear();
                }
            }
            catch (Exception getUnitTimesException)
            {
                Debug.WriteLine(getUnitTimesException.ToString());
            }
        }