コード例 #1
0
        public async Task <IEnumerable <UserNotification> > GetAllUserNotifications(long userId)
        {
            var userIdentifier = new UserIdentifier(1, userId);
            var notifications  = await _userNotificationManager.GetUserNotificationsAsync(userIdentifier);

            return(notifications);
        }
コード例 #2
0
        public async Task <List <UserNotificationDto> > GetUserNotificationsAsync()
        {
            var definitions = _notificationDefinitionManager.GetAll();

            //var notificationDescription = definitions.Any(x=>x.Name == )
            string GetDescription(string notificationName)
            {
                return(definitions.FirstOrDefault(x => x.Name == notificationName)?.DisplayName.Localize(_localizationContext) ?? notificationName);
            }

            var models = await _userNotificationManager.GetUserNotificationsAsync(LoginIdentifier, null);

            var list = models.Select(x => new UserNotificationDto
            {
                Id               = x.Id,
                State            = x.State,
                NotificationName = x.Notification.NotificationName,
                Description      = GetDescription(x.Notification.NotificationName),
                Severity         = x.Notification.Severity,
                CreationTime     = x.Notification.CreationTime,
                EntityId         = x.Notification.EntityId,
                EntityTypeName   = x.Notification.EntityTypeName
            }).ToList();

            return(list);
        }
コード例 #3
0
 /// <summary>
 ///     Gets notifications for a user.
 /// </summary>
 /// <param name="userNotificationManager">User notificaiton manager</param>
 /// <param name="user">User.</param>
 /// <param name="state">State</param>
 /// <param name="skipCount">Skip count.</param>
 /// <param name="maxResultCount">Maximum result count.</param>
 public static List <UserNotification> GetUserNotifications(this IUserNotificationManager userNotificationManager,
                                                            UserIdentifier user, UserNotificationState?state = null, int skipCount = 0,
                                                            int maxResultCount = int.MaxValue)
 {
     return
         (AsyncHelper.RunSync(
              () => userNotificationManager.GetUserNotificationsAsync(user, state, skipCount, maxResultCount)));
 }
コード例 #4
0
        /// <summary>
        /// 取得用户通知信息
        /// </summary>
        public async Task <NotificationsPagedResultDto> GetUserNotifications(GetUserNotificationsInput input)
        {
            var currentUserId = AbpSession.ToUserIdentifier();

            var totalCount = await _userNotificationManager
                             .GetUserNotificationCountAsync(currentUserId, input.State);

            var unreadCount = await _userNotificationManager
                              .GetUserNotificationCountAsync(currentUserId, UserNotificationState.Unread);

            var notifications = await _userNotificationManager
                                .GetUserNotificationsAsync(currentUserId, input.State, input.SkipCount, input.MaxResultCount);

            return(new NotificationsPagedResultDto(totalCount, unreadCount, notifications));
        }
コード例 #5
0
        public async Task <GetNotificationsOutput> GetUserNotifications(GetUserNotificationsInput input)
        {
            var totalCount = await _userNotificationManager.GetUserNotificationCountAsync(
                AbpSession.ToUserIdentifier(), input.State, input.StartDate, input.EndDate
                );

            var unreadCount = await _userNotificationManager.GetUserNotificationCountAsync(
                AbpSession.ToUserIdentifier(), UserNotificationState.Unread, input.StartDate, input.EndDate
                );

            var notifications = await _userNotificationManager.GetUserNotificationsAsync(
                AbpSession.ToUserIdentifier(), input.State, input.SkipCount, input.MaxResultCount, input.StartDate, input.EndDate
                );

            return(new GetNotificationsOutput(totalCount, unreadCount, notifications));
        }
コード例 #6
0
        public async Task <GetNotificationsOutput> GetUserNotifications(GetUserNotificationsInput input)
        {
            var totalCount = await _userNotificationManager.GetUserNotificationCountAsync(
                InfrastructureSession.ToUserIdentifier(), input.State
                );

            var unreadCount = await _userNotificationManager.GetUserNotificationCountAsync(
                InfrastructureSession.ToUserIdentifier(), UserNotificationState.Unread
                );

            var notifications = await _userNotificationManager.GetUserNotificationsAsync(
                InfrastructureSession.ToUserIdentifier(), input.State, input.SkipCount, input.PageSize
                );

            return(new GetNotificationsOutput(totalCount, unreadCount, notifications));
        }
コード例 #7
0
        public async Task <ListResultDto <UserNotificationDto> > GetListAsync(UserNotificationState?state = null, int skipCount = 0, int maxResultCount = int.MaxValue, DateTime?startDate = null, DateTime?endDate = null)
        {
            var result = await _userNotificationManager.GetUserNotificationsAsync(CurrentUser.Id.Value, state, skipCount, maxResultCount, startDate, endDate);

            return(new ListResultDto <UserNotificationDto>(
                       result.Select(un => new UserNotificationDto
            {
                UserId = un.UserNotification.UserId,
                NotificationId = un.UserNotification.NotificationId,
                NotificationName = un.Notification.NotificationName,
                NotificationDisplayName = _notificationDefinitionManager.Get(un.Notification.NotificationName).DisplayName.Localize(StringLocalizerFactory),
                Data = un.Notification.Data,
                EntityTypeName = un.Notification.EntityTypeName,
                EntityId = un.Notification.EntityId,
                Severity = un.Notification.Severity,
                State = un.UserNotification.State,
                CreationTime = un.Notification.CreationTime
            }).ToList()
                       ));
        }
コード例 #8
0
 public Task <List <UserNotification> > GetUserNotifications()
 {
     return(_userNotificationManager.GetUserNotificationsAsync(GetCurrentUserIdentifier()));
 }