Exemplo n.º 1
0
 public void Tick()
 {
     if (LastRefresh.AddSeconds(30) < DateTime.Now)
     {
         RefreshGates();
     }
 }
Exemplo n.º 2
0
        public IActionResult Select()
        {
            var lastRefresh = (from refr in _context.LastRefresh
                               select refr).FirstOrDefault();

            if (lastRefresh == null)
            {
                // no refresh date exists; fetch with fetchAll = true
                Google.Apis.YouTube.Samples.YouTubeCaller.FetchVideos(_context, true);
                var refresh = new LastRefresh();
                refresh.RefreshDate = DateTime.Now;
                _context.Add(refresh);
                _context.SaveChanges();
            }
            else if (lastRefresh.RefreshDate.Date < DateTime.Today)
            {
                // refresh has happened, but not yet today... pull most recent 50 videos
                // (using fetchall=False)
                Google.Apis.YouTube.Samples.YouTubeCaller.FetchVideos(_context, false);
                lastRefresh.RefreshDate = DateTime.Now;
                _context.SaveChanges();
            }


            ViewBag.Vids = (from vid in _context.Video
                            orderby vid.PostedDate descending
                            select vid
                            );
            return(View());
        }