Example #1
0
        public async Task <MemoryStream> Export()
        {
            //FileStream fs = new FileStream("C:\\Users\\jm\\Desktop\\委托和事件\\1.txt", FileMode.OpenOrCreate, FileAccess.Read);

            UserNotification not = new UserNotification();

            not.Id       = Guid.NewGuid();
            not.TenantId = 1;
            not.State    = UserNotificationState.Unread;
            //not.Notification
            TenantNotification tenNot = new TenantNotification();

            tenNot.TenantId         = 1;
            tenNot.Id               = Guid.NewGuid();
            tenNot.NotificationName = "export";
            Dictionary <string, object> s = new Dictionary <string, object>();

            s.Add("message", "我的通知");
            tenNot.Data = new NotificationData()
            {
                Properties = s
            };
            UserNotification[] notArray = { not };
            _not.SendNotificationsAsync(notArray);

            byte[]       buff = File.ReadAllBytes("C:\\Users\\jm\\Desktop\\委托和事件\\1.txt");
            MemoryStream ms   = new MemoryStream(buff);

            return(ms);
        }
        public async Task DistributeAsync(long notificationId)
        {
            var notificationScheme = await _notificationRepository.GetNotificationSchemeOrNullAsync(notificationId);

            if (notificationScheme == null)
            {
                Logger.LogWarning("NotificationDistributionJob can not continue since could not found notification by id: " + notificationId);
                return;
            }

            var userIds = await GetUserIds(notificationScheme);

            var userNotifications = await SaveUserNotifications(userIds, notificationScheme);

            await _notificationRepository.DeleteNotificationAsync(notificationScheme);

            await _notificationRepository.SaveChangesAsync();

            try
            {
                await _realTimeNotifier.SendNotificationsAsync(userNotifications.ToArray());
            }
            catch (Exception ex)
            {
                Logger.LogWarning(ex.ToString(), ex);
            }
        }
Example #3
0
        /// <summary>
        /// 通知管理有心任务来了
        /// </summary>
        /// <param name="order"></param>
        /// <returns></returns>
        private async Task NotificationToAdmin(WOrder_Order order)
        {
            UserNotification userNotification = new UserNotification();
            NotificationData notificationData = new NotificationData();

            notificationData["category"]  = order.Category;
            notificationData["title"]     = order.ItemName;
            userNotification.Notification =
                new TenantNotification()
            {
                CreationTime     = DateTime.Now,
                NotificationName = "新消息",
                Severity         = NotificationSeverity.Info,
                Data             = notificationData
            };
            userNotification.TenantId = AbpSession.GetTenantId();
            //通知管理员
            userNotification.UserId = 1;
            userNotification.Id     = Guid.NewGuid();
            //实时通知
            await _realTimeNotifier.SendNotificationsAsync(new UserNotification[] { userNotification });

            //记录消息
            await _messageService.Create(new CreateMessageInput()
            {
                Title   = order.Category,
                Content = order.ItemName,
                UserId  = 1,
                //派单
                AppPage = "Assign",
                SrcId   = order.Id
            });
        }
Example #4
0
        public async Task <RegisterOutput> Register(RegisterInput input)
        {
            var user = await _userRegistrationManager.RegisterAsync(
                input.Name,
                input.Surname,
                input.EmailAddress,
                input.UserName,
                input.Password,
                true // Assumed email address is always confirmed. Change this if you want to implement email confirmation.
                );

            _notificationSubscriptionManager.SubscribeToAllAvailableNotifications(user.ToUserIdentifier());
            await _appNotifier.WelcomeToTheApplicationAsync(user);


            var notification = _userNotificationManager.GetUserNotifications(user.ToUserIdentifier());

            await _realTimeNotifier.SendNotificationsAsync(notification.ToArray());

            var isEmailConfirmationRequiredForLogin = await SettingManager.GetSettingValueAsync <bool>(AbpZeroSettingNames.UserManagement.IsEmailConfirmationRequiredForLogin);

            return(new RegisterOutput
            {
                CanLogin = user.IsActive && (user.IsEmailConfirmed || !isEmailConfirmationRequiredForLogin)
            });
        }
Example #5
0
        public void SendNotify()
        {
            IRealTimeNotifier rtf = TwinkleContext.GetService <IRealTimeNotifier>();

            rtf.SendNotificationsAsync(new UserNotification[] {
                new UserNotification {
                    UserId = "admin", Data = new NotifyData {
                        Channel = "test", Data = new { key = "key", num = 2 }
                    }
                }
            });
        }
        /// <summary>
        /// 发送点对点消息
        /// </summary>
        /// <param name="recipientId"></param>
        /// <param name="chatDetailed"></param>
        /// <param name="severity"></param>
        /// <returns></returns>
        public virtual async Task SendChatAsync(long recipientId, string chatDetailed, NotificationSeverity severity = NotificationSeverity.Info)
        {
            UserIdentifier userIdentifier = new UserIdentifier(AbpSessionExtens.TenantId, recipientId);
            //用户不在线直接返回
            var onlineClients = _onlineClientManager.GetAllByUserId(userIdentifier);

            if (onlineClients == null || onlineClients.Count == 0)
            {
                return;
            }

            UserInfo userModel     = _cacheManagerExtens.GetUserInfoCache(recipientId);
            string   promptContent = "您有一条来自[" + userModel.UserNameCn + "]的消息";
            string   promptTitle   = "您有一条新消息";

            FrameNotificationData frameNotificationData = new FrameNotificationData(promptContent);

            frameNotificationData.NotificationType     = "chat"; //推送的类型用于前端JS判断
            frameNotificationData.Title                = promptTitle;
            frameNotificationData.NotificationDetailed = chatDetailed;
            frameNotificationData.SendId               = AbpSessionExtens.UserId.Value;

            TenantNotification tenantNotification = new TenantNotification()
            {
                Id               = Guid.NewGuid(),
                Data             = frameNotificationData,
                Severity         = severity,
                NotificationName = "站内短信",
                TenantId         = userIdentifier.TenantId,
                CreationTime     = DateTime.Now
            };

            List <UserNotification> userNotification = new List <UserNotification>();

            userNotification.Add(
                new UserNotification
            {
                Id           = Guid.NewGuid(),
                Notification = tenantNotification,
                UserId       = userIdentifier.UserId,
                State        = UserNotificationState.Unread,
                TenantId     = userIdentifier.TenantId
            });

            await _realTimeNotifier.SendNotificationsAsync(userNotification.ToArray());
        }
Example #7
0
        private async Task NotificationToAdmin(CreateUserInput user)
        {
            UserNotification userNotification = new UserNotification();
            NotificationData notificationData = new NotificationData();

            notificationData["category"]  = $"姓名:{user.UserName}";
            notificationData["title"]     = "请帮忙审核";
            userNotification.Notification =
                new TenantNotification()
            {
                CreationTime     = DateTime.Now,
                NotificationName = "人员注册提醒",
                Severity         = NotificationSeverity.Info,
                Data             = notificationData
            };
            userNotification.TenantId = AbpSession.GetTenantId();
            //通知管理员
            userNotification.UserId = 1;
            userNotification.Id     = Guid.NewGuid();
            await _realTimeNotifier.SendNotificationsAsync(new UserNotification[] { userNotification });
        }
Example #8
0
        private void SendToClient(ReportArgs args, int status = 0)
        {
            string token = TwinkleContext.UserToken;

            AuthUser user = TwinkleContext.GetService <TokenAuthManager>().GetUser(token);

            IRealTimeNotifier rtf = TwinkleContext.GetService <IRealTimeNotifier>();

            rtf.SendNotificationsAsync(new UserNotification[] {
                new UserNotification {
                    TenantId = user.TenantId,
                    UserId   = user.UserId,
                    Data     = new NotifyData {
                        Channel = "signalr.reveive",
                        Data    = new {
                            uploadId = TwinkleContext.HttpContext.Request.Form["uploadId"].ToString(),//有待测试验证
                            message  = args.Message,
                            status   = args.Status
                        }
                    }
                }
            });
        }