public override void Run() { HeadlineCollection headlines = new HeadlineCollection(); try { //DateTime now = DateTime.Now; DateTime now = DateTime.FromFileTime(0); string strFileName = Names.FeedsFolder + m_feedNode.FileName; if (File.Exists(strFileName)) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(strFileName); FeedManager = new FeedManager(xmlDoc.NameTable); FeedManager.TransferNamespaces(xmlDoc); XmlNodeList xmlNodes = xmlDoc.SelectNodes("/rss/channel//item"); foreach (XmlNode xmlNode in xmlNodes) { string title = FeedManager.GetNodeContent(xmlNode, "title"); DateTime dtPublished = FeedManager.GetNodeDate(xmlNode, "pubDate", now); DateTime dtReceived = FeedManager.GetNodeDate(xmlNode, "comshak:rcvDate", now); string author = FeedManager.GetNodeContent(xmlNode, "author"); string desc = FeedManager.GetNodeContent(xmlNode, "description", NCEncoding.String, NCType.Text); string link = FeedManager.GetNodeContent(xmlNode, "link"); string categ = FeedManager.GetNodeContent(xmlNode, "category"); Enclosure enc = FeedManager.GetEnclosure(xmlNode, "enclosure"); Headline headline = new Headline(title, dtPublished, dtReceived, author, desc, categ, enc); headline.Link = link; headlines.Add(headline); } } } catch (FileNotFoundException ex) { Utils.DbgOutExc("ReadChannelThread::Run()", ex); } catch (XmlException xmlEx) { Utils.DbgOutExc("ReadChannelThread::Run()", xmlEx); } //catch (Exception ex) //{ // Utils.DbgOutExc("ReadChannelThread::Run()", ex); //} finally { m_form.Invoke(new OnEndCallback(OnEnd), new object[] { headlines }); } }
/// <summary> /// Writes items from an RSS feed. /// </summary> /// <param name="xmlDocument"></param> /// <param name="xmlWriter"></param> private void WriteRssItems(XmlDocument xmlDocument, RssChannel rssChannel) { NCEncoding encoding = NCEncoding.String; DateTime now = DateTime.Now; XmlNodeList xmlNodes = xmlDocument.SelectNodes("/rss/channel//item", FeedManager.NsManager); foreach (XmlNode xmlNode in xmlNodes) { RssItem rssItem = new RssItem(); rssItem.Title = FeedManager.GetNodeContent(xmlNode, "title"); rssItem.Link = FeedManager.GetNodeContent(xmlNode, "link"); rssItem.Published = FeedManager.GetNodeContentFrom(xmlNode, s_arrRssPubDate, ref encoding); rssItem.ReceivedDate = now; rssItem.Author = FeedManager.GetNodeContentFrom(xmlNode, s_arrRssAuthor, ref encoding); rssItem.Description = FeedManager.GetNodeContentFrom(xmlNode, s_arrRssDesc, ref encoding); rssItem.Category = FeedManager.GetNodeContent(xmlNode, "category"); rssItem.Encoding = encoding; rssItem.Enclosure = FeedManager.GetEnclosure(xmlNode, "enclosure"); rssChannel.AddItem(rssItem); } }