Exemple #1
0
        /// <summary>
        /// 推送消息
        /// </summary>
        private void PushNotification()
        {
            //获取所有待发送的通知,定时拉取方式
            var notifications = _notificationQueryService.Notifications().Where(x => !x.IsSmsed || !x.IsMessaged);

            if (notifications.Any())
            {
                foreach (var notification in notifications)
                {
                    if (!notification.IsSmsed)
                    {//发送短信
                        SendSm(notification);
                    }
                    if (!notification.IsMessaged)
                    {//发送微信模板消息
                        SendTemplateMsg(notification);
                    }
                    //设置已发送
                    var command = new SetNotificationSmsedCommand {
                        AggregateRootId = notification.Id
                    };
                    _commandService.SendAsync(command);
                }
            }
        }
 public void Handle(ICommandContext context, SetNotificationSmsedCommand command)
 {
     context.Get <Notification>(command.AggregateRootId).SetSmsed();
 }