예제 #1
0
        /// <summary>
        /// Parses RSS Feed
        /// </summary>
        public void ParseData()
        {
            FeedParser parser = new FeedParser();
            var        items  = parser.ParseRss(rssURL);

            int i = 0;

            //Sorts list by date descending whilst keeping in text format
            sortedWriteList = items.OrderBy(o => Convert.ToDateTime(o.PublishDate)).ToList();
            sortedWriteList.Reverse();

            //Loops through full article list to find matching criteria for final list
            foreach (Item y in sortedWriteList)
            {
                DateTime sortDate = new DateTime();
                sortDate = Convert.ToDateTime(sortedWriteList.ElementAt(i).PublishDate);
                if (sortDate.Hour == DateTime.Now.Hour)
                {
                    //Adds all matching criteria to final list
                    finalWriteList.Add(new Item()
                    {
                        Title       = sortedWriteList.ElementAt(i).Title.ToString(),
                        Description = sortedWriteList.ElementAt(i).Description.ToString(),
                        Link        = sortedWriteList.ElementAt(i).Link.ToString(),
                        PublishDate = sortedWriteList.ElementAt(i).PublishDate.ToString()
                    });
                }
                i++;
            }
        }
예제 #2
0
        /// <summary>
        /// Parses RSS Feed
        /// </summary>
        public void ParseData()
        {
            FeedParser parser = new FeedParser();
            var items = parser.ParseRss(rssURL);

            int i = 0;

            //Sorts list by date descending whilst keeping in text format
            sortedWriteList = items.OrderBy(o => Convert.ToDateTime(o.PublishDate)).ToList();
            sortedWriteList.Reverse();

            //Loops through full article list to find matching criteria for final list
            foreach (Item y in sortedWriteList)
            {
                DateTime sortDate = new DateTime();
                sortDate = Convert.ToDateTime(sortedWriteList.ElementAt(i).PublishDate);
                if (sortDate.Hour == DateTime.Now.Hour)
                {
                    //Adds all matching criteria to final list
                    finalWriteList.Add(new Item()
                    {
                        Title = sortedWriteList.ElementAt(i).Title.ToString(),
                        Description = sortedWriteList.ElementAt(i).Description.ToString(),
                        Link = sortedWriteList.ElementAt(i).Link.ToString(),
                        PublishDate = sortedWriteList.ElementAt(i).PublishDate.ToString()
                    });
                }
                i++;
            }
        }