Esempio n. 1
0
        public bool DisplayFoundCalendar(bool bModal)
        {
            _Daddy.UpdateHttpDefaultWebProxy();
            String owner = ConfigurationManager.AppSettings["owner"];

            // On checke que les L/MDP soient corrects
            // Et on récupère les cookies au passage
            CookieContainer cookieJar = _Daddy.CheckGCAccount(true, false);

            if (cookieJar == null)
            {
                return(false);
            }

            _Daddy._ThreadProgressBarTitle = _Daddy.GetTranslator().GetString("LblFetchingProgressInfoMsg");
            _Daddy.CreateThreadProgressBar();
            string result = _Daddy.GetCacheHTMLFromClientImpl("https://www.geocaching.com/my/logs.aspx?s=1&lt=2", cookieJar);


            // On extrait la table
            result = MyTools.GetSnippetFromText("<table", "</table>", result);

            // Chaque <tr est un found it
            List <String> founds = MyTools.GetSnippetsFromText("<tr", "</tr>", result);

            // on parcourt chaque foundit
            Dictionary <DateTime, int> date_founds = new Dictionary <DateTime, int>();

            foreach (String bloc in founds)
            {
                // on splitte en <td
                List <String> cols = MyTools.GetSnippetsFromText("<td>", "</td>", bloc);

                // 2 : date
                String date = cols[2];
                date = MyTools.CleanString(date);
                DateTime ddate;
                if (DateTime.TryParse(date, out ddate) == true)
                {
                    ddate = new DateTime(ddate.Year, ddate.Month, ddate.Day);
                    if (date_founds.ContainsKey(ddate))
                    {
                        date_founds[ddate] = date_founds[ddate] + 1;
                    }
                    else
                    {
                        date_founds.Add(ddate, 1);
                    }
                }
            }
            _Daddy.KillThreadProgressBar();

            FoundCalendar cal = new FoundCalendar(date_founds);

            cal.Icon = _Daddy.Icon;
            if (bModal)
            {
                cal.ShowDialog();
            }
            else
            {
                cal.Show();
            }
            return(true);
        }