예제 #1
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));
        }
예제 #2
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));
        }
예제 #3
0
        public async Task GetUserNotificationCountAsync_Test()
        {
            var notificationCount = await _userNotificationManager.GetUserNotificationCountAsync(
                new UserIdentifier(1, 2), UserNotificationState.Read
                );

            notificationCount.ShouldBeGreaterThanOrEqualTo(0);
        }
예제 #4
0
        public async Task <GetCurrentLoginInformationsOutput> GetCurrentLoginInformations()
        {
            var output = new GetCurrentLoginInformationsOutput
            {
                Application = new ApplicationInfoDto
                {
                    Version     = AppVersionHelper.Version,
                    ReleaseDate = AppVersionHelper.ReleaseDate,
                    Features    = new Dictionary <string, bool>
                    {
                    }
                }
            };

            if (AbpSession.TenantId.HasValue)
            {
                var tenant = _tenantCache.Get(AbpSession.GetTenantId());
                output.Tenant = ObjectMapper.Map <TenantLoginInfoDto>(tenant);

                //output.Tenant = ObjectMapper
                //                    .Map<TenantLoginInfoDto>(await TenantManager
                //                        .Tenants
                //                        .Include(t => t.Edition)
                //                        .FirstAsync(t => t.Id == AbpSession.GetTenantId()));

                //output.Tenant.LogoUrl = await _pictureManager.GetPictureUrlAsync(output.Tenant.LogoId);
            }

            if (AbpSession.UserId.HasValue)
            {
                var userLoginInfo = await GetCurrentUserAsync();

                var account = await GetCurrentUserAccountCacheAsync();

                output.User = ObjectMapper.Map <UserLoginInfoDto>(userLoginInfo);
                output.User.ProfilePictureUrl       = (account != null ? await _pictureManager.GetPictureUrlAsync(account.ProfilePictureId) : string.Empty);
                output.User.UnreadNotificationCount = await _userNotificationManager.GetUserNotificationCountAsync(
                    AbpSession.ToUserIdentifier(), UserNotificationState.Unread);
            }

            if (output.Tenant == null)
            {
                return(output);
            }

            if (output.Tenant.Edition != null)
            {
                // 是否最高版本
                output.Tenant.Edition.IsHighestEdition = await IsEditionHighest(output.Tenant.Edition.Id);
            }

            output.Tenant.SubscriptionDateString = GetTenantSubscriptionDateString(output);
            output.Tenant.CreationTimeString     = output.Tenant.CreationTime.ToString("d");

            return(output);
        }
 /// <summary>
 /// Gets user notification count.
 /// </summary>
 /// <param name="userNotificationManager">User notificaiton manager</param>
 /// <param name="user">User.</param>
 /// <param name="state">State.</param>
 public static int GetUserNotificationCount(this IUserNotificationManager userNotificationManager, UserIdentifier user, UserNotificationState?state = null)
 {
     return(AsyncHelper.RunSync(() => userNotificationManager.GetUserNotificationCountAsync(user, state)));
 }
예제 #6
0
 public async Task <int> GetCountAsync(UserNotificationState?state = null, DateTime?startDate = null, DateTime?endDate = null)
 {
     return(await _userNotificationManager.GetUserNotificationCountAsync(CurrentUser.Id.Value, state, startDate, endDate));
 }