예제 #1
0
파일: Job.cs 프로젝트: BeeFrog/dashing.net
        public RssItem GetFeed()
        {
            // To save on hitting bandwidth let's only hit the server 1 in 10 times
            if (timesUpdated > 10)
            {
                timesUpdated = 0;
            }

            RssItem item = null;

            if (timesUpdated < 1)
            {
                var client = new RssClient();
                var feed = client.GetRssFeed(new Uri(this.feedUrl));
                this.feedItems = feed?.Items;

                item = feed?.Items?.FirstOrDefault();
            }
            else
            {
                if (this.feedItems != null)
                {
                    int i = this.randomGenerator.Next(this.feedItems.Count() - 1);
                    item = this.feedItems.Skip(i).FirstOrDefault();
                }
            }

            timesUpdated++;
            return item;            
        }
예제 #2
0
        public RssItem GetFeed()
        {
            // To save on hitting bandwidth let's only hit the server 1 in 10 times
            if (timesUpdated > 10)
            {
                timesUpdated = 0;
            }

            RssItem item = null;

            if (timesUpdated < 1)
            {
                var client = new RssClient();
                var feed   = client.GetRssFeed(new Uri(this.feedUrl));
                this.feedItems = feed?.Items;

                item = feed?.Items?.FirstOrDefault();
            }
            else
            {
                if (this.feedItems != null)
                {
                    int i = this.randomGenerator.Next(this.feedItems.Count() - 1);
                    item = this.feedItems.Skip(i).FirstOrDefault();
                }
            }

            timesUpdated++;
            return(item);
        }
 public async Task LoadItemsAsync()
 {
     var client = new RssClient();
     var tcs = new TaskCompletionSource<RssFeed>();
     client.GetRssFeed(new Uri(FeedUrl), tcs.SetResult);
     var feed = await tcs.Task;
     Items = feed.Items.Select(item => new RssItem()
         {
             Title = item.Title,
             Description = item.Description,
             Link = item.Link
         });
 }
예제 #4
0
        public async Task LoadItemsAsync()
        {
            var client = new RssClient();
            var tcs    = new TaskCompletionSource <RssFeed>();

            client.GetRssFeed(new Uri(FeedUrl), tcs.SetResult);
            var feed = await tcs.Task;

            Items = feed.Items.Select(item => new RssItem()
            {
                Title       = item.Title,
                Description = item.Description,
                Link        = item.Link
            });
        }
예제 #5
0
        public async Task <IActionResult> Index()
        {
            var rssFeed = await _rssClient.GetRssFeed();

            return(Ok(rssFeed));
        }