public void PollforKynNotification() { var notificationTypes = _notificationTypeRepository.GetAll(); var notificationIsActive = notificationTypes.Any(nt => (nt.NotificationTypeAlias == NotificationTypeAlias.KynFirstNotification) && nt.IsActive); if (!notificationIsActive) { return; } const int pageSize = 50; int pageNumber = 1; while (true) { long totalRecords; var eventCustomers = _eventCustomerRepository.GetEventCustomersForKynFirstNotification(_daysAfterRegistration, pageNumber, pageSize, out totalRecords); if (eventCustomers == null || !eventCustomers.Any()) { _logger.Info("No Customers Found!"); break; } foreach (var eventCustomer in eventCustomers) { try { var corporateAccount = _corporateAccountRepository.GetbyEventId(eventCustomer.EventId); if (corporateAccount != null && !corporateAccount.AllowCustomerPortalLogin) { continue; } var notificationModel = _kynNotificationService.IsApplicableForNotification(eventCustomer); if (notificationModel != null) { _logger.Info(string.Format("Sending First Kyn Notification for Customer [Id:{0}] and Event[Id:{1}] ", eventCustomer.CustomerId, eventCustomer.EventId)); _notifier.NotifySubscribersViaEmail(NotificationTypeAlias.KynFirstNotification, EmailTemplateAlias.KynFirstNotification, notificationModel, notificationModel.UserId, eventCustomer.CustomerId, "Kyn First Notification"); } } catch (Exception ex) { _logger.Error(string.Format("Message:{0} \nStackTrace: {1}", ex.Message, ex.StackTrace)); } } if ((pageNumber * pageSize) >= totalRecords) { break; } pageNumber++; } }