Exemple #1
0
 private int GetRssFeedItems(RssFeed feed, Subscription subscription)
 {
     var itemsAdded = 0;
     foreach (var rssItem in feed.Channel.Items.Where(x => subscription.LastFeedUpdatesUTC == null
         || x.PublicationDate.ToUniversalTime() > subscription.LastFeedUpdatesUTC))
     {
         var categories = rssItem.Categories.Aggregate(String.Empty, (current, category) => current + (category.Value + ",")).TrimEnd(',');
         var subscriptionPost = new SubscriptionPost
                                    {
                                        Categories = categories,
                                        OriginalUrl = rssItem.Link.ToString(),
                                        PublishDateUTC = GetGoodDateTime(rssItem.PublicationDate.ToUniversalTime()),
                                        Subscription = subscription,
                                        Title = rssItem.Title,
                                        Content = GetRssContent(rssItem),
                                        Authors = GetRssAuthors(rssItem)
                                    };
         itemsAdded++;
         _dbContext.SubscriptionPosts.Add(subscriptionPost);
         subscription.SubscriptionPosts.Add(subscriptionPost);
     }
     return itemsAdded;
 }
Exemple #2
0
 private int GetAtomFeedItems(AtomFeed feed, Subscription subscription)
 {
     var itemsAdded = 0;
     foreach (var entry in feed.Entries.Where(x => subscription.LastFeedUpdatesUTC == null
         || x.PublishedOn.ToUniversalTime() > subscription.LastFeedUpdatesUTC))
     {
         var categories = entry.Categories.Aggregate(String.Empty, (current, category) => current + (category.Label + ",")).TrimEnd(',');
         var authors = entry.Authors.Aggregate(String.Empty, (current, author) => current + (author.Name + ",")).TrimEnd(',');
         var subscriptionPost = new SubscriptionPost
                                    {
                                        Authors = authors,
                                        Categories = categories,
                                        Content = entry.Content != null ? entry.Content.Content : (entry.Summary != null) ? entry.Summary.Content : String.Empty,
                                        OriginalUrl = GetOriginalUrl(entry),
                                        PublishDateUTC = GetGoodDateTime(entry.PublishedOn.ToUniversalTime()),
                                        Subscription = subscription,
                                        Title = entry.Title.Content
                                    };
         itemsAdded++;
         _dbContext.SubscriptionPosts.Add(subscriptionPost);
         subscription.SubscriptionPosts.Add(subscriptionPost);
     }
     return itemsAdded;
 }