public void SeedShow(string sourceId) { Logger.Info(string.Format("Seeding show: {0}", sourceId)); var cache = _session .Load<ShowInfoCache>(ShowInfoCache.IdFromSourceId(sourceId)); if (cache == null) { Logger.Warn(string.Format("Show {0} could not be seeded because it's not in the name cache", sourceId)); return; } var source = new EpGuideShowSource(); var show = source.FetchShowFromEpGuide(sourceId, cache); _session.Store(show); _eventSink("watchlist"); }
public void UpdateShows() { var lastFreshDate = DateTimeOffset.UtcNow.AddDays(-1); var showsNeedingUpdate = _session .Query<Show>() .Where(x => !x.HasEnded && x.LastUpdate < lastFreshDate) .ToList(); var source = new EpGuideShowSource(); var updatedShows = new ConcurrentBag<Tuple<Show, Show>>(); Parallel.ForEach( showsNeedingUpdate, x => updatedShows.Add(Tuple.Create(x, source.FetchShowFromEpGuide(x.SourceId, x)))); foreach (var i in updatedShows.Where(x => x.Item1 != null)) { var originalShow = i.Item1; var updatedShow = i.Item2; _session.Advanced.Evict(originalShow); _session.Store(updatedShow); } _eventSink("watchlist"); }