public RssFeedMonitorSettingsView() { _checkdelay = Properties.Settings.Default.UpdateInterval; _listalerts = new ObservableCollection <Alert>(RssFeedAlertHandler.LoadRssFeedAlerts()); }
public void CheckAlertAndTriggers() { List <Alert> listAlert = RssFeedAlertHandler.LoadRssFeedAlerts(); SyndicationFeed sf; foreach (Alert a in listAlert) { XmlReader xr = XmlReader.Create(a.Url); sf = SyndicationFeed.Load(xr); if (sf == null) { return; } List <SyndicationItem> si = sf.Items.ToList(); if (a.Criterias.Exists(x => x.RSSElement == "Title") == true) { Criteria cr = (Criteria)a.Criterias.Select(x => x.RSSElement == "Title"); if (cr.Condition == "Contains") { si.RemoveAll(x => !x.Title.Text.Contains(cr.UserCondition)); } if (cr.Condition == "Equals") { si.RemoveAll(x => x.Title.Text != cr.UserCondition); } } if (a.Criterias.Exists(x => x.RSSElement == "Description") == true) { Criteria cr = (Criteria)a.Criterias.Select(x => x.RSSElement == "Description"); if (cr.Condition == "Contains") { si.RemoveAll(x => !x.Summary.Text.Contains(cr.UserCondition)); } if (cr.Condition == "Equals") { si.RemoveAll(x => x.Summary.Text != cr.UserCondition); } } if (a.Criterias.Exists(x => x.RSSElement == "Publication Date") == true) { Criteria cr = (Criteria)a.Criterias.Select(x => x.RSSElement == "Title"); if (cr.Condition == "Contains") { si.RemoveAll(x => !x.PublishDate.ToString().Contains(cr.UserCondition)); } if (cr.Condition == "Equals") { si.RemoveAll(x => x.PublishDate.ToString() != cr.UserCondition); } if (cr.Condition == "Greater") { si.RemoveAll(x => x.PublishDate > DateTimeOffset.Parse(cr.UserCondition)); } if (cr.Condition == "Lower") { si.RemoveAll(x => x.PublishDate < DateTimeOffset.Parse(cr.UserCondition)); } } if (a.Criterias.Exists(x => x.RSSElement == "Category") == true) { Criteria cr = (Criteria)a.Criterias.Select(x => x.RSSElement == "Title"); /*if (cr.Condition == "Contains") * si.RemoveAll(x => !x.Categories.Contains.Text.Contains(cr.UserCondition));*/ /*if (cr.Condition == "Equals") * si.RemoveAll(x => x.Title.Text != cr.UserCondition);*/ } if (si.Count > 0) { // Do ALERT ABOUT IT. } } }