Example #1
0
        private void GetRssFeeds(object state)
        {
            OutlineInfo outline = null;

            try
            {
                outline = (OutlineInfo)state;
                string xmlString = string.Empty;

                using (Stream rssStream = DownloadManager.GetFeed(outline.Outline.XmlUrl))
                {
                    using (XmlTextReader reader = new XmlTextReader(rssStream))
                    {
                        while (reader.Read())
                        {
                            if (reader.NodeType == XmlNodeType.Element)
                            {
                                xmlString = reader.ReadOuterXml();
                                break;
                            }
                        }
                    }
                }

                ////convert to rss
                xmlString = RssXmlHelper.ConvertToRssXml(xmlString);

                if (!string.IsNullOrEmpty(xmlString))
                {
                    RssXmlSchemaValidator validator = new RssXmlSchemaValidator();
                    Assembly assembly = Assembly.GetExecutingAssembly();
                    using (Stream stream = assembly.GetManifestResourceStream(Constants.Rss20Xsd))
                    {
                        lock (aggregateRss)
                        {
                            validator.ValidXmlDoc(xmlString, new XmlTextReader(stream));

                            if (validator.IsValidXml)
                            {
                                aggregateRss.Add(xmlString);
                            }
                        }

                        if (!validator.IsValidXml)
                        {
                            NotifySubscribers(null, "Rss not valid in OPML for - " + outline.Outline.XmlUrl, RssSeverityType.Warning);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                NotifySubscribers(ex, ex.Message, RssSeverityType.Error);
            }
            finally
            {
                rssEvents[outline.Index].Set();
            }
        }
        private void GetRssFeeds(object state)
        {
            OutlineInfo outline = null;
            try
            {
                outline = (OutlineInfo)state;
                string xmlString = string.Empty;

                using (Stream rssStream = DownloadManager.GetFeed(outline.Outline.XmlUrl))
                {
                    using (XmlTextReader reader = new XmlTextReader(rssStream))
                    {
                        while (reader.Read())
                        {
                            if (reader.NodeType == XmlNodeType.Element)
                            {
                                xmlString = reader.ReadOuterXml();
                                break;
                            }
                        }
                    }
                }

                ////convert to rss
                xmlString = RssXmlHelper.ConvertToRssXml(xmlString);

                if (!string.IsNullOrEmpty(xmlString))
                {
                    RssXmlSchemaValidator validator = new RssXmlSchemaValidator();
                    Assembly assembly = Assembly.GetExecutingAssembly();
                    using (Stream stream = assembly.GetManifestResourceStream(Constants.Rss20Xsd))
                    {
                        lock (aggregateRss)
                        {
                            validator.ValidXmlDoc(xmlString, new XmlTextReader(stream));

                            if (validator.IsValidXml)
                            {
                                aggregateRss.Add(xmlString);
                            }
                        }

                        if (!validator.IsValidXml)
                        {
                            NotifySubscribers(null, "Rss not valid in OPML for - " + outline.Outline.XmlUrl, RssSeverityType.Warning);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                NotifySubscribers(ex, ex.Message, RssSeverityType.Error);
            }
            finally
            {
                rssEvents[outline.Index].Set();
            }
        }