Exemple #1
0
 private void OnNewHeaderAdding()
 {
     Hub.Default.Subscribe((List <NewsLine> headers) =>
     {
         Task.Run(async() =>
         {
             var subscriptions = SubscriptionRepository.GetAllSubscriptions();
             var messages      = headers.SelectMany(m =>
                                                    subscriptions.Where(s => s.LastArticleTime == null || s.LastArticleTime.Value < m.GetTime())
                                                    .Select(subscription => new SubscriptionMessage(subscription, m))).ToList();
             await TelegramService.SendMessages(messages);
             UpdateLastArticleTimes(subscriptions, messages);
         }).GetAwaiter().GetResult();
     });
 }