/// <summary> /// Update the RSS feed. /// </summary> private void UpdateRssFeed() { logger.Debug(string.Format("Updating the feed for {0}", FeedUri)); try { XmlReaderSettings readerSettings = null; using (SecureString password = FeedCredentials.GetSecurePassword()) { readerSettings = new XmlReaderSettings() { XmlResolver = new XmlUrlResolver() { Credentials = new NetworkCredential(FeedCredentials.Username, password) } }; } using (XmlReader reader = XmlReader.Create(FeedUri, readerSettings)) { Feed = new Feed(SyndicationFeed.Load(reader)); } } catch (Exception e) { Enabled = false; ToastManager.Toast("Failed to Update Feed", string.Format("Failed to update the feed {0}. Check settings and renable the feed.", FeedUri)); logger.Error(string.Format("Failed to update the feed {0} due to the exception {1}", FeedUri, e.Message)); } logger.Debug(string.Format("Finished updating the feed for {0}", FeedUri)); }
/// <summary> /// Update a feed and send notifications for new items to the ToastManger /// </summary> /// <param name="sender">The timer that caused this event.</param> /// <param name="e">Timer event args/</param> private void UpdateFeedAndSendNotifications(object sender, ElapsedEventArgs e) { IEnumerable <FeedItem> newRssFeedEntries; UpdateRssFeed(out newRssFeedEntries); foreach (var item in newRssFeedEntries) { ToastManager.Toast(item); } }