示例#1
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());
        }
示例#2
0
        public List <Article> Process(bool IsDownImage, int maxcount)
        {
            HttpFeedFactory factory  = new HttpFeedFactory();
            IFeed           feed     = factory.CreateFeed(new Uri(this.rssURL));
            List <Article>  articles = GetArticles(feed, maxcount, IsDownImage);

            Console.WriteLine("GET Artilces!");
            articles.ForEach(ar => ar.Cat = cat);
            return(articles);
        }
示例#3
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)));
        }
示例#4
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);
        }
        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(""));
            }
        }
示例#6
0
        protected void Page_Load(object sender, EventArgs e)
        {

            HttpFeedFactory factory = new HttpFeedFactory(new Xml.PodcastFeedXmlParser(), new PodcastFeedInstanceProvider());
            Uri url = new Uri(string.Format("http://feed.scicast.com.br/")); //http://feed.nerdcast.com.br  //http://feed.scicast.com.br/
            //Uri url = new Uri(string.Format("http://{0}/Examples/{1}.xml", HttpContext.Current.Request.Url.Authority, "nerdcast")); 

            if (factory.PingFeed(url)) {
                PodcastRss20Feed feed = (PodcastRss20Feed) factory.CreateFeed(url);
                TitleLink.HRef = feed.Link;
                TitleLink.Title = feed.Description;
                TitleLink.InnerHtml = feed.Title;

                LogoImage.Src = feed.Image.Url;
                LogoImage.Alt = feed.Image.Title;

                DescriptionLiteral.Text = feed.Description;
                ManagingEditorLiteral.Text = feed.ManagingEditor;

                SiteLink.HRef = feed.Link;
                SiteLink.Title = feed.Description;
                SiteLink.InnerHtml = feed.Link;

                CategoryLiteral.Text = feed.Category;
                LastDateLiteral.Text = feed.LastUpdated.ToLongDateString();

                for (int i = 0; i < feed.Items.Count; i++)
                {
                    IFeedItem item = feed.Items[i];
                    string modelo = string.Format(@"<div class=""panel panel-default"">
                                                    <div class=""panel-heading"">
                                                      <h4 class=""panel-title"">
                                                        <a data-toggle=""collapse"" data-parent=""#EpisodesList"" href=""#{0}"">
                                                            {1}
                                                        </a>
                                                      </h4>
                                                    </div>
                                                    <div id=""{0}"" class=""panel-collapse collapse"">
                                                      <div class=""panel-body"">{2}</div>
                                                    </div>
                                                  </div>", "collapse" + i, item.Title, item.Content);

                    LiteralControl collapseControl = new LiteralControl(modelo);
                    EpisodesList.Controls.Add(collapseControl);
                }
            }
        }
        private static void UpdateFeed(Feed feed)
        {
            //LastUpdated
            Uri          feeduri = new Uri(feed.Url);
            IFeedFactory factory = new HttpFeedFactory();
            IFeed        ifeed   = factory.CreateFeed(feeduri);

            if (feed.LastUpdated != ifeed.LastUpdated)
            {
                feed.LastUpdated = ifeed.LastUpdated;
                using (FeedsDB db = new FeedsDB())
                {
                    foreach (BaseFeedItem feedItem in ifeed.Items)
                    {
                        /* IFeedItem members...
                         * string Author
                         * IList<string> Categories
                         * string Content
                         * DateTime DatePublished
                         * string Id
                         * string Link
                         * string Title
                         */
                        if (db.FeedItems.Where(r => r.FeedId == feed.ID && r.ItemId == feedItem.Id).Count() == 0)
                        {
                            FeedItem newItem = new FeedItem();
                            newItem.Read          = false;
                            newItem.FeedId        = feed.ID;
                            newItem.ItemId        = feedItem.Id;
                            newItem.Text          = feedItem.Content;
                            newItem.Title         = feedItem.Title;
                            newItem.ItemUrl       = feedItem.Link;
                            newItem.DatePublished = feedItem.DatePublished;
                            db.FeedItems.Add(newItem);
                        }
                    }
                    db.SaveChanges();
                }
            }
        }
示例#8
0
        private void GetTiles(object sender, RoutedEventArgs e)
        {
            btnGetTiles.IsEnabled = false;
            isBusy = true;

            _tiles.Clear();

            Uri          feeduri = new Uri("http://www.hnsearch.com/bigrss");
            IFeedFactory factory = new HttpFeedFactory();
            IFeed        feed    = factory.CreateFeed(feeduri);

            foreach (var item in feed.Items)
            {
                Tile t = new Tile();
                t.Title = item.Title;
                t.Link  = item.Link;
                _tiles.Add(t);
            }

            isBusy = false;
            btnGetTiles.IsEnabled = true;
        }
        //private static FeedsDB db = new FeedsDB();
        public static void CreateNewFeed(Feed newFeed)
        {
            using (FeedsDB db = new FeedsDB())
            {
                if (db.Feeds.Where(r => r.Url == newFeed.Url && r.UserName == newFeed.UserName).Count() > 0)
                {
                    // already exists
                    // TODO: give user error message
                }
                else
                {
                    Uri          feeduri = new Uri(newFeed.Url);
                    IFeedFactory factory = new HttpFeedFactory();
                    IFeed        feed    = factory.CreateFeed(feeduri);

                    if (feed != null)
                    {
                        newFeed.LastUpdated = feed.LastUpdated;
                        db.Feeds.Add(newFeed);
                        db.SaveChanges(); // save.. to get id

                        /* IFeed members...
                         * FeedType FeedType
                         * string FeedUri
                         * string Generator
                         * List<BaseFeedItem> Items
                         * DateTime LastUpdated
                         * string Link
                         * string Title
                         */

                        foreach (BaseFeedItem feedItem in feed.Items)
                        {
                            /* IFeedItem members...
                             * string Author
                             * IList<string> Categories
                             * string Content
                             * DateTime DatePublished
                             * string Id
                             * string Link
                             * string Title
                             */
                            if (db.FeedItems.Where(r => r.FeedId == newFeed.ID && r.ItemId == feedItem.Id).Count() == 0)
                            {
                                FeedItem newItem = new FeedItem();
                                newItem.Read          = false;
                                newItem.FeedId        = newFeed.ID;
                                newItem.ItemId        = feedItem.Id;
                                newItem.Text          = feedItem.Content;
                                newItem.Title         = feedItem.Title;
                                newItem.ItemUrl       = feedItem.Link;
                                newItem.DatePublished = feedItem.DatePublished;
                                db.FeedItems.Add(newItem);
                            }
                        }
                        db.SaveChanges();
                    }
                    else
                    {
                        // bad url???
                        // TODO: give user error message
                    }
                }
            }
        }
示例#10
0
        public IFeed GetPodcastFeed(Uri uri)
        {
            var feed = _factory.CreateFeed(uri);

            return(feed);
        }