Пример #1
0
        protected virtual async Task SendFriendValidationNotifierAsync(UserChatFriend userChatFriend)
        {
            // 发送好友验证通知
            var userIdentifer = new UserIdentifier(userChatFriend.FrientId, userChatFriend.RemarkName);

            var friendValidationNotifictionData = new NotificationData();

            friendValidationNotifictionData
            .WriteLocalizedData(
                new LocalizableStringInfo(
                    LocalizationResourceNameAttribute.GetName(typeof(MessageServiceResource)),
                    "Notifications:FriendValidation"),
                new LocalizableStringInfo(
                    LocalizationResourceNameAttribute.GetName(typeof(MessageServiceResource)),
                    "Notifications:RequestAddNewFriend",
                    new Dictionary <object, object> {
                { "name", _currentUser.UserName }
            }),
                DateTime.Now,
                _currentUser.UserName,
                new LocalizableStringInfo(
                    LocalizationResourceNameAttribute.GetName(typeof(MessageServiceResource)),
                    "Notifications:RequestAddNewFriendDetail",
                    new Dictionary <object, object> {
                { "description", userChatFriend.Description }
            }));
            friendValidationNotifictionData.TrySetData("userId", userChatFriend.UserId);
            friendValidationNotifictionData.TrySetData("frientId", userChatFriend.FrientId);

            await _notificationSender
            .SendNofiterAsync(
                MessageServiceNotificationNames.IM.FriendValidation,
                friendValidationNotifictionData,
                userIdentifer,
                userChatFriend.TenantId);
        }
Пример #2
0
        public async Task HandleEventAsync(EntityCreatedEventData <UserEto> eventData)
        {
            var userIdentifer = new UserIdentifier(eventData.Entity.Id, eventData.Entity.UserName);
            // 订阅用户欢迎消息
            await _notificationSubscriptionManager
            .SubscribeAsync(
                eventData.Entity.TenantId,
                userIdentifer,
                UserNotificationNames.WelcomeToApplication);

            var userWelcomeNotifictionData = new NotificationData();

            //userWelcomeNotifictionData.WriteStandardData(
            //    L("WelcomeToApplicationFormUser", eventData.Entity.Name ?? eventData.Entity.UserName),
            //    L("WelcomeToApplicationFormUser", eventData.Entity.Name ?? eventData.Entity.UserName),
            //    DateTime.Now, eventData.Entity.UserName);

            userWelcomeNotifictionData
            .WriteLocalizedData(
                new LocalizableStringInfo(
                    LocalizationResourceNameAttribute.GetName(typeof(MessageServiceResource)),
                    "WelcomeToApplicationFormUser"),
                new LocalizableStringInfo(
                    LocalizationResourceNameAttribute.GetName(typeof(MessageServiceResource)),
                    "WelcomeToApplicationFormUser"),
                DateTime.Now, eventData.Entity.UserName);

            await _notificationSender
            .SendNofiterAsync(
                UserNotificationNames.WelcomeToApplication,
                userWelcomeNotifictionData,
                userIdentifer,
                eventData.Entity.TenantId,
                NotificationSeverity.Info
                );
        }