/// <summary> /// Internal method used to raise the error event /// </summary> protected void OnFeedError(FeedErrorEventArgs args) { if (FeedError != null) { FeedError(this, args); } }
void feed_FeedError(object sender, FeedErrorEventArgs e) { Feed feed = (Feed)sender; string name = (feed.Name == Feed.LOADING ? feed.Url : feed.Name); string text = String.Format("The feed '{0}' was not able to be parsed.", name); Notification n = new Notification(this.app.Name, this.ntFeedError.Name, "", "Feed Error", text); this.growl.Notify(n); }
/// <summary> /// Internal method used to raise the error event /// </summary> protected void OnFeedError(FeedErrorEventArgs args) { if (FeedError != null) FeedError(this, args); }
void webclient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e) { WebClient wc = (WebClient)sender; // process the feed if (e.Error == null && e.Result != null) { /* THIS IS JUST FOR TESTING List<byte> chars = new List<byte>(); System.IO.StreamReader r = new System.IO.StreamReader(e.Result); using (r) { while (r.Peek() > 0) { chars.Add((byte) r.Read()); } } byte[] bytes = chars.ToArray(); string s = System.Text.Encoding.UTF8.GetString(bytes); Console.WriteLine(s); * */ FeedInfo info = null; XmlReaderSettings settings = new XmlReaderSettings(); settings.ProhibitDtd = false; using (XmlReader reader = XmlReader.Create(e.Result, settings)) { GenericFeedParser parser = new GenericFeedParser(); info = parser.Parse(reader); } if (info != null) { info.CustomTitle = this.CustomName; info.Url = this.Url; OnFeedRetrieved(info); } else { // the loader couldn't load the feed FeedErrorEventArgs args = new FeedErrorEventArgs(new FeedException(_parseErrorMessage)); OnFeedError(args); } } else { if (e.Error != null) { // there was an error returned from the call FeedErrorEventArgs args = new FeedErrorEventArgs(e.Error); OnFeedError(args); } else { // an empty stream. FeedErrorEventArgs args = new FeedErrorEventArgs(new FeedException(_nullResultErrorMessage)); OnFeedError(args); } } // restart the timer this.timer.Start(); }
void webclient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e) { WebClient wc = (WebClient)sender; // process the feed if (e.Error == null && e.Result != null) { /* THIS IS JUST FOR TESTING * List<byte> chars = new List<byte>(); * System.IO.StreamReader r = new System.IO.StreamReader(e.Result); * using (r) * { * while (r.Peek() > 0) * { * chars.Add((byte) r.Read()); * } * } * byte[] bytes = chars.ToArray(); * string s = System.Text.Encoding.UTF8.GetString(bytes); * Console.WriteLine(s); * */ FeedInfo info = null; XmlReaderSettings settings = new XmlReaderSettings(); settings.ProhibitDtd = false; using (XmlReader reader = XmlReader.Create(e.Result, settings)) { GenericFeedParser parser = new GenericFeedParser(); info = parser.Parse(reader); } if (info != null) { info.CustomTitle = this.CustomName; info.Url = this.Url; OnFeedRetrieved(info); } else { // the loader couldn't load the feed FeedErrorEventArgs args = new FeedErrorEventArgs(new FeedException(_parseErrorMessage)); OnFeedError(args); } } else { if (e.Error != null) { // there was an error returned from the call FeedErrorEventArgs args = new FeedErrorEventArgs(e.Error); OnFeedError(args); } else { // an empty stream. FeedErrorEventArgs args = new FeedErrorEventArgs(new FeedException(_nullResultErrorMessage)); OnFeedError(args); } } // restart the timer this.timer.Start(); }