/// <summary> /// Retrieves and saves Events information /// </summary> /// <param name="urlEvents"></param> private void GetEvents(string eventsUrl, ILog logger) { HTMLDocument document = JobUtils.LoadDocument(eventsUrl); string rssRoot = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?> <?xml-stylesheet href=\"http://www.w3.org/2000/08/w3c-synd/style.css\" type=\"text/css\"?> <!-- generator=\"ICMS GemWeb v1.1\" --> <rdf:RDF xmlns=\"http://purl.org/rss/1.0/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:ev=\"http://www.w3.org/2001/xml-events\">#####1</rdf:RDF>"; string rssItem = "<item rdf:about=\"#####2\" image=\"#####5\" > <dc:format>text/html</dc:format> <date>#####3</date> <title>#####4</title> <description>#####6</description> </item>"; string strRssContent = "", strRssDetailsContent = ""; // Find original content placeholder IHTMLElement contentBox = document.getElementById("contentboxsub"); // Iterate over all <TR>'s foreach (IHTMLElement el in (IHTMLElementCollection)contentBox.all) { string strDate = "", strTitle = "", strDetailID = "", strDetailUrl = "", strRssItem = ""; if (el.tagName.ToLower() == "tr") { IHTMLElement date = JobUtils.FindElement(el, "td span"); if (date != null) { strDate = date.innerHTML; } IHTMLElement title = JobUtils.FindElement(el, "span a"); if (title != null) { // Process title strTitle = title.innerText; strDetailUrl = title.getAttribute("href").ToString(); int infoPos = strDetailUrl.IndexOf("_id=") + 4; int ampPos = strDetailUrl.IndexOf("&", infoPos); if (ampPos < 0) { ampPos = strDetailUrl.Length; } strDetailID = strDetailUrl.Substring(infoPos, ampPos - infoPos); // Save Details content strDetailUrl = strDetailUrl.Replace("about:blank", JobUtils.GetConfigValue("sourceWebRoot")); JobUtils.SaveEventsDetailsContent(strDetailUrl, strDetailID + ".data", logger); } if ((title == null) || (date == null)) { continue; } strRssItem = rssItem.Replace("#####2", strDetailUrl); strRssItem = strRssItem.Replace("#####4", strTitle); strRssItem = strRssItem.Replace("#####5", ""); strRssItem = strRssItem.Replace("#####3", strDate); strRssItem = strRssItem.Replace("#####6", ""); strRssItem += "\\\n"; strRssContent += strRssItem; strRssDetailsContent += (strDetailUrl + " \n"); } } strRssContent = rssRoot.Replace("#####1", strRssContent); // Updated processed content strRssContent = strRssContent.Replace('"', '\''); strRssContent = "RSSData.Content = \"" + strRssContent + "\";"; JobUtils.SaveData(strRssContent, "events.rss", logger); }
/// <summary> /// Retrieves and saves Weather information /// </summary> /// <param name="urlWeather"></param> private void GetWeather(string weatherUrl, ILog logger) { JobUtils.SaveEventsDetailsContent(weatherUrl, "weather.data", logger); }