public ExecutionResult Execute() { var settings = _notificationSettingsService.Get <PopupNotifierTemplate>( new ActivityEventNotifierIdentity( CommunicationTypeEnum.Member, NotificationTypeEnum.Welcome, NotifierTypeEnum.PopupNotifier)); settings.IsEnabled = false; _notificationSettingsService.Save(settings); return(ExecutionResult.Success); }
public void Notify(NotifierData data) { var identity = GetSettingsIdentity(data); var settings = _notificationSettingsService.Get <EmailNotifierTemplate>(identity); if (!settings.IsEnabled) { return; } var receivers = _intranetUserService.GetMany(data.ReceiverIds).ToList(); foreach (var receiverId in data.ReceiverIds) { var user = receivers.Find(receiver => receiver.Id == receiverId); var message = _notificationModelMapper.Map(data.Value, settings.Template, user); _mailService.Send(message); _notificationRepository.Add(new global::Uintra.Notification.Notification() { Id = Guid.NewGuid(), Date = DateTime.UtcNow, IsNotified = true, IsViewed = false, Type = data.NotificationType.ToInt(), NotifierType = NotifierTypeEnum.EmailNotifier.ToInt(), Value = new { message }.ToJson(), ReceiverId = receiverId }); } }
public void Notify(NotifierData data) { var isCommunicationSettings = data.NotificationType.In( NotificationTypeEnum.CommentLikeAdded, NotificationTypeEnum.MonthlyMail); //TODO: temporary for communication settings var identity = new ActivityEventIdentity(isCommunicationSettings ? CommunicationTypeEnum.CommunicationSettings : data.ActivityType, data.NotificationType) .AddNotifierIdentity(Type); var settings = _notificationSettingsService.Get <EmailNotifierTemplate>(identity); if (settings == null || !settings.IsEnabled) { return; } var receivers = _intranetUserService.GetMany(data.ReceiverIds).ToList(); foreach (var receiverId in data.ReceiverIds) { var user = receivers.Find(receiver => receiver.Id == receiverId); var message = _notificationModelMapper.Map(data.Value, settings.Template, user); _mailService.Send(message); } }
public void Notify(NotifierData data) { var isCommunicationSettings = data.NotificationType.In( NotificationTypeEnum.CommentLikeAdded, NotificationTypeEnum.MonthlyMail) || //TODO: temporary for communication settings data.ActivityType.In( IntranetActivityTypeEnum.ContentPage, IntranetActivityTypeEnum.PagePromotion); var identity = new ActivityEventIdentity(isCommunicationSettings ? CommunicationTypeEnum.CommunicationSettings : data.ActivityType, data.NotificationType) .AddNotifierIdentity(Type); var settings = _notificationSettingsService.Get <UiNotifierTemplate>(identity); if (settings == null || !settings.IsEnabled) { return; } var receivers = _intranetUserService.GetMany(data.ReceiverIds); var messages = receivers.Select(r => _notificationModelMapper.Map(data.Value, settings.Template, r)); _notificationsService.Notify(messages); }
public void Notify(NotifierData data) { var isCommunicationSettings = data.NotificationType.In( NotificationTypeEnum.CommentLikeAdded, NotificationTypeEnum.MonthlyMail, IntranetActivityTypeEnum.ContentPage, IntranetActivityTypeEnum.PagePromotion); var identity = new ActivityEventIdentity(isCommunicationSettings ? CommunicationTypeEnum.CommunicationSettings : data.ActivityType, data.NotificationType) .AddNotifierIdentity(Type); var settings = _notificationSettingsService.Get <UiNotifierTemplate>(identity); //if (settings == null) return; var desktopSettingsIdentity = new ActivityEventIdentity(settings.ActivityType, settings.NotificationType) .AddNotifierIdentity(NotifierTypeEnum.DesktopNotifier); var desktopSettings = _notificationSettingsService.Get <DesktopNotifierTemplate>(desktopSettingsIdentity); if (!settings.IsEnabled && !desktopSettings.IsEnabled) { return; } var receivers = _intranetMemberService.GetMany(data.ReceiverIds); var messages = receivers.Select(receiver => { var uiMsg = _notificationModelMapper.Map(data.Value, settings.Template, receiver); if (desktopSettings.IsEnabled) { var desktopMsg = _desktopNotificationModelMapper.Map(data.Value, desktopSettings.Template, receiver); uiMsg.DesktopTitle = desktopMsg.Title; uiMsg.DesktopMessage = desktopMsg.Message; uiMsg.IsDesktopNotificationEnabled = true; } return(uiMsg); }); _notificationsService.Notify(messages); }