public SingleResponse<UserFeed> LookupUserFeed(UserFeed userFeed)
        {
            if (userFeed.Feed == null || string.IsNullOrEmpty(userFeed.Feed.Url))
            {
                return ResponseBuilder.BuildSingleResponse<UserFeed>(ErrorLevel.None, "");
            }
            var factory = new HttpFeedFactory();
            try
            {
                var rssFeed = factory.CreateFeed(new Uri(userFeed.Feed.Url));

                return ResponseBuilder.BuildSingleResponse(new UserFeed
                {
                    Name = rssFeed.Title,
                    Feed = userFeed.Feed
                }, ErrorLevel.None);
            }
            catch (NotSupportedException)
            {
                return ResponseBuilder.BuildSingleResponse<UserFeed>(ErrorLevel.Error, "URL type is not supported");
            }
            catch (InvalidFeedXmlException ex)
            {
                return ResponseBuilder.BuildSingleResponse<UserFeed>(ErrorLevel.Critical,
                    string.Format("Failed to retrieve feed at URL: {0}", userFeed.Feed.Url), ex);
            }
        }
        public CollectionResponse<FeedItem> GetFeedItems(Feed feed)
        {
            var factory = new HttpFeedFactory();
            try
            {
                var rssFeed = factory.CreateFeed(new Uri(feed.Url));

                var feedItems = rssFeed.Items.ConvertAll(i => new FeedItem
                {
                    RssId = !string.IsNullOrEmpty(i.Id) ? i.Id : i.Title,
                    Title = i.Title,
                    FeedId = feed.Id,
                    Url = i.Link,
                    Author = i.Author,
                    Content = i.Content,
                    DatePublished = i.DatePublished
                });
                return ResponseBuilder.BuildCollectionResponse(feedItems, ErrorLevel.None);
            }
            catch (InvalidFeedXmlException ex)
            {
                return ResponseBuilder.BuildCollectionResponse<FeedItem>(ErrorLevel.Critical,
                    string.Format("Failed to retrieve feed at URL: {0}", feed.Url), ex);
            }
        }
Esempio n. 3
0
        private static async Task<IFeed> CreateFeedAsync()
        {
            var factory = new HttpFeedFactory();
            IFeed feed = null;
            try
            {
                feed = await factory.CreateFeedAsync(new Uri(FRONT_PAGE_RSS_URI));
            }

            catch (Exception ex) { throw ex; }
            return feed;
        }
Esempio n. 4
0
 public IFeed GetRssFeed()
 {
     try
     {
         var factory = new HttpFeedFactory();
         return factory.CreateFeed(_url);
     }
     catch (MissingFeedException)
     {
         throw new Exception("Could not read feed");
     }
 }
Esempio n. 5
0
        public void Sync()
        {
            var factory = new HttpFeedFactory();
            model = factory.CreateFeed(feedUri);
            OnPropertyChanged("Title");
            OnPropertyChanged("FeedUri");
            OnPropertyChanged("SiteUri");
            OnPropertyChanged("LastUPdated");

            Entries.Clear();
            model.Items.ToList().ForEach(o => Entries.Add(new EntryViewModel(o)));
        }
Esempio n. 6
0
        public static List<IFeed> GetFeeds()
        {
            var feeds = new List<IFeed>();
            IFeedFactory factory = new HttpFeedFactory();

            foreach (var URL in GetFeedUrls())
            {
                Uri feeduri = new Uri(URL);
                IFeed feed = factory.CreateFeed(feeduri);
                feeds.Add(feed);
            }

            return feeds;
        }
        static void Main(string[] args)
        {
            try
            {
                if(args.Length > 0 && args[0].ToLower().Equals("--help"))
                {
                    Console.WriteLine("Arguments: [http | filesys] [uri]");
                    Console.WriteLine(@"e.g. filesys C:\RSS\rss01.xml");
                    Console.WriteLine(@"e.g. http http://www.aaronstannard.com/syndication.axd");
                    Console.WriteLine("The results will be the parsed content of all of the items in the feed.");
                }
                else
                {
                    UseFileSys = args.Length == 0 ? true : !args[0].ToLower().Equals("http");
                    var strFeedUri = args.Length <= 1 ? ValidTestFileSysPath : args[1];

                    Uri feeduri;
                    IFeedFactory factory;
                    if (UseFileSys)
                    {
                        feeduri = new Uri(Path.GetFullPath(strFeedUri));
                        factory = new FileSystemFeedFactory();
                    }
                    else
                    {
                        feeduri = new Uri(strFeedUri);
                        factory = new HttpFeedFactory();
                    }

                    factory.BeginCreateFeed(feeduri, async =>
                    {
                        var feed = factory.EndCreateFeed(async);
                        PrintFeed(feed);
                    });

                    //Just to prevent the window from instantly bailing out.
                    Console.ReadKey();
                }

            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception: {0}", ex);
            }
        }
Esempio n. 8
0
        public static FeedEntity GetOrCreate(Uri feed_uri)
        {
            var feed = Feeds.Entities.SingleOrDefault(f => f.uri == feed_uri);
            if (feed != null) {
                return feed;
            }

            IFeedFactory factory = new HttpFeedFactory();
            if (!factory.PingFeed(feed_uri)) {
                return null;
            }

            var new_feed = factory.CreateFeed(feed_uri);
            feed = new FeedEntity()
            {
                link = new Uri(new_feed.Link),
                title = new_feed.Title,
                uri = feed_uri,
                articles = new_feed.Items.Select(item => new Article() {
                    article_id = item.Id,
                    author = item.Author,
                    categories = item.Categories.ToList(),
                    content = item.Content,
                    link = new Uri(item.Link),
                    published = item.DatePublished,
                    title = item.Title
                }).ToList()
            };

            if (Feeds.Entities.Insert(feed))
            {
                return Feeds.Entities.SingleOrDefault(f => f.uri == feed_uri);
            }
            else
            {
                return null;
            }
        }
Esempio n. 9
0
 public IEnumerable<FeedEntry> GetEntries(string url)
 {
     var factory = new HttpFeedFactory();
     var feed = factory.CreateFeed(new Uri(url));
     return feed.Items.Select(feedItem => new FeedEntry { Title = feedItem.Title }).ToList();
 }
Esempio n. 10
0
        public ActionResult GetRss()
        {

            try
            {
                var factory = new HttpFeedFactory();

                var url = new Uri(MvcApplication.Config("home.Rss"));
                var item = factory.CreateFeed(url);

                return View(item);
            }
            catch
            {
                return Content("");
            }
        }