|
|
@ -6,6 +6,7 @@ using System; |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
using System.Globalization; |
|
|
using System.Globalization; |
|
|
using System.Threading.Tasks; |
|
|
using System.Threading.Tasks; |
|
|
|
|
|
using Microsoft.Extensions.Logging; |
|
|
using Volo.Abp.Application.Services; |
|
|
using Volo.Abp.Application.Services; |
|
|
using Volo.Abp.Authorization; |
|
|
using Volo.Abp.Authorization; |
|
|
using Volo.Abp.Features; |
|
|
using Volo.Abp.Features; |
|
|
@ -34,7 +35,7 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations |
|
|
IAuthorizationService authorizationService, |
|
|
IAuthorizationService authorizationService, |
|
|
ICurrentUser currentUser, |
|
|
ICurrentUser currentUser, |
|
|
ISettingProvider settingProvider, |
|
|
ISettingProvider settingProvider, |
|
|
SettingDefinitionManager settingDefinitionManager, |
|
|
ISettingDefinitionManager settingDefinitionManager, |
|
|
IFeatureDefinitionManager featureDefinitionManager, |
|
|
IFeatureDefinitionManager featureDefinitionManager, |
|
|
ILanguageProvider languageProvider) |
|
|
ILanguageProvider languageProvider) |
|
|
{ |
|
|
{ |
|
|
@ -76,23 +77,35 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations |
|
|
|
|
|
|
|
|
protected virtual async Task<ApplicationAuthConfigurationDto> GetAuthConfigAsync() |
|
|
protected virtual async Task<ApplicationAuthConfigurationDto> GetAuthConfigAsync() |
|
|
{ |
|
|
{ |
|
|
|
|
|
Logger.LogDebug("Executing AbpApplicationConfigurationAppService.GetAuthConfigAsync()"); |
|
|
|
|
|
|
|
|
var authConfig = new ApplicationAuthConfigurationDto(); |
|
|
var authConfig = new ApplicationAuthConfigurationDto(); |
|
|
|
|
|
|
|
|
foreach (var policyName in await _abpAuthorizationPolicyProvider.GetPoliciesNamesAsync()) |
|
|
var policyNames = await _abpAuthorizationPolicyProvider.GetPoliciesNamesAsync(); |
|
|
|
|
|
|
|
|
|
|
|
Logger.LogDebug($"GetPoliciesNamesAsync returns {policyNames.Count} items."); |
|
|
|
|
|
|
|
|
|
|
|
foreach (var policyName in policyNames) |
|
|
{ |
|
|
{ |
|
|
authConfig.Policies[policyName] = true; |
|
|
authConfig.Policies[policyName] = true; |
|
|
|
|
|
|
|
|
|
|
|
Logger.LogDebug($"_authorizationService.IsGrantedAsync? {policyName}"); |
|
|
|
|
|
|
|
|
if (await _authorizationService.IsGrantedAsync(policyName)) |
|
|
if (await _authorizationService.IsGrantedAsync(policyName)) |
|
|
{ |
|
|
{ |
|
|
authConfig.GrantedPolicies[policyName] = true; |
|
|
authConfig.GrantedPolicies[policyName] = true; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Logger.LogDebug("Executed AbpApplicationConfigurationAppService.GetAuthConfigAsync()"); |
|
|
|
|
|
|
|
|
return authConfig; |
|
|
return authConfig; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected virtual async Task<ApplicationLocalizationConfigurationDto> GetLocalizationConfigAsync() |
|
|
protected virtual async Task<ApplicationLocalizationConfigurationDto> GetLocalizationConfigAsync() |
|
|
{ |
|
|
{ |
|
|
|
|
|
Logger.LogDebug("Executing AbpApplicationConfigurationAppService.GetLocalizationConfigAsync()"); |
|
|
|
|
|
|
|
|
var localizationConfig = new ApplicationLocalizationConfigurationDto(); |
|
|
var localizationConfig = new ApplicationLocalizationConfigurationDto(); |
|
|
|
|
|
|
|
|
localizationConfig.Languages.AddRange(await _languageProvider.GetLanguagesAsync()); |
|
|
localizationConfig.Languages.AddRange(await _languageProvider.GetLanguagesAsync()); |
|
|
@ -115,12 +128,14 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations |
|
|
|
|
|
|
|
|
localizationConfig.CurrentCulture = GetCurrentCultureInfo(); |
|
|
localizationConfig.CurrentCulture = GetCurrentCultureInfo(); |
|
|
|
|
|
|
|
|
|
|
|
Logger.LogDebug("Executed AbpApplicationConfigurationAppService.GetLocalizationConfigAsync()"); |
|
|
|
|
|
|
|
|
return localizationConfig; |
|
|
return localizationConfig; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private static CurrentCultureDto GetCurrentCultureInfo() |
|
|
private static CurrentCultureDto GetCurrentCultureInfo() |
|
|
{ |
|
|
{ |
|
|
return new CurrentCultureDto |
|
|
return new CurrentCultureDto |
|
|
{ |
|
|
{ |
|
|
Name = CultureInfo.CurrentUICulture.Name, |
|
|
Name = CultureInfo.CurrentUICulture.Name, |
|
|
DisplayName = CultureInfo.CurrentUICulture.DisplayName, |
|
|
DisplayName = CultureInfo.CurrentUICulture.DisplayName, |
|
|
@ -145,6 +160,8 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations |
|
|
|
|
|
|
|
|
private async Task<ApplicationSettingConfigurationDto> GetSettingConfigAsync() |
|
|
private async Task<ApplicationSettingConfigurationDto> GetSettingConfigAsync() |
|
|
{ |
|
|
{ |
|
|
|
|
|
Logger.LogDebug("Executing AbpApplicationConfigurationAppService.GetSettingConfigAsync()"); |
|
|
|
|
|
|
|
|
var result = new ApplicationSettingConfigurationDto |
|
|
var result = new ApplicationSettingConfigurationDto |
|
|
{ |
|
|
{ |
|
|
Values = new Dictionary<string, string>() |
|
|
Values = new Dictionary<string, string>() |
|
|
@ -160,11 +177,15 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations |
|
|
result.Values[settingDefinition.Name] = await _settingProvider.GetOrNullAsync(settingDefinition.Name); |
|
|
result.Values[settingDefinition.Name] = await _settingProvider.GetOrNullAsync(settingDefinition.Name); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Logger.LogDebug("Executed AbpApplicationConfigurationAppService.GetSettingConfigAsync()"); |
|
|
|
|
|
|
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected virtual async Task<ApplicationFeatureConfigurationDto> GetFeaturesConfigAsync() |
|
|
protected virtual async Task<ApplicationFeatureConfigurationDto> GetFeaturesConfigAsync() |
|
|
{ |
|
|
{ |
|
|
|
|
|
Logger.LogDebug("Executing AbpApplicationConfigurationAppService.GetFeaturesConfigAsync()"); |
|
|
|
|
|
|
|
|
var result = new ApplicationFeatureConfigurationDto(); |
|
|
var result = new ApplicationFeatureConfigurationDto(); |
|
|
|
|
|
|
|
|
foreach (var featureDefinition in _featureDefinitionManager.GetAll()) |
|
|
foreach (var featureDefinition in _featureDefinitionManager.GetAll()) |
|
|
@ -177,6 +198,8 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations |
|
|
result.Values[featureDefinition.Name] = await FeatureChecker.GetOrNullAsync(featureDefinition.Name); |
|
|
result.Values[featureDefinition.Name] = await FeatureChecker.GetOrNullAsync(featureDefinition.Name); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Logger.LogDebug("Executed AbpApplicationConfigurationAppService.GetFeaturesConfigAsync()"); |
|
|
|
|
|
|
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|