/// <summary> /// On update, update items. /// </summary> protected override void OnUpdate() { try { if (_feed == null) { _feed = RssFeed.Read(base.Address); if (_feed.Channels.Count == 1) { // Some feeds have those symbols in their names. _name = _feed.Channels[0].Title.Replace("\r", "").Replace("\n", "").Trim(); } else { _name = _feed.Url.ToString(); } List <string> names = new List <string>(); foreach (RssChannel channel in _feed.Channels) { names.Add(channel.Title); } foreach (string name in names) { if (ChannelsNames.Contains(name) == false) { EventSourceChannel channel = new EventSourceChannel(name, true); channel.Initialize(this); base.AddChannel(channel); } } } else { _feed = RssFeed.Read(_feed); } //OperationalStateEnum newState = OperationalStateEnum.Operational; } catch (WebException we) {// Feed not found or some other problem. SystemMonitor.OperationWarning("Failed to initialize feed [" + Address + ", " + we.Message + "]"); ChangeOperationalState(OperationalStateEnum.NotOperational); } catch (Exception ex) {// RssFeed class launches IOExceptions too, so get safe here. SystemMonitor.OperationWarning("Failed to initialize feed [" + Address + ", " + ex.Message + "]"); ChangeOperationalState(OperationalStateEnum.NotOperational); } DoUpdateItems(); //RaisePersistenceDataUpdatedEvent(); }
public override void OnUpdate() { OperationalStateEnum newState; try { if (_feed == null) { _feed = RssFeed.Read(base.Address); if (_feed.Channels.Count == 1) { // Some feeds have those symbols in their names. _name = _feed.Channels[0].Title.Replace("\r", "").Replace("\n", "").Trim(); } else { _name = _feed.Url.ToString(); } List <string> names = new List <string>(); foreach (RssChannel channel in _feed.Channels) { names.Add(channel.Title); } foreach (string name in names) { if (ChannelsNames.Contains(name) == false) { base.AddChannel(name, true); } } // Retrieve web site shortcut icon. //if (_icon == null) //{ // _icon = GeneralHelper.GetWebSiteShortcutIcon(new Uri(Address)); //} } else { _feed = RssFeed.Read(_feed); } newState = OperationalStateEnum.Operational; } catch (WebException we) {// Feed not found or some other problem. SystemMonitor.OperationWarning("Failed to initialize feed [" + Address + ", " + we.Message + "]"); newState = OperationalStateEnum.NotOperational; } catch (Exception ex) {// RssFeed class launches IOExceptions too, so get safe here. SystemMonitor.OperationWarning("Failed to initialize feed [" + Address + ", " + ex.Message + "]"); newState = OperationalStateEnum.NotOperational; } OperationalStateEnum oldState = _operationalState; _operationalState = newState; if (newState != _operationalState) { RaiseOperationalStatusChangedEvent(oldState); } UpdateItems(); RaisePersistenceDataUpdatedEvent(); }