Exemple #1
0
        static void Main(string[] args)
        {
            RssRepository RssRepository = new RssRepository();
            RssHelper     helper        = new RssHelper(RssRepository);

            helper.ReadXmlFile("Habr.xml");
            Console.ReadLine();
        }
Exemple #2
0
        public ActionResult Index(int page = 1)
        {
            RssRepository repository = new RssRepository();

            List <NewsItem> newsItems = repository.GetAllNews().ToList();

            var model = PageListViewModel <NewsItem> .CreatePage(newsItems, page, tableSize);

            if (Request.IsAjaxRequest())
            {
                return(PartialView("ListViewPatial", model));
            }
            return(View(model));
        }
Exemple #3
0
        public async Task RecordNewMatches()
        {
            foreach (RssFeed feed in RssRepository.GetFeeds())
            {
                var newPosts = await GetNewPosts(feed);

                if (newPosts.Any())
                {
                    feed.LastPollTime       = DateTime.Now;
                    feed.LastPostUniqueName = newPosts.FirstOrDefault()?.PostId ?? feed.LastPostUniqueName;

                    var matchingPosts = newPosts.Where(post => PostMatches(post, feed.MatchCriteria));

                    feed.Posts.AddRange(matchingPosts);

                    RssRepository.SavePosts(matchingPosts.ToList());

                    RssRepository.SaveFeed(feed);
                }
            }
        }
Exemple #4
0
        static void Main(string[] args)
        {
            RssSoure habr = new RssSoure {
                UrlSourse = @"http://habrahabr.ru/rss/", Title = "Хабрахабр"
            };

            IRepository <RssSoure> repository = new RssRepository();

            RssSourseReader reader = new RssSourseReader();

            RssSoure filledHabr = reader.InitialazeSourse(habr);

            if (filledHabr.NewsItems == null)
            {
                Console.WriteLine("Something wrong happend, try again . . .");
                Console.ReadKey();
                return;
            }

            Console.WriteLine("RSS reading ...");

            int readCount     = 0;
            int saveNewsCount = 0;

            foreach (NewsItem item in filledHabr.NewsItems)
            {
                readCount++;
                if (!repository.IsNewsItemInDb(item))
                {
                    saveNewsCount++;
                    repository.AddNewsItem(item);
                }
                Console.Write(".");
            }
            Console.WriteLine();
            Console.WriteLine("Read news: {0}", readCount);
            Console.WriteLine("Saved news: {0}", saveNewsCount);
            Console.ReadKey();
        }