private static async Task <IDictionary <Guid, int> > UpdateDownloadedFeedsAsync(IDictionary <Guid, Feed> subscribedFeeds, string fileName, IPersistentManager dbContext) { var feedsUpdated = await dbContext.ReadSerializedCopyAsync <List <Feed> >(fileName); if (feedsUpdated == null || feedsUpdated.Count == 0) { return(null); } var updatedFeeds = new Dictionary <Guid, int>(); feedsUpdated.ForEach(f => { if (!subscribedFeeds.ContainsKey(f.Id)) { return; } var persistentFeed = subscribedFeeds[f.Id]; var updatedItemCount = FeedHelper.UpdateFeedItems(persistentFeed, f.Items); if (updatedItemCount > 0) { updatedFeeds.Add(persistentFeed.Id, updatedItemCount); } persistentFeed.LastUpdatedTime = f.LastUpdatedTime; }); return(updatedFeeds); }
public async Task <int> UpdateItemsAsync(Feed feed) { try { var updatedFeed = await GetFeedResultAsync(feed.Link.ToString()); if (updatedFeed == null || updatedFeed.Items.Count == 0) { return(0); } updatedFeed.Publisher.Id = feed.Publisher.Id; TailorFeed(updatedFeed); return(FeedHelper.UpdateFeedItems(feed, updatedFeed.Items)); } catch (Exception ex) { throw new ApplicationException("feedUrl: " + feed.Link, ex); } }