/// <summary> /// Actual updating of items happens here. /// </summary> void DoUpdateItems() { if (_feed == null) { return; } List <RssChannel> channels; lock (this) { channels = GeneralHelper.EnumerableToList <RssChannel>(_feed.Channels); } foreach (RssChannel channel in channels) { // Obtain or create channel. EventSourceChannel sourceChannel = base.GetChannelByName(channel.Title, true); sourceChannel.ItemsUpdateEnabled = false; sourceChannel.Address = channel.Link.ToString(); List <EventBase> newItems = new List <EventBase>(); foreach (RssItem item in channel.Items) { RssNewsEvent eventItem = new RssNewsEvent(item); eventItem.Initialize(sourceChannel); newItems.Add(eventItem); } // Add all by default to the "Default" channel, since RSS feeds never seem to bother with proper inner channels. sourceChannel.AddItems(newItems); } }
/// <summary> /// Helper. node.ChildNodes[0].InnerText + ">>" + node.Attributes["href"].Value + "; " + Environment.NewLine; /// </summary> /// <param name="node"></param> /// <param name="fetchDate"></param> /// <returns></returns> RssNewsEvent CreateNewsItem(HtmlNode node, bool fetchDateAndDetails) { RssNewsEvent item = new RssNewsEvent(); item.Author = "Bloomberg"; item.Comments = string.Empty; if (node.ParentNode.Name == "p" && node.ParentNode.ChildNodes[2].Name == "#text") {// Description available in parent. item.Description = GeneralHelper.RepairHTMLString(node.ParentNode.ChildNodes[2].InnerText); item.Description = item.Description.Replace("\n", " "); } else { item.Description = ""; } item.Link = new Uri(BaseAddress + node.Attributes["href"].Value).ToString(); item.Title = node.ChildNodes[0].InnerText.Trim(); if (fetchDateAndDetails) { HtmlDocument document = GenerateDocument(item.LinkUri.AbsoluteUri); if (document == null) { return null; } HtmlNodeCollection nodes = document.DocumentNode.SelectNodes("//i"); foreach (HtmlNode iNode in nodes) { string dateTimeInfo = iNode.ChildNodes[0].InnerText; DateTime time = GeneralHelper.ParseDateTimeWithZone(dateTimeInfo.Replace("Last Updated:", "")); item.DateTime = time; } } return item; }
/// <summary> /// /// </summary> public NewsItemControl(RssNewsEvent newsItem) { InitializeComponent(); NewsItem = newsItem; }
/// <summary> /// Actual updating of items happens here. /// </summary> void DoUpdateItems() { if (_feed == null) { return; } List<RssChannel> channels; lock (this) { channels = GeneralHelper.EnumerableToList<RssChannel>(_feed.Channels); } foreach (RssChannel channel in channels) { // Obtain or create channel. EventSourceChannel sourceChannel = base.GetChannelByName(channel.Title, true); sourceChannel.ItemsUpdateEnabled = false; sourceChannel.Address = channel.Link.ToString(); List<EventBase> newItems = new List<EventBase>(); foreach (RssItem item in channel.Items) { RssNewsEvent eventItem = new RssNewsEvent(item); eventItem.Initialize(sourceChannel); newItems.Add(eventItem); } // Add all by default to the "Default" channel, since RSS feeds never seem to bother with proper inner channels. sourceChannel.AddItems(newItems); } }