private NotifierSettingModel <PopupNotifierTemplate> GetSettings() { return(_notificationSettingsService.Get <PopupNotifierTemplate>( new ActivityEventNotifierIdentity( new ActivityEventIdentity(CommunicationTypeEnum.Member, NotificationTypeEnum.Welcome), NotifierTypeEnum.PopupNotifier))); }
public void Notify(NotifierData data) { var identity = GetSettingsIdentity(data); var settings = _notificationSettingsService.Get <EmailNotifierTemplate>(identity); if (!settings.IsEnabled) { return; } var receivers = _intranetMemberService.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 Sql.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, IntranetActivityTypeEnum.ContentPage); var identity = new ActivityEventIdentity(isCommunicationSettings ? CommunicationTypeEnum.CommunicationSettings : data.ActivityType, data.NotificationType) .AddNotifierIdentity(Type); var settings = _notificationSettingsService.Get <UiNotifierTemplate>(identity); 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).ToList(); 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; if (uiMsg.NotifierId.HasValue) { uiMsg.NotifierPhotoUrl = _intranetMemberService.Get(uiMsg.NotifierId.Value)?.Photo; } } return(uiMsg); }); _notificationsService.Notify(messages); }
internal UiNotificationMessage GetUiNotificationMessage( Guid receiverId, Enum activityType, Enum notificationType, INotifierDataValue newValue) { var notificationIdentity = new ActivityEventNotifierIdentity(activityType, notificationType, UiNotifierType); var template = _notificationSettingsService.Get <UiNotifierTemplate>(notificationIdentity).Template; var receiver = _intranetMemberService.Get(receiverId); var message = _notificationModelMapper.Map(newValue, template, receiver); return(message); }
public void Notify(NotifierData data) { var identity = new ActivityEventIdentity(CommunicationTypeEnum.Member, data.NotificationType).AddNotifierIdentity(Type); var settings = _notificationSettingsService.Get <PopupNotifierTemplate>(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 CreateAndSendMail() { var currentDate = DateTime.UtcNow; var allUsers = _intranetMemberService.GetAll(); var monthlyMails = allUsers .Select(user => user.Id.Pipe(GetUserActivitiesFilteredByUserTags) .Pipe(userActivities => TryGetMonthlyMail(userActivities, user))) .ToList(); var identity = new ActivityEventIdentity( CommunicationTypeEnum.CommunicationSettings, NotificationTypeEnum.MonthlyMail) .AddNotifierIdentity(NotifierTypeEnum.EmailNotifier); var settings = _notificationSettingsService.Get <EmailNotifierTemplate>(identity); if (!settings.IsEnabled) { return; } foreach (var monthlyMail in monthlyMails) { monthlyMail.Do(some: mail => { var mailModel = GetMonthlyMailModel(mail.user, mail.monthlyMail, settings.Template); try { _mailService.SendMailByTypeAndDay( mailModel, mail.user.Email, currentDate, NotificationTypeEnum.MonthlyMail); } catch (Exception ex) { _logger.Error <MonthlyEmailServiceBase>(ex); } }); } }
private NotifierSettingModel <EmailNotifierTemplate> GetEmailNotifierSettings(Enum activityType, Enum notificationType) { return(_notificationSettingsService.Get <EmailNotifierTemplate>(GetActivityEventNotifierIdentity(NotifierTypeEnum.EmailNotifier, activityType, notificationType))); }