Exemplo n.º 1
0
        private async Task <TenantManagementSettingsEditDto> GetTenantManagementSettingsAsync()
        {
            var settings = new TenantManagementSettingsEditDto
            {
                AllowSelfRegistration =
                    await SettingManager.GetSettingValueAsync <bool>(AppSettings.TenantManagement.AllowSelfRegistration),
                IsNewRegisteredTenantActiveByDefault =
                    await SettingManager.GetSettingValueAsync <bool>(AppSettings.TenantManagement
                                                                     .IsNewRegisteredTenantActiveByDefault),
                UseCaptchaOnRegistration =
                    await SettingManager.GetSettingValueAsync <bool>(AppSettings.TenantManagement
                                                                     .UseCaptchaOnRegistration),
            };

            var defaultEditionId =
                await SettingManager.GetSettingValueAsync(AppSettings.TenantManagement.DefaultEdition);

            if (!string.IsNullOrEmpty(defaultEditionId) &&
                (await _editionManager.FindByIdAsync(Convert.ToInt32(defaultEditionId)) != null))
            {
                settings.DefaultEditionId = Convert.ToInt32(defaultEditionId);
            }

            return(settings);
        }
Exemplo n.º 2
0
        private async Task UpdateTenantManagementAsync(TenantManagementSettingsEditDto settings)
        {
            await SettingManager.ChangeSettingForApplicationAsync(
                AppSettings.TenantManagement.AllowSelfRegistration,
                settings.AllowSelfRegistration.ToString(CultureInfo.InvariantCulture)
                .ToLower(CultureInfo.InvariantCulture)
                );

            await SettingManager.ChangeSettingForApplicationAsync(
                AppSettings.TenantManagement.IsNewRegisteredTenantActiveByDefault,
                settings.IsNewRegisteredTenantActiveByDefault.ToString(CultureInfo.InvariantCulture)
                .ToLower(CultureInfo.InvariantCulture)
                );

            await SettingManager.ChangeSettingForApplicationAsync(
                AppSettings.TenantManagement.UseCaptchaOnRegistration,
                settings.UseCaptchaOnRegistration.ToString(CultureInfo.InvariantCulture)
                .ToLower(CultureInfo.InvariantCulture)
                );

            await SettingManager.ChangeSettingForApplicationAsync(
                AppSettings.TenantManagement.DefaultEdition,
                settings.DefaultEditionId?.ToString() ?? ""
                );
        }
        private async Task UpdateTenantManagementAsync(TenantManagementSettingsEditDto settings)
        {
            // 租户注册配置
            await SettingManager.ChangeSettingForApplicationAsync(
                AppSettingNames.HostSettings.AllowSelfRegistration,
                settings.AllowSelfRegistration.ToString().ToLowerInvariant()
                );

            await SettingManager.ChangeSettingForApplicationAsync(
                AppSettingNames.HostSettings.IsNewRegisteredTenantActiveByDefault,
                settings.IsNewRegisteredTenantActiveByDefault.ToString().ToLowerInvariant()
                );

            // 宿主租户注册验证码配置
            await SettingManager.ChangeSettingForApplicationAsync(
                AppSettingNames.HostSettings.UseCaptchaOnTenantRegistration,
                settings.UseCaptchaOnTenantRegistration.ToString().ToLowerInvariant()
                );

            await SettingManager.ChangeSettingForApplicationAsync(
                AppSettingNames.HostSettings.CaptchaOnTenantRegistrationType,
                ((int)settings.CaptchaOnTenantRegistrationType).ToString()
                );

            await SettingManager.ChangeSettingForApplicationAsync(
                AppSettingNames.HostSettings.CaptchaOnTenantRegistrationLength,
                settings.CaptchaOnTenantRegistrationLength.ToString()
                );

            // 创建租户的默认版本
            await SettingManager.ChangeSettingForApplicationAsync(
                AppSettingNames.HostSettings.DefaultEdition,
                settings.DefaultEditionId?.ToString() ?? ""
                );
        }
        private async Task <TenantManagementSettingsEditDto> GetTenantManagementSettingsAsync()
        {
            var settings = new TenantManagementSettingsEditDto
            {
                // 宿主注册租户
                AllowSelfRegistration = await SettingManager.GetSettingValueAsync <bool>(AppSettingNames.HostSettings.AllowSelfRegistration),
                IsNewRegisteredTenantActiveByDefault = await SettingManager.GetSettingValueAsync <bool>(AppSettingNames.HostSettings.IsNewRegisteredTenantActiveByDefault),
                // 宿主租户注册验证码
                UseCaptchaOnTenantRegistration    = await SettingManager.GetSettingValueAsync <bool>(AppSettingNames.HostSettings.UseCaptchaOnTenantRegistration),
                CaptchaOnTenantRegistrationType   = (ValidateCodeType)await SettingManager.GetSettingValueAsync <int>(AppSettingNames.HostSettings.CaptchaOnTenantRegistrationType),
                CaptchaOnTenantRegistrationLength = await SettingManager.GetSettingValueAsync <int>(AppSettingNames.HostSettings.CaptchaOnTenantRegistrationLength),
            };

            var defaultEditionId = await SettingManager.GetSettingValueAsync(AppSettingNames.HostSettings.DefaultEdition);

            if (!string.IsNullOrEmpty(defaultEditionId) && (await _editionManager.FindByIdAsync(Convert.ToInt32(defaultEditionId)) != null))
            {
                settings.DefaultEditionId = Convert.ToInt32(defaultEditionId);
            }

            return(settings);
        }