예제 #1
0
 public async Task ValidateAsync(MessageNotificationConfig config)
 {
     if (config == null)
     {
         throw new ArgumentNullException(nameof(config));
     }
     if (config.Enabled)
     {
         if (config.DelayStart < Consts.AppConsts.DELAY_MIN)
         {
             throw new ArgumentOutOfRangeException(nameof(config.DelayStart), $"Minimum value is {Consts.AppConsts.DELAY_MIN}");
         }
         if (config.DelayStart > Consts.AppConsts.DELAY_MAX)
         {
             throw new ArgumentOutOfRangeException(nameof(config.DelayStart), $"Maximum value is {Consts.AppConsts.DELAY_MAX}");
         }
         if (config.RunInterval < Consts.AppConsts.INTERVAL_MIN)
         {
             throw new ArgumentOutOfRangeException(nameof(config.RunInterval), $"Minimum value is {Consts.AppConsts.INTERVAL_MIN}");
         }
         if (config.RunInterval > Consts.AppConsts.INTERVAL_MAX)
         {
             throw new ArgumentOutOfRangeException(nameof(config.RunInterval), $"Maximum value is {Consts.AppConsts.INTERVAL_MAX}");
         }
         if (string.IsNullOrWhiteSpace(config.From))
         {
             throw new ArgumentNullException(nameof(config.From));
         }
         if (string.IsNullOrWhiteSpace(config.Display))
         {
             throw new ArgumentNullException(nameof(config.Display));
         }
         if (config.Limit < AppConsts.MESSAGES_LIMIT_MIN)
         {
             throw new ArgumentOutOfRangeException(nameof(config.Limit), $"Minimum value is {AppConsts.MESSAGES_LIMIT_MIN}");
         }
         if (config.Limit > AppConsts.MESSAGES_LIMIT_MAX)
         {
             throw new ArgumentOutOfRangeException(nameof(config.Limit), $"Maximum value is {AppConsts.MESSAGES_LIMIT_MAX}");
         }
         if (config.MessageRecipients == null || config.MessageRecipients.Count == 0)
         {
             throw new ArgumentNullException(nameof(config.MessageRecipients));
         }
         foreach (var messageRecipient in config.MessageRecipients)
         {
             await this.messageRecipientValidator.ValidateAsync(messageRecipient);
         }
     }
 }
예제 #2
0
 public override ServiceResult<MessageEntity> Add(MessageEntity item)
 {
     ServiceResult<MessageEntity> result = base.Add(item);
     MessageNotificationConfig notifyConfig = _applicationSettingService.Get<MessageNotificationConfig>();
     if (notifyConfig.MessageNotifyEmails.IsNotNullAndWhiteSpace())
     {
         _notificationManager.Send(new RazorEmailNotice
         {
             Subject = "新的留言提醒",
             To = notifyConfig.MessageNotifyEmails.Split(new char[] { '\r', '\n', ',', ';' }, StringSplitOptions.RemoveEmptyEntries),
             Model = item,
             TemplatePath = "~/wwwroot/Plugins/ZKEACMS.Message/EmailTemplates/MessageNotification.cshtml"
         });
     }
     return result;
 }
        public void Handle(object entity, EventArg e)
        {
            Comments item = entity as Comments;

            if (item != null)
            {
                MessageNotificationConfig notifyConfig = _applicationSettingService.Get <MessageNotificationConfig>();
                if (notifyConfig.CommentNotifyEmails.IsNotNullAndWhiteSpace())
                {
                    _notificationManager.Send(new RazorEmailNotice
                    {
                        Subject      = _localize.Get("New comment"),
                        To           = notifyConfig.CommentNotifyEmails.Split(new char[] { '\r', '\n', ',', ';' }, StringSplitOptions.RemoveEmptyEntries),
                        Model        = item,
                        TemplatePath = "~/wwwroot/Plugins/ZKEACMS.Message/EmailTemplates/CommentNotification.cshtml"
                    });
                }
            }
        }
예제 #4
0
 public AppConfigBuilder WithMessageNotification(MessageNotificationConfig messageNotificationConfig)
 {
     this.Obj.MessageNotification = messageNotificationConfig;
     return(this);
 }