/** * Put all data from given day into given table */ public static void collectDataforDay(DateTime dateTime, SQLiteConnection m_dbConnection) { string zeroMonth = dateTime.Month < 10 ? "0" : ""; string zeroDay = dateTime.Day < 10 ? "0" : ""; string date = zeroMonth + dateTime.Month + "/" + zeroDay + dateTime.Day + "/" + dateTime.Year; PdfReader reader; try { reader = new PdfReader("http://www.equibase.com/premium/eqbPDFChartPlus.cfm?RACE=A&BorP=P&TID=SAR&CTRY=USA&DT=" + date + "&DAY=D&STYLE=EQB"); } catch (Exception e) { Console.WriteLine("CAPTCHA TIME"); Console.ReadKey(); Console.ReadKey(); reader = new PdfReader("http://www.equibase.com/premium/eqbPDFChartPlus.cfm?RACE=A&BorP=P&TID=SAR&CTRY=USA&DT=" + date + "&DAY=D&STYLE=EQB"); } StringBuilder builder = new StringBuilder(); for (int x = 1; x <= reader.NumberOfPages; x++) { PdfDictionary page = reader.GetPageN(x); IRenderListener listener = new SBTextRenderer(builder); PdfContentStreamProcessor processor = new PdfContentStreamProcessor(listener); PdfDictionary pageDic = reader.GetPageN(x); PdfDictionary resourcesDic = pageDic.GetAsDict(PdfName.RESOURCES); processor.ProcessContent(ContentByteUtils.GetContentBytesForPage(reader, x), resourcesDic); } if (pages.Count != 0) { DataHandler handler = new DataHandler(dateTime, pages, m_dbConnection); Thread thread = new Thread(new ThreadStart(handler.extractPdfData)); thread.Start(); thread.Join(); reader.Dispose(); pages.Clear(); } else { // If there were no races on this particular day, simply skip it! :D Console.WriteLine("Invalid Date: " + date); } }