Beispiel #1
0
        /// <summary>
        /// 获取当前账号版本信息
        /// </summary>
        /// <returns></returns>
        public async Task <EditionsViewOutput> GetCurrentEdition()
        {
            var features = FeatureManager
                           .GetAll()
                           .Where(feature => (feature[FeatureMetadata.CustomFeatureKey] as FeatureMetadata)?.IsVisibleOnPricingTable ?? false);

            var flatFeatures = ObjectMapper
                               .Map <List <FlatFeatureSelectDto> >(features)
                               .OrderBy(f => f.DisplayName)
                               .ToList();

            var tenant = _tenantCache.Get(AbpSession.GetTenantId());
            SubscribableEditionCacheItem edition;

            if (tenant.EditionId.HasValue)
            {
                edition = await _subscribableEditionCache.GetAsync(tenant.EditionId.Value);
            }
            else
            {
                edition = await _subscribableEditionCache.GetDefaultAsync();
            }

            var featureDictionary = features.ToDictionary(feature => feature.Name, f => f);

            return(new EditionsViewOutput
            {
                AllFeatures = flatFeatures,
                EditionWithFeatures = await CreateEditionWithFeaturesDto(edition, featureDictionary),
            });
        }
Beispiel #2
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);
        }