Beispiel #1
0
        public void UpdateGlobalRss()
        {
            var rssChannels    = this.updateRepository.LoadAllGlobalRssChannels();
            var rssEntriesList = new List <RssEntry>();

            foreach (var rssChannel in rssChannels)
            {
                try
                {
                    var syndicationEntries = this.syndicationFeedAdapter.Load(rssChannel.Url);

                    foreach (var item in syndicationEntries.Where(item => item.PublishDate > rssChannel.RssLastUpdatedTime))
                    {
                        var rssEntry = new RssEntry(
                            item.Id,
                            item.PublishDate,
                            item.Title,
                            item.Summary,
                            rssChannel.Id,
                            item.Url);
                        rssEntriesList.Add(rssEntry);
                    }

                    if (syndicationEntries.Any())
                    {
                        rssChannel.RssLastUpdatedTime = syndicationEntries.Max(d => d.PublishDate);
                    }

                    this.rssEntriesRepository.SaveToDatabase(rssEntriesList);

                    var rssChannelUpdated = new EventRssChannelUpdated
                    {
                        RssChannelId = rssChannel.Id
                    };

                    this.rssChannelsUpdatedRepository.SaveEvent(rssChannelUpdated);
                }
                catch (XmlException e)
                {
                    System.Diagnostics.Debug.WriteLine(e.Message);
                }
                catch (Exception e)
                {
                    System.Diagnostics.Debug.WriteLine(e.Message);
                }

                rssEntriesList.Clear();
            }

            this.rssChannelsRepository.UpdateRssLastUpdateTimeToDatabase(rssChannels);
            rssChannels.Clear();
        }
 public void SaveEvent(long eventRssChannelUpdated)
 {
     var rssChannelUpdated = new EventRssChannelUpdated { RssChannelId = eventRssChannelUpdated };
     this.database.RssChannelUpdates.Add(rssChannelUpdated);
     this.database.SaveChanges();
 }
 public void SaveEvent(EventRssChannelUpdated eventRssChannelUpdated)
 {
     this.database.RssChannelUpdates.Add(eventRssChannelUpdated);
     this.database.SaveChanges();
 }