public void InspectAlert(Alert alert) { bool condionAns = socialMediaManager.VerifyCondition(alert); int notificationNmr = 1; if (condionAns == true) { AlertType type = alert.Type; if (type != AlertType.mail) { //TODO controleer of notification al in database is opgenomen if (!alertRepository.NotificationExists(alert.AlertId)) { Notification notification = new Notification() { NotificationId = notificationNmr, DateTime = DateTime.Now, Alert = alert }; alertRepository.CreateNotification(notification); alert.Notifications.Add(notification); //TODO klopt niet, moet een user wel als attribuut in Alert opgenomen worden? alertRepository.UpdateAlert(alert); notificationNmr++; } } if (type != AlertType.notification) { this.SendMail(alert); } } }
private void CompareSentimentWithSelf(Alert alert) { double newSentiment = socialMediaRepository.ReadAverageSentimentFromItem(alert.Item, DateTime.Now, DateTime.Now.AddHours(-FREQUENTIE)); double oldSentiment = socialMediaRepository.ReadAverageSentimentFromItem(alert.Item, DateTime.Now.AddHours(-FREQUENTIE), DateTime.Now.AddHours(-(FREQUENTIE * 2))); if (newSentiment >= oldSentiment * (alert.ConditionPerc / 100)) { Notification n = new Notification() { DateTime = DateTime.Now, Alert = alert }; n.Content = String.Format("{0} wordt nu {1}% positiever gezien dan eerder", alert.Item.Name, alert.ConditionPerc); alertRepository.CreateNotification(n); alert.Notifications.Add(n); alertRepository.UpdateAlert(alert); SendAlert(alert, n); } ; }