private void scan_by_id(int id) { client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)"); //set headers string url = "https://apps.fcc.gov/oetcf/kdb/forms/FTSSearchResultPage.cfm?id=" + id.ToString() + "&switch=P"; Stream data; try { data = client.OpenRead(url); } catch (WebException we) { KeepScanning = false; Connection_Error_Event(this, new EventArgs()); MessageBox.Show("Error accessing fcc webpage.Please check Internet Connection and try again. Error Message:" + we.Message); return; } StreamReader reader = new StreamReader(data); string html = reader.ReadToEnd(); reader.Close(); //search for a date Match date_m = date_regex.Match(html); if (date_m.Success) //found a date { string year = date_m.Groups[3].Value; string month = date_m.Groups[1].Value; string day = date_m.Groups[2].Value; DateTime publication_date = new DateTime(int.Parse(year), int.Parse(month), int.Parse(day)); if (true)//publication_date > DateTime.Today) { string title; //search for title Match title_m = title_regex.Match(html); if (title_m.Success) { title = title_m.Groups[1].Value; title = process_title(title); } else { title = "No title"; } FutureEntry fe = new FutureEntry(DateTime.Today, publication_date, id, title); //raise an event that emits a notification object Found_Future_Entry_Event(this, new ScannerEventArg(fe)); } } }
static public int CompareByPublicationDate(FutureEntry x, FutureEntry y) { if (x.publication_date < y.publication_date) { return(-1); } else if (x.publication_date > y.publication_date) { return(1); } else { return(0); } }
static public int CompareByFoundDate(FutureEntry x, FutureEntry y) { if (x.found_date < y.found_date) { return(-1); } else if (x.found_date > y.found_date) { return(1); } else { return(0); } }
static public int CompareByID(FutureEntry x, FutureEntry y) { if (x.id < y.id) { return(-1); } else if (x.id > y.id) { return(1); } else { return(0); } }
public ScannerEventArg(FutureEntry _fe) { fe = _fe; }