Ejemplo n.º 1
0
        private void downalodFeed(object arg)
        {
            FeedSource f = arg as FeedSource;

            RssItemList articles;

            try {
                logger.Info("RssChannel.Create=>" + f.FeedLink);
                articles = RssChannel.Create(f.FeedLink).RssItems;
            }
            catch (Exception ex) {
                logger.Error("download rss:" + f.FeedLink);
                logger.Error(ex.Message);
                return;
            }

            //最后更新时间
            f.LastRefreshTime = DateTime.Now;
            db.update(f, "LastRefreshTime");
            logger.Info("download feed ok");

            RssChannel c = new RssChannel();

            c.RssItems   = articles;
            f.RssChannel = c;

            saveFeedItems(f);
        }
Ejemplo n.º 2
0
        private FeedSource createNewSource(String url)
        {
            FeedSource feedsrc = new FeedSource();
            RssChannel rss     = RssChannel.Create(url);

            feedsrc.RssChannel = rss;

            //-----------------------------------

            feedsrc.Title        = rss.Title;
            feedsrc.FeedLink     = url;
            feedsrc.Link         = rss.Link;
            feedsrc.Description  = rss.Description;
            feedsrc.BlogLanguage = rss.Language;

            feedsrc.LastBuildDate = rss.LastBuildDate;
            if (feedsrc.LastBuildDate == null || feedsrc.LastBuildDate < new DateTime(1900, 1, 1))
            {
                feedsrc.LastBuildDate = DateTime.Now;
            }

            feedsrc.PubDate = rss.PubDate;
            if (feedsrc.PubDate == null || feedsrc.PubDate < new DateTime(1900, 1, 1))
            {
                feedsrc.PubDate = DateTime.Now;
            }

            feedsrc.LastRefreshTime = DateTime.Now;
            feedsrc.Generator       = rss.Generator;
            feedsrc.Created         = DateTime.Now;

            db.insert(feedsrc);

            return(feedsrc);
        }