Browse Source

use file-scoped namespacing for settingManagement module

pull/10696/head
Ahmet Çotur 5 years ago
parent
commit
7e2f09efd5
  1. 25
      modules/setting-management/app/Volo.Abp.SettingManagement.DemoApp/DemoAppDbContext.cs
  2. 31
      modules/setting-management/app/Volo.Abp.SettingManagement.DemoApp/DemoAppDbContextFactory.cs
  3. 189
      modules/setting-management/app/Volo.Abp.SettingManagement.DemoApp/DemoAppModule.cs
  4. 962
      modules/setting-management/app/Volo.Abp.SettingManagement.DemoApp/Migrations/20210209024820_init.cs
  5. 9
      modules/setting-management/app/Volo.Abp.SettingManagement.DemoApp/Pages/Index.cshtml.cs
  6. 69
      modules/setting-management/app/Volo.Abp.SettingManagement.DemoApp/Program.cs
  7. 19
      modules/setting-management/app/Volo.Abp.SettingManagement.DemoApp/Startup.cs
  8. 17
      modules/setting-management/src/Volo.Abp.SettingManagement.Application.Contracts/Volo/Abp/SettingManagement/AbpSettingManagementApplicationContractsModule.cs
  9. 23
      modules/setting-management/src/Volo.Abp.SettingManagement.Application.Contracts/Volo/Abp/SettingManagement/AllowTenantsToChangeEmailSettingsFeatureSimpleStateChecker.cs
  10. 25
      modules/setting-management/src/Volo.Abp.SettingManagement.Application.Contracts/Volo/Abp/SettingManagement/EmailSettingsDto.cs
  11. 11
      modules/setting-management/src/Volo.Abp.SettingManagement.Application.Contracts/Volo/Abp/SettingManagement/IEmailSettingsAppService.cs
  12. 25
      modules/setting-management/src/Volo.Abp.SettingManagement.Application.Contracts/Volo/Abp/SettingManagement/SettingManagementPermissionDefinitionProvider.cs
  13. 17
      modules/setting-management/src/Volo.Abp.SettingManagement.Application.Contracts/Volo/Abp/SettingManagement/SettingManagementPermissions.cs
  14. 11
      modules/setting-management/src/Volo.Abp.SettingManagement.Application.Contracts/Volo/Abp/SettingManagement/SettingManagementRemoteServiceConsts.cs
  15. 47
      modules/setting-management/src/Volo.Abp.SettingManagement.Application.Contracts/Volo/Abp/SettingManagement/UpdateEmailSettingsDto.cs
  16. 19
      modules/setting-management/src/Volo.Abp.SettingManagement.Application/Volo/Abp/SettingManagement/AbpSettingManagementApplicationModule.cs
  17. 100
      modules/setting-management/src/Volo.Abp.SettingManagement.Application/Volo/Abp/SettingManagement/EmailSettingsAppService.cs
  18. 13
      modules/setting-management/src/Volo.Abp.SettingManagement.Application/Volo/Abp/SettingManagement/SettingManagementAppServiceBase.cs
  19. 15
      modules/setting-management/src/Volo.Abp.SettingManagement.Blazor.Server/AbpSettingManagementBlazorServerModule.cs
  20. 17
      modules/setting-management/src/Volo.Abp.SettingManagement.Blazor.WebAssembly/AbpSettingManagementBlazorWebAssemblyModule.cs
  21. 53
      modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/AbpSettingManagementBlazorModule.cs
  22. 13
      modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/ISettingComponentContributor.cs
  23. 79
      modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Menus/SettingManagementMenuContributor.cs
  24. 11
      modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Menus/SettingManagementMenus.cs
  25. 75
      modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Pages/SettingManagement/EmailSettingGroup/EmailSettingGroupViewComponent.razor.cs
  26. 57
      modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Pages/SettingManagement/SettingManagement.razor.cs
  27. 21
      modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/SettingComponentCreationContext.cs
  28. 56
      modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/SettingComponentGroup.cs
  29. 11
      modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/SettingManagementBlazorAutoMapperProfile.cs
  30. 15
      modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/SettingManagementComponentOptions.cs
  31. 73
      modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Settings/EmailingPageContributor.cs
  32. 33
      modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/AbpSettingManagementDomainSharedModule.cs
  33. 9
      modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/AbpSettingManagementResource.cs
  34. 49
      modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/SettingConsts.cs
  35. 47
      modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/SettingManagementFeatureDefinitionProvider.cs
  36. 13
      modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/SettingManagementFeatures.cs
  37. 13
      modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/AbpSettingManagementDbProperties.cs
  38. 35
      modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/AbpSettingManagementDomainModule.cs
  39. 43
      modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/ConfigurationSettingManagementProvider.cs
  40. 21
      modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/ConfigurationValueSettingManagerExtensions.cs
  41. 33
      modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/DefaultValueSettingManagementProvider.cs
  42. 21
      modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/DefaultValueSettingManagerExtensions.cs
  43. 25
      modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/GlobalSettingManagementProvider.cs
  44. 27
      modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/GlobalSettingManagerExtensions.cs
  45. 15
      modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/ISettingManagementProvider.cs
  46. 17
      modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/ISettingManagementStore.cs
  47. 15
      modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/ISettingManager.cs
  48. 35
      modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/ISettingRepository.cs
  49. 81
      modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/Setting.cs
  50. 45
      modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/SettingCacheItem.cs
  51. 41
      modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/SettingCacheItemInvalidator.cs
  52. 15
      modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/SettingManagementOptions.cs
  53. 63
      modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/SettingManagementProvider.cs
  54. 301
      modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/SettingManagementStore.cs
  55. 293
      modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/SettingManager.cs
  56. 31
      modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/SettingStore.cs
  57. 39
      modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/TenantSettingManagementProvider.cs
  58. 65
      modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/TenantSettingManagerExtensions.cs
  59. 39
      modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/UserSettingManagementProvider.cs
  60. 63
      modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/UserSettingManagerExtensions.cs
  61. 25
      modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo/Abp/SettingManagement/EntityFrameworkCore/AbpSettingManagementEntityFrameworkCoreModule.cs
  62. 79
      modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo/Abp/SettingManagement/EntityFrameworkCore/EfCoreSettingRepository.cs
  63. 13
      modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo/Abp/SettingManagement/EntityFrameworkCore/ISettingManagementDbContext.cs
  64. 29
      modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo/Abp/SettingManagement/EntityFrameworkCore/SettingManagementDbContext.cs
  65. 49
      modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo/Abp/SettingManagement/EntityFrameworkCore/SettingManagementDbContextModelBuilderExtensions.cs
  66. 7
      modules/setting-management/src/Volo.Abp.SettingManagement.HttpApi.Client/ClientProxies/EmailSettingsClientProxy.cs
  67. 31
      modules/setting-management/src/Volo.Abp.SettingManagement.HttpApi.Client/Volo/Abp/SettingManagement/AbpSettingManagementHttpApiClientModule.cs
  68. 41
      modules/setting-management/src/Volo.Abp.SettingManagement.HttpApi/Volo/Abp/SettingManagement/AbpSettingManagementHttpApiModule.cs
  69. 41
      modules/setting-management/src/Volo.Abp.SettingManagement.HttpApi/Volo/Abp/SettingManagement/EmailSettingsController.cs
  70. 23
      modules/setting-management/src/Volo.Abp.SettingManagement.Installer/Volo/Abp/SettingManagement/AbpSettingManagementInstallerModule.cs
  71. 29
      modules/setting-management/src/Volo.Abp.SettingManagement.Installer/Volo/Abp/SettingManagement/SettingManagementInstallerPipelineBuilder.cs
  72. 25
      modules/setting-management/src/Volo.Abp.SettingManagement.MongoDB/Volo/Abp/SettingManagement/MongoDB/AbpSettingManagementMongoDbModule.cs
  73. 13
      modules/setting-management/src/Volo.Abp.SettingManagement.MongoDB/Volo/Abp/SettingManagement/MongoDB/ISettingManagementMongoDbContext.cs
  74. 75
      modules/setting-management/src/Volo.Abp.SettingManagement.MongoDB/Volo/Abp/SettingManagement/MongoDB/MongoSettingRepository.cs
  75. 21
      modules/setting-management/src/Volo.Abp.SettingManagement.MongoDB/Volo/Abp/SettingManagement/MongoDB/SettingManagementMongoDbContext.cs
  76. 23
      modules/setting-management/src/Volo.Abp.SettingManagement.MongoDB/Volo/Abp/SettingManagement/MongoDB/SettingManagementMongoDbContextExtensions.cs
  77. 79
      modules/setting-management/src/Volo.Abp.SettingManagement.Web/AbpSettingManagementWebModule.cs
  78. 81
      modules/setting-management/src/Volo.Abp.SettingManagement.Web/Navigation/SettingManagementMainMenuContributor.cs
  79. 9
      modules/setting-management/src/Volo.Abp.SettingManagement.Web/Navigation/SettingManagementMenuNames.cs
  80. 27
      modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/Components/EmailSettingGroup/EmailSettingGroupViewComponent.cs
  81. 13
      modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/ISettingPageContributor.cs
  82. 65
      modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/Index.cshtml.cs
  83. 15
      modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/SettingManagementPageOptions.cs
  84. 21
      modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/SettingPageCreationContext.cs
  85. 56
      modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/SettingPageGroup.cs
  86. 27
      modules/setting-management/src/Volo.Abp.SettingManagement.Web/Properties/launchSettings.json
  87. 77
      modules/setting-management/src/Volo.Abp.SettingManagement.Web/Settings/EmailingPageContributor.cs
  88. 49
      modules/setting-management/test/Volo.Abp.SettingManagement.EntityFrameworkCore.Tests/Volo/Abp/SettingManagement/EntityFrameworkCore/AbpSettingManagementEntityFrameworkCoreTestModule.cs
  89. 7
      modules/setting-management/test/Volo.Abp.SettingManagement.EntityFrameworkCore.Tests/Volo/Abp/SettingManagement/EntityFrameworkCore/SettingRepository_Tests.cs
  90. 33
      modules/setting-management/test/Volo.Abp.SettingManagement.MongoDB.Tests/Volo/Abp/SettingManagement/MongoDB/AbpSettingManagementMongoDbTestModule.cs
  91. 27
      modules/setting-management/test/Volo.Abp.SettingManagement.MongoDB.Tests/Volo/Abp/SettingManagement/MongoDB/MongoDbFixture.cs
  92. 13
      modules/setting-management/test/Volo.Abp.SettingManagement.MongoDB.Tests/Volo/Abp/SettingManagement/MongoDB/MongoTestCollection.cs
  93. 9
      modules/setting-management/test/Volo.Abp.SettingManagement.MongoDB.Tests/Volo/Abp/SettingManagement/MongoDB/SettingRepository_Tests.cs
  94. 35
      modules/setting-management/test/Volo.Abp.SettingManagement.TestBase/Volo/Abp/SettingManagement/AbpSettingManagementTestBaseModule.cs
  95. 13
      modules/setting-management/test/Volo.Abp.SettingManagement.TestBase/Volo/Abp/SettingManagement/SettingManagementTestBase.cs
  96. 101
      modules/setting-management/test/Volo.Abp.SettingManagement.TestBase/Volo/Abp/SettingManagement/SettingRepository_Tests.cs
  97. 15
      modules/setting-management/test/Volo.Abp.SettingManagement.TestBase/Volo/Abp/SettingManagement/SettingTestData.cs
  98. 139
      modules/setting-management/test/Volo.Abp.SettingManagement.TestBase/Volo/Abp/SettingManagement/SettingTestDataBuilder.cs
  99. 23
      modules/setting-management/test/Volo.Abp.SettingManagement.TestBase/Volo/Abp/SettingManagement/TestSettingDefinitionProvider.cs
  100. 15
      modules/setting-management/test/Volo.Abp.SettingManagement.Tests/Volo/Abp/SettingManagement/AbpSettingManagementTestModule.cs

25
modules/setting-management/app/Volo.Abp.SettingManagement.DemoApp/DemoAppDbContext.cs

@ -4,23 +4,22 @@ using Volo.Abp.Identity.EntityFrameworkCore;
using Volo.Abp.PermissionManagement.EntityFrameworkCore; using Volo.Abp.PermissionManagement.EntityFrameworkCore;
using Volo.Abp.SettingManagement.EntityFrameworkCore; using Volo.Abp.SettingManagement.EntityFrameworkCore;
namespace Volo.Abp.SettingManagement.DemoApp namespace Volo.Abp.SettingManagement.DemoApp;
public class DemoAppDbContext : AbpDbContext<DemoAppDbContext>
{ {
public class DemoAppDbContext: AbpDbContext<DemoAppDbContext> public DemoAppDbContext(DbContextOptions<DemoAppDbContext> options)
: base(options)
{ {
public DemoAppDbContext(DbContextOptions<DemoAppDbContext> options)
: base(options)
{
} }
protected override void OnModelCreating(ModelBuilder modelBuilder) protected override void OnModelCreating(ModelBuilder modelBuilder)
{ {
base.OnModelCreating(modelBuilder); base.OnModelCreating(modelBuilder);
modelBuilder.ConfigurePermissionManagement(); modelBuilder.ConfigurePermissionManagement();
modelBuilder.ConfigureSettingManagement(); modelBuilder.ConfigureSettingManagement();
modelBuilder.ConfigureIdentity(); modelBuilder.ConfigureIdentity();
}
} }
} }

31
modules/setting-management/app/Volo.Abp.SettingManagement.DemoApp/DemoAppDbContextFactory.cs

@ -3,27 +3,26 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design; using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
namespace Volo.Abp.SettingManagement.DemoApp namespace Volo.Abp.SettingManagement.DemoApp;
public class DemoAppDbContextFactory : IDesignTimeDbContextFactory<DemoAppDbContext>
{ {
public class DemoAppDbContextFactory : IDesignTimeDbContextFactory<DemoAppDbContext> public DemoAppDbContext CreateDbContext(string[] args)
{ {
public DemoAppDbContext CreateDbContext(string[] args) var configuration = BuildConfiguration();
{
var configuration = BuildConfiguration();
var builder = new DbContextOptionsBuilder<DemoAppDbContext>() var builder = new DbContextOptionsBuilder<DemoAppDbContext>()
.UseSqlServer(configuration.GetConnectionString("Default")); .UseSqlServer(configuration.GetConnectionString("Default"));
return new DemoAppDbContext(builder.Options); return new DemoAppDbContext(builder.Options);
} }
private static IConfigurationRoot BuildConfiguration() private static IConfigurationRoot BuildConfiguration()
{ {
var builder = new ConfigurationBuilder() var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory()) .SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false); .AddJsonFile("appsettings.json", optional: false);
return builder.Build(); return builder.Build();
}
} }
} }

189
modules/setting-management/app/Volo.Abp.SettingManagement.DemoApp/DemoAppModule.cs

@ -28,121 +28,120 @@ using Volo.Abp.SettingManagement.Web;
using Volo.Abp.Threading; using Volo.Abp.Threading;
using Volo.Abp.VirtualFileSystem; using Volo.Abp.VirtualFileSystem;
namespace Volo.Abp.SettingManagement.DemoApp namespace Volo.Abp.SettingManagement.DemoApp;
[DependsOn(
typeof(AbpSettingManagementWebModule),
typeof(AbpSettingManagementApplicationModule),
typeof(AbpSettingManagementHttpApiModule),
typeof(AbpAutofacModule),
typeof(AbpAccountWebModule),
typeof(AbpAccountApplicationModule),
typeof(AbpAccountHttpApiModule),
typeof(AbpEntityFrameworkCoreSqlServerModule),
typeof(AbpSettingManagementEntityFrameworkCoreModule),
typeof(AbpPermissionManagementEntityFrameworkCoreModule),
typeof(AbpPermissionManagementApplicationModule),
typeof(AbpPermissionManagementHttpApiModule),
typeof(AbpIdentityWebModule),
typeof(AbpIdentityApplicationModule),
typeof(AbpIdentityHttpApiModule),
typeof(AbpIdentityEntityFrameworkCoreModule),
typeof(AbpPermissionManagementDomainIdentityModule),
typeof(AbpAspNetCoreMvcUiBasicThemeModule)
)]
public class DemoAppModule : AbpModule
{ {
[DependsOn( public override void ConfigureServices(ServiceConfigurationContext context)
typeof(AbpSettingManagementWebModule),
typeof(AbpSettingManagementApplicationModule),
typeof(AbpSettingManagementHttpApiModule),
typeof(AbpAutofacModule),
typeof(AbpAccountWebModule),
typeof(AbpAccountApplicationModule),
typeof(AbpAccountHttpApiModule),
typeof(AbpEntityFrameworkCoreSqlServerModule),
typeof(AbpSettingManagementEntityFrameworkCoreModule),
typeof(AbpPermissionManagementEntityFrameworkCoreModule),
typeof(AbpPermissionManagementApplicationModule),
typeof(AbpPermissionManagementHttpApiModule),
typeof(AbpIdentityWebModule),
typeof(AbpIdentityApplicationModule),
typeof(AbpIdentityHttpApiModule),
typeof(AbpIdentityEntityFrameworkCoreModule),
typeof(AbpPermissionManagementDomainIdentityModule),
typeof(AbpAspNetCoreMvcUiBasicThemeModule)
)]
public class DemoAppModule : AbpModule
{ {
public override void ConfigureServices(ServiceConfigurationContext context) var hostingEnvironment = context.Services.GetHostingEnvironment();
{ var configuration = context.Services.GetConfiguration();
var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = context.Services.GetConfiguration();
#if DEBUG #if DEBUG
context.Services.Replace(ServiceDescriptor.Singleton<IEmailSender, NullEmailSender>()); context.Services.Replace(ServiceDescriptor.Singleton<IEmailSender, NullEmailSender>());
#endif #endif
Configure<AbpDbContextOptions>(options => Configure<AbpDbContextOptions>(options =>
{ {
options.UseSqlServer(); options.UseSqlServer();
}); });
if (hostingEnvironment.IsDevelopment())
{
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.FileSets.ReplaceEmbeddedByPhysical<AbpSettingManagementWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.Abp.SettingManagement.Web", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpSettingManagementDomainModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.Abp.SettingManagement.Domain", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpSettingManagementApplicationModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.Abp.SettingManagement.Application", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpSettingManagementApplicationContractsModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.Abp.SettingManagement.Application.Contracts", Path.DirectorySeparatorChar)));
});
}
context.Services.AddSwaggerGen(
options =>
{
options.SwaggerDoc("v1", new OpenApiInfo { Title = "AbpSettingManagement API", Version = "v1" });
options.DocInclusionPredicate((docName, description) => true);
options.CustomSchemaIds(type => type.FullName);
});
Configure<AbpLocalizationOptions>(options => if (hostingEnvironment.IsDevelopment())
{
Configure<AbpVirtualFileSystemOptions>(options =>
{ {
options.Languages.Add(new LanguageInfo("en", "en", "English")); options.FileSets.ReplaceEmbeddedByPhysical<AbpSettingManagementWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.Abp.SettingManagement.Web", Path.DirectorySeparatorChar)));
options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak")); options.FileSets.ReplaceEmbeddedByPhysical<AbpSettingManagementDomainModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.Abp.SettingManagement.Domain", Path.DirectorySeparatorChar)));
options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe")); options.FileSets.ReplaceEmbeddedByPhysical<AbpSettingManagementApplicationModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.Abp.SettingManagement.Application", Path.DirectorySeparatorChar)));
options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish")); options.FileSets.ReplaceEmbeddedByPhysical<AbpSettingManagementApplicationContractsModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.Abp.SettingManagement.Application.Contracts", Path.DirectorySeparatorChar)));
options.Languages.Add(new LanguageInfo("fr", "fr", "Français"));
options.Languages.Add(new LanguageInfo("ro-RO", "ro-RO", "Română"));
options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in"));
options.Languages.Add(new LanguageInfo("is", "is", "Icelandic", "is"));
options.Languages.Add(new LanguageInfo("it", "it", "Italiano", "it"));
}); });
}
Configure<AbpMultiTenancyOptions>(options => context.Services.AddSwaggerGen(
options =>
{ {
options.IsEnabled = true; options.SwaggerDoc("v1", new OpenApiInfo { Title = "AbpSettingManagement API", Version = "v1" });
options.DocInclusionPredicate((docName, description) => true);
options.CustomSchemaIds(type => type.FullName);
}); });
}
public override void OnApplicationInitialization(ApplicationInitializationContext context) Configure<AbpLocalizationOptions>(options =>
{ {
var app = context.GetApplicationBuilder(); options.Languages.Add(new LanguageInfo("en", "en", "English"));
options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak"));
options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe"));
options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish"));
options.Languages.Add(new LanguageInfo("fr", "fr", "Français"));
options.Languages.Add(new LanguageInfo("ro-RO", "ro-RO", "Română"));
options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in"));
options.Languages.Add(new LanguageInfo("is", "is", "Icelandic", "is"));
options.Languages.Add(new LanguageInfo("it", "it", "Italiano", "it"));
});
if (context.GetEnvironment().IsDevelopment()) Configure<AbpMultiTenancyOptions>(options =>
{ {
app.UseDeveloperExceptionPage(); options.IsEnabled = true;
} });
else }
{
app.UseErrorPage();
app.UseHsts();
}
app.UseHttpsRedirection(); public override void OnApplicationInitialization(ApplicationInitializationContext context)
app.UseStaticFiles(); {
app.UseRouting(); var app = context.GetApplicationBuilder();
app.UseAuthentication();
app.UseAuthorization();
app.UseMultiTenancy();
app.UseAbpRequestLocalization();
app.UseSwagger(); if (context.GetEnvironment().IsDevelopment())
app.UseSwaggerUI(options => {
{ app.UseDeveloperExceptionPage();
options.SwaggerEndpoint("/swagger/v1/swagger.json", "SettingManagement APP API"); }
}); else
{
app.UseErrorPage();
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseMultiTenancy();
app.UseAbpRequestLocalization();
app.UseSwagger();
app.UseSwaggerUI(options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "SettingManagement APP API");
});
app.UseConfiguredEndpoints(); app.UseConfiguredEndpoints();
using (var scope = context.ServiceProvider.CreateScope()) using (var scope = context.ServiceProvider.CreateScope())
{
AsyncHelper.RunSync(async () =>
{ {
AsyncHelper.RunSync(async () => await scope.ServiceProvider
{ .GetRequiredService<IDataSeeder>()
await scope.ServiceProvider .SeedAsync();
.GetRequiredService<IDataSeeder>() });
.SeedAsync();
});
}
} }
} }
} }

962
modules/setting-management/app/Volo.Abp.SettingManagement.DemoApp/Migrations/20210209024820_init.cs

@ -1,500 +1,484 @@
using System; using System;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
namespace Volo.Abp.SettingManagement.DemoApp.Migrations namespace Volo.Abp.SettingManagement.DemoApp.Migrations;
public partial class init : Migration
{ {
public partial class init : Migration protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "AbpClaimTypes",
columns: table => new {
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Name = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
Required = table.Column<bool>(type: "bit", nullable: false),
IsStatic = table.Column<bool>(type: "bit", nullable: false),
Regex = table.Column<string>(type: "nvarchar(512)", maxLength: 512, nullable: true),
RegexDescription = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: true),
Description = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
ValueType = table.Column<int>(type: "int", nullable: false),
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpClaimTypes", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AbpLinkUsers",
columns: table => new {
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
SourceUserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
SourceTenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
TargetUserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TargetTenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpLinkUsers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AbpOrganizationUnits",
columns: table => new {
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
ParentId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
Code = table.Column<string>(type: "nvarchar(95)", maxLength: 95, nullable: false),
DisplayName = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true),
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifierId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
DeleterId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpOrganizationUnits", x => x.Id);
table.ForeignKey(
name: "FK_AbpOrganizationUnits_AbpOrganizationUnits_ParentId",
column: x => x.ParentId,
principalTable: "AbpOrganizationUnits",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "AbpPermissionGrants",
columns: table => new {
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
Name = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
ProviderName = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
ProviderKey = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpPermissionGrants", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AbpRoles",
columns: table => new {
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
Name = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
NormalizedName = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
IsDefault = table.Column<bool>(type: "bit", nullable: false),
IsStatic = table.Column<bool>(type: "bit", nullable: false),
IsPublic = table.Column<bool>(type: "bit", nullable: false),
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpRoles", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AbpSecurityLogs",
columns: table => new {
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
ApplicationName = table.Column<string>(type: "nvarchar(96)", maxLength: 96, nullable: true),
Identity = table.Column<string>(type: "nvarchar(96)", maxLength: 96, nullable: true),
Action = table.Column<string>(type: "nvarchar(96)", maxLength: 96, nullable: true),
UserId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
UserName = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
TenantName = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true),
ClientId = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true),
CorrelationId = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true),
ClientIpAddress = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true),
BrowserInfo = table.Column<string>(type: "nvarchar(512)", maxLength: 512, nullable: true),
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpSecurityLogs", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AbpSettings",
columns: table => new {
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Name = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
Value = table.Column<string>(type: "nvarchar(2048)", maxLength: 2048, nullable: false),
ProviderName = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true),
ProviderKey = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpSettings", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AbpUsers",
columns: table => new {
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
UserName = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
NormalizedUserName = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
Name = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true),
Surname = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true),
Email = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
NormalizedEmail = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
EmailConfirmed = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
PasswordHash = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
SecurityStamp = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
IsExternal = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
PhoneNumber = table.Column<string>(type: "nvarchar(16)", maxLength: 16, nullable: true),
PhoneNumberConfirmed = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
TwoFactorEnabled = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
LockoutEnd = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
LockoutEnabled = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
AccessFailedCount = table.Column<int>(type: "int", nullable: false, defaultValue: 0),
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true),
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifierId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
DeleterId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpUsers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AbpOrganizationUnitRoles",
columns: table => new {
RoleId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
OrganizationUnitId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpOrganizationUnitRoles", x => new { x.OrganizationUnitId, x.RoleId });
table.ForeignKey(
name: "FK_AbpOrganizationUnitRoles_AbpOrganizationUnits_OrganizationUnitId",
column: x => x.OrganizationUnitId,
principalTable: "AbpOrganizationUnits",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_AbpOrganizationUnitRoles_AbpRoles_RoleId",
column: x => x.RoleId,
principalTable: "AbpRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AbpRoleClaims",
columns: table => new {
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
RoleId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
ClaimType = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
ClaimValue = table.Column<string>(type: "nvarchar(1024)", maxLength: 1024, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpRoleClaims", x => x.Id);
table.ForeignKey(
name: "FK_AbpRoleClaims_AbpRoles_RoleId",
column: x => x.RoleId,
principalTable: "AbpRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AbpUserClaims",
columns: table => new {
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
UserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
ClaimType = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
ClaimValue = table.Column<string>(type: "nvarchar(1024)", maxLength: 1024, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpUserClaims", x => x.Id);
table.ForeignKey(
name: "FK_AbpUserClaims_AbpUsers_UserId",
column: x => x.UserId,
principalTable: "AbpUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AbpUserLogins",
columns: table => new {
UserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
LoginProvider = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
ProviderKey = table.Column<string>(type: "nvarchar(196)", maxLength: 196, nullable: false),
ProviderDisplayName = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpUserLogins", x => new { x.UserId, x.LoginProvider });
table.ForeignKey(
name: "FK_AbpUserLogins_AbpUsers_UserId",
column: x => x.UserId,
principalTable: "AbpUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AbpUserOrganizationUnits",
columns: table => new {
UserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
OrganizationUnitId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpUserOrganizationUnits", x => new { x.OrganizationUnitId, x.UserId });
table.ForeignKey(
name: "FK_AbpUserOrganizationUnits_AbpOrganizationUnits_OrganizationUnitId",
column: x => x.OrganizationUnitId,
principalTable: "AbpOrganizationUnits",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_AbpUserOrganizationUnits_AbpUsers_UserId",
column: x => x.UserId,
principalTable: "AbpUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AbpUserRoles",
columns: table => new {
UserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
RoleId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpUserRoles", x => new { x.UserId, x.RoleId });
table.ForeignKey(
name: "FK_AbpUserRoles_AbpRoles_RoleId",
column: x => x.RoleId,
principalTable: "AbpRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_AbpUserRoles_AbpUsers_UserId",
column: x => x.UserId,
principalTable: "AbpUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AbpUserTokens",
columns: table => new {
UserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
LoginProvider = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
Name = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
Value = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpUserTokens", x => new { x.UserId, x.LoginProvider, x.Name });
table.ForeignKey(
name: "FK_AbpUserTokens_AbpUsers_UserId",
column: x => x.UserId,
principalTable: "AbpUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_AbpLinkUsers_SourceUserId_SourceTenantId_TargetUserId_TargetTenantId",
table: "AbpLinkUsers",
columns: new[] { "SourceUserId", "SourceTenantId", "TargetUserId", "TargetTenantId" },
unique: true,
filter: "[SourceTenantId] IS NOT NULL AND [TargetTenantId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_AbpOrganizationUnitRoles_RoleId_OrganizationUnitId",
table: "AbpOrganizationUnitRoles",
columns: new[] { "RoleId", "OrganizationUnitId" });
migrationBuilder.CreateIndex(
name: "IX_AbpOrganizationUnits_Code",
table: "AbpOrganizationUnits",
column: "Code");
migrationBuilder.CreateIndex(
name: "IX_AbpOrganizationUnits_ParentId",
table: "AbpOrganizationUnits",
column: "ParentId");
migrationBuilder.CreateIndex(
name: "IX_AbpPermissionGrants_Name_ProviderName_ProviderKey",
table: "AbpPermissionGrants",
columns: new[] { "Name", "ProviderName", "ProviderKey" });
migrationBuilder.CreateIndex(
name: "IX_AbpRoleClaims_RoleId",
table: "AbpRoleClaims",
column: "RoleId");
migrationBuilder.CreateIndex(
name: "IX_AbpRoles_NormalizedName",
table: "AbpRoles",
column: "NormalizedName");
migrationBuilder.CreateIndex(
name: "IX_AbpSecurityLogs_TenantId_Action",
table: "AbpSecurityLogs",
columns: new[] { "TenantId", "Action" });
migrationBuilder.CreateIndex(
name: "IX_AbpSecurityLogs_TenantId_ApplicationName",
table: "AbpSecurityLogs",
columns: new[] { "TenantId", "ApplicationName" });
migrationBuilder.CreateIndex(
name: "IX_AbpSecurityLogs_TenantId_Identity",
table: "AbpSecurityLogs",
columns: new[] { "TenantId", "Identity" });
migrationBuilder.CreateIndex(
name: "IX_AbpSecurityLogs_TenantId_UserId",
table: "AbpSecurityLogs",
columns: new[] { "TenantId", "UserId" });
migrationBuilder.CreateIndex(
name: "IX_AbpSettings_Name_ProviderName_ProviderKey",
table: "AbpSettings",
columns: new[] { "Name", "ProviderName", "ProviderKey" });
migrationBuilder.CreateIndex(
name: "IX_AbpUserClaims_UserId",
table: "AbpUserClaims",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_AbpUserLogins_LoginProvider_ProviderKey",
table: "AbpUserLogins",
columns: new[] { "LoginProvider", "ProviderKey" });
migrationBuilder.CreateIndex(
name: "IX_AbpUserOrganizationUnits_UserId_OrganizationUnitId",
table: "AbpUserOrganizationUnits",
columns: new[] { "UserId", "OrganizationUnitId" });
migrationBuilder.CreateIndex(
name: "IX_AbpUserRoles_RoleId_UserId",
table: "AbpUserRoles",
columns: new[] { "RoleId", "UserId" });
migrationBuilder.CreateIndex(
name: "IX_AbpUsers_Email",
table: "AbpUsers",
column: "Email");
migrationBuilder.CreateIndex(
name: "IX_AbpUsers_NormalizedEmail",
table: "AbpUsers",
column: "NormalizedEmail");
migrationBuilder.CreateIndex(
name: "IX_AbpUsers_NormalizedUserName",
table: "AbpUsers",
column: "NormalizedUserName");
migrationBuilder.CreateIndex(
name: "IX_AbpUsers_UserName",
table: "AbpUsers",
column: "UserName");
}
protected override void Down(MigrationBuilder migrationBuilder)
{ {
protected override void Up(MigrationBuilder migrationBuilder) migrationBuilder.DropTable(
{ name: "AbpClaimTypes");
migrationBuilder.CreateTable(
name: "AbpClaimTypes", migrationBuilder.DropTable(
columns: table => new name: "AbpLinkUsers");
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false), migrationBuilder.DropTable(
Name = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false), name: "AbpOrganizationUnitRoles");
Required = table.Column<bool>(type: "bit", nullable: false),
IsStatic = table.Column<bool>(type: "bit", nullable: false), migrationBuilder.DropTable(
Regex = table.Column<string>(type: "nvarchar(512)", maxLength: 512, nullable: true), name: "AbpPermissionGrants");
RegexDescription = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: true),
Description = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true), migrationBuilder.DropTable(
ValueType = table.Column<int>(type: "int", nullable: false), name: "AbpRoleClaims");
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true) migrationBuilder.DropTable(
}, name: "AbpSecurityLogs");
constraints: table =>
{ migrationBuilder.DropTable(
table.PrimaryKey("PK_AbpClaimTypes", x => x.Id); name: "AbpSettings");
});
migrationBuilder.DropTable(
migrationBuilder.CreateTable( name: "AbpUserClaims");
name: "AbpLinkUsers",
columns: table => new migrationBuilder.DropTable(
{ name: "AbpUserLogins");
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
SourceUserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false), migrationBuilder.DropTable(
SourceTenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), name: "AbpUserOrganizationUnits");
TargetUserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TargetTenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true) migrationBuilder.DropTable(
}, name: "AbpUserRoles");
constraints: table =>
{
table.PrimaryKey("PK_AbpLinkUsers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AbpOrganizationUnits",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
ParentId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
Code = table.Column<string>(type: "nvarchar(95)", maxLength: 95, nullable: false),
DisplayName = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true),
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifierId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
DeleterId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpOrganizationUnits", x => x.Id);
table.ForeignKey(
name: "FK_AbpOrganizationUnits_AbpOrganizationUnits_ParentId",
column: x => x.ParentId,
principalTable: "AbpOrganizationUnits",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "AbpPermissionGrants",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
Name = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
ProviderName = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
ProviderKey = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpPermissionGrants", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AbpRoles",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
Name = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
NormalizedName = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
IsDefault = table.Column<bool>(type: "bit", nullable: false),
IsStatic = table.Column<bool>(type: "bit", nullable: false),
IsPublic = table.Column<bool>(type: "bit", nullable: false),
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpRoles", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AbpSecurityLogs",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
ApplicationName = table.Column<string>(type: "nvarchar(96)", maxLength: 96, nullable: true),
Identity = table.Column<string>(type: "nvarchar(96)", maxLength: 96, nullable: true),
Action = table.Column<string>(type: "nvarchar(96)", maxLength: 96, nullable: true),
UserId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
UserName = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
TenantName = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true),
ClientId = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true),
CorrelationId = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true),
ClientIpAddress = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true),
BrowserInfo = table.Column<string>(type: "nvarchar(512)", maxLength: 512, nullable: true),
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpSecurityLogs", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AbpSettings",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Name = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
Value = table.Column<string>(type: "nvarchar(2048)", maxLength: 2048, nullable: false),
ProviderName = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true),
ProviderKey = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpSettings", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AbpUsers",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
UserName = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
NormalizedUserName = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
Name = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true),
Surname = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true),
Email = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
NormalizedEmail = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
EmailConfirmed = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
PasswordHash = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
SecurityStamp = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
IsExternal = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
PhoneNumber = table.Column<string>(type: "nvarchar(16)", maxLength: 16, nullable: true),
PhoneNumberConfirmed = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
TwoFactorEnabled = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
LockoutEnd = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
LockoutEnabled = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
AccessFailedCount = table.Column<int>(type: "int", nullable: false, defaultValue: 0),
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true),
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifierId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
DeleterId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpUsers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AbpOrganizationUnitRoles",
columns: table => new
{
RoleId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
OrganizationUnitId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpOrganizationUnitRoles", x => new { x.OrganizationUnitId, x.RoleId });
table.ForeignKey(
name: "FK_AbpOrganizationUnitRoles_AbpOrganizationUnits_OrganizationUnitId",
column: x => x.OrganizationUnitId,
principalTable: "AbpOrganizationUnits",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_AbpOrganizationUnitRoles_AbpRoles_RoleId",
column: x => x.RoleId,
principalTable: "AbpRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AbpRoleClaims",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
RoleId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
ClaimType = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
ClaimValue = table.Column<string>(type: "nvarchar(1024)", maxLength: 1024, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpRoleClaims", x => x.Id);
table.ForeignKey(
name: "FK_AbpRoleClaims_AbpRoles_RoleId",
column: x => x.RoleId,
principalTable: "AbpRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AbpUserClaims",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
UserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
ClaimType = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
ClaimValue = table.Column<string>(type: "nvarchar(1024)", maxLength: 1024, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpUserClaims", x => x.Id);
table.ForeignKey(
name: "FK_AbpUserClaims_AbpUsers_UserId",
column: x => x.UserId,
principalTable: "AbpUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AbpUserLogins",
columns: table => new
{
UserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
LoginProvider = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
ProviderKey = table.Column<string>(type: "nvarchar(196)", maxLength: 196, nullable: false),
ProviderDisplayName = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpUserLogins", x => new { x.UserId, x.LoginProvider });
table.ForeignKey(
name: "FK_AbpUserLogins_AbpUsers_UserId",
column: x => x.UserId,
principalTable: "AbpUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AbpUserOrganizationUnits",
columns: table => new
{
UserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
OrganizationUnitId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpUserOrganizationUnits", x => new { x.OrganizationUnitId, x.UserId });
table.ForeignKey(
name: "FK_AbpUserOrganizationUnits_AbpOrganizationUnits_OrganizationUnitId",
column: x => x.OrganizationUnitId,
principalTable: "AbpOrganizationUnits",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_AbpUserOrganizationUnits_AbpUsers_UserId",
column: x => x.UserId,
principalTable: "AbpUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AbpUserRoles",
columns: table => new
{
UserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
RoleId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpUserRoles", x => new { x.UserId, x.RoleId });
table.ForeignKey(
name: "FK_AbpUserRoles_AbpRoles_RoleId",
column: x => x.RoleId,
principalTable: "AbpRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_AbpUserRoles_AbpUsers_UserId",
column: x => x.UserId,
principalTable: "AbpUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AbpUserTokens",
columns: table => new
{
UserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
LoginProvider = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
Name = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
Value = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpUserTokens", x => new { x.UserId, x.LoginProvider, x.Name });
table.ForeignKey(
name: "FK_AbpUserTokens_AbpUsers_UserId",
column: x => x.UserId,
principalTable: "AbpUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_AbpLinkUsers_SourceUserId_SourceTenantId_TargetUserId_TargetTenantId",
table: "AbpLinkUsers",
columns: new[] { "SourceUserId", "SourceTenantId", "TargetUserId", "TargetTenantId" },
unique: true,
filter: "[SourceTenantId] IS NOT NULL AND [TargetTenantId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_AbpOrganizationUnitRoles_RoleId_OrganizationUnitId",
table: "AbpOrganizationUnitRoles",
columns: new[] { "RoleId", "OrganizationUnitId" });
migrationBuilder.CreateIndex(
name: "IX_AbpOrganizationUnits_Code",
table: "AbpOrganizationUnits",
column: "Code");
migrationBuilder.CreateIndex(
name: "IX_AbpOrganizationUnits_ParentId",
table: "AbpOrganizationUnits",
column: "ParentId");
migrationBuilder.CreateIndex(
name: "IX_AbpPermissionGrants_Name_ProviderName_ProviderKey",
table: "AbpPermissionGrants",
columns: new[] { "Name", "ProviderName", "ProviderKey" });
migrationBuilder.CreateIndex(
name: "IX_AbpRoleClaims_RoleId",
table: "AbpRoleClaims",
column: "RoleId");
migrationBuilder.CreateIndex(
name: "IX_AbpRoles_NormalizedName",
table: "AbpRoles",
column: "NormalizedName");
migrationBuilder.CreateIndex(
name: "IX_AbpSecurityLogs_TenantId_Action",
table: "AbpSecurityLogs",
columns: new[] { "TenantId", "Action" });
migrationBuilder.CreateIndex(
name: "IX_AbpSecurityLogs_TenantId_ApplicationName",
table: "AbpSecurityLogs",
columns: new[] { "TenantId", "ApplicationName" });
migrationBuilder.CreateIndex(
name: "IX_AbpSecurityLogs_TenantId_Identity",
table: "AbpSecurityLogs",
columns: new[] { "TenantId", "Identity" });
migrationBuilder.CreateIndex(
name: "IX_AbpSecurityLogs_TenantId_UserId",
table: "AbpSecurityLogs",
columns: new[] { "TenantId", "UserId" });
migrationBuilder.CreateIndex(
name: "IX_AbpSettings_Name_ProviderName_ProviderKey",
table: "AbpSettings",
columns: new[] { "Name", "ProviderName", "ProviderKey" });
migrationBuilder.CreateIndex(
name: "IX_AbpUserClaims_UserId",
table: "AbpUserClaims",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_AbpUserLogins_LoginProvider_ProviderKey",
table: "AbpUserLogins",
columns: new[] { "LoginProvider", "ProviderKey" });
migrationBuilder.CreateIndex(
name: "IX_AbpUserOrganizationUnits_UserId_OrganizationUnitId",
table: "AbpUserOrganizationUnits",
columns: new[] { "UserId", "OrganizationUnitId" });
migrationBuilder.CreateIndex(
name: "IX_AbpUserRoles_RoleId_UserId",
table: "AbpUserRoles",
columns: new[] { "RoleId", "UserId" });
migrationBuilder.CreateIndex(
name: "IX_AbpUsers_Email",
table: "AbpUsers",
column: "Email");
migrationBuilder.CreateIndex(
name: "IX_AbpUsers_NormalizedEmail",
table: "AbpUsers",
column: "NormalizedEmail");
migrationBuilder.CreateIndex(
name: "IX_AbpUsers_NormalizedUserName",
table: "AbpUsers",
column: "NormalizedUserName");
migrationBuilder.CreateIndex(
name: "IX_AbpUsers_UserName",
table: "AbpUsers",
column: "UserName");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AbpClaimTypes");
migrationBuilder.DropTable(
name: "AbpLinkUsers");
migrationBuilder.DropTable(
name: "AbpOrganizationUnitRoles");
migrationBuilder.DropTable(
name: "AbpPermissionGrants");
migrationBuilder.DropTable(
name: "AbpRoleClaims");
migrationBuilder.DropTable(
name: "AbpSecurityLogs");
migrationBuilder.DropTable(
name: "AbpSettings");
migrationBuilder.DropTable(
name: "AbpUserClaims");
migrationBuilder.DropTable(
name: "AbpUserLogins");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "AbpUserOrganizationUnits"); name: "AbpUserTokens");
migrationBuilder.DropTable(
name: "AbpUserRoles");
migrationBuilder.DropTable(
name: "AbpUserTokens");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "AbpOrganizationUnits"); name: "AbpOrganizationUnits");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "AbpRoles"); name: "AbpRoles");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "AbpUsers"); name: "AbpUsers");
}
} }
} }

9
modules/setting-management/app/Volo.Abp.SettingManagement.DemoApp/Pages/Index.cshtml.cs

@ -1,11 +1,10 @@
using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.AspNetCore.Mvc.RazorPages;
namespace Volo.Abp.SettingManagement.DemoApp.Pages namespace Volo.Abp.SettingManagement.DemoApp.Pages;
public class IndexModel : PageModel
{ {
public class IndexModel : PageModel public void OnGet()
{ {
public void OnGet()
{
}
} }
} }

69
modules/setting-management/app/Volo.Abp.SettingManagement.DemoApp/Program.cs

@ -4,44 +4,43 @@ using Microsoft.Extensions.Hosting;
using Serilog; using Serilog;
using Serilog.Events; using Serilog.Events;
namespace Volo.Abp.SettingManagement.DemoApp namespace Volo.Abp.SettingManagement.DemoApp;
public class Program
{ {
public class Program public static int Main(string[] args)
{ {
public static int Main(string[] args) Log.Logger = new LoggerConfiguration()
{ .MinimumLevel.Debug()
Log.Logger = new LoggerConfiguration() .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.MinimumLevel.Debug() .MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
.MinimumLevel.Override("Microsoft", LogEventLevel.Information) .Enrich.FromLogContext()
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) .WriteTo.File("Logs/logs.txt")
.Enrich.FromLogContext() .CreateLogger();
.WriteTo.File("Logs/logs.txt")
.CreateLogger();
try try
{ {
Log.Information("Starting web host."); Log.Information("Starting web host.");
CreateHostBuilder(args).Build().Run(); CreateHostBuilder(args).Build().Run();
return 0; return 0;
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Fatal(ex, "Host terminated unexpectedly!"); Log.Fatal(ex, "Host terminated unexpectedly!");
return 1; return 1;
} }
finally finally
{ {
Log.CloseAndFlush(); Log.CloseAndFlush();
}
} }
internal static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.UseAutofac()
.UseSerilog();
} }
internal static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.UseAutofac()
.UseSerilog();
} }

19
modules/setting-management/app/Volo.Abp.SettingManagement.DemoApp/Startup.cs

@ -3,18 +3,17 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace Volo.Abp.SettingManagement.DemoApp namespace Volo.Abp.SettingManagement.DemoApp;
public class Startup
{ {
public class Startup public void ConfigureServices(IServiceCollection services)
{ {
public void ConfigureServices(IServiceCollection services) services.AddApplication<DemoAppModule>();
{ }
services.AddApplication<DemoAppModule>();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
{ {
app.InitializeApplication(); app.InitializeApplication();
}
} }
} }

17
modules/setting-management/src/Volo.Abp.SettingManagement.Application.Contracts/Volo/Abp/SettingManagement/AbpSettingManagementApplicationContractsModule.cs

@ -2,16 +2,15 @@
using Volo.Abp.Authorization; using Volo.Abp.Authorization;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
[DependsOn(
typeof(AbpSettingManagementDomainSharedModule),
typeof(AbpDddApplicationContractsModule),
typeof(AbpAuthorizationAbstractionsModule)
)]
public class AbpSettingManagementApplicationContractsModule : AbpModule
{ {
[DependsOn(
typeof(AbpSettingManagementDomainSharedModule),
typeof(AbpDddApplicationContractsModule),
typeof(AbpAuthorizationAbstractionsModule)
)]
public class AbpSettingManagementApplicationContractsModule : AbpModule
{
}
} }

23
modules/setting-management/src/Volo.Abp.SettingManagement.Application.Contracts/Volo/Abp/SettingManagement/AllowTenantsToChangeEmailSettingsFeatureSimpleStateChecker.cs

@ -5,21 +5,20 @@ using Volo.Abp.Features;
using Volo.Abp.MultiTenancy; using Volo.Abp.MultiTenancy;
using Volo.Abp.SimpleStateChecking; using Volo.Abp.SimpleStateChecking;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
public class AllowTenantsToChangeEmailSettingsFeatureSimpleStateChecker : ISimpleStateChecker<PermissionDefinition>
{ {
public class AllowTenantsToChangeEmailSettingsFeatureSimpleStateChecker : ISimpleStateChecker<PermissionDefinition> public async Task<bool> IsEnabledAsync(SimpleStateCheckerContext<PermissionDefinition> context)
{ {
public async Task<bool> IsEnabledAsync(SimpleStateCheckerContext<PermissionDefinition> context) var currentTenant = context.ServiceProvider.GetRequiredService<ICurrentTenant>();
{
var currentTenant = context.ServiceProvider.GetRequiredService<ICurrentTenant>();
if (!currentTenant.IsAvailable)
{
return true;
}
var featureChecker = context.ServiceProvider.GetRequiredService<IFeatureChecker>(); if (!currentTenant.IsAvailable)
return await featureChecker.IsEnabledAsync(SettingManagementFeatures.AllowTenantsToChangeEmailSettings); {
return true;
} }
var featureChecker = context.ServiceProvider.GetRequiredService<IFeatureChecker>();
return await featureChecker.IsEnabledAsync(SettingManagementFeatures.AllowTenantsToChangeEmailSettings);
} }
} }

25
modules/setting-management/src/Volo.Abp.SettingManagement.Application.Contracts/Volo/Abp/SettingManagement/EmailSettingsDto.cs

@ -1,23 +1,22 @@
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
public class EmailSettingsDto
{ {
public class EmailSettingsDto public string SmtpHost { get; set; }
{
public string SmtpHost { get; set; }
public int SmtpPort { get; set; } public int SmtpPort { get; set; }
public string SmtpUserName { get; set; } public string SmtpUserName { get; set; }
public string SmtpPassword { get; set; } public string SmtpPassword { get; set; }
public string SmtpDomain { get; set; } public string SmtpDomain { get; set; }
public bool SmtpEnableSsl { get; set; } public bool SmtpEnableSsl { get; set; }
public bool SmtpUseDefaultCredentials { get; set; } public bool SmtpUseDefaultCredentials { get; set; }
public string DefaultFromAddress { get; set; } public string DefaultFromAddress { get; set; }
public string DefaultFromDisplayName { get; set; } public string DefaultFromDisplayName { get; set; }
}
} }

11
modules/setting-management/src/Volo.Abp.SettingManagement.Application.Contracts/Volo/Abp/SettingManagement/IEmailSettingsAppService.cs

@ -1,12 +1,11 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
public interface IEmailSettingsAppService : IApplicationService
{ {
public interface IEmailSettingsAppService : IApplicationService Task<EmailSettingsDto> GetAsync();
{
Task<EmailSettingsDto> GetAsync();
Task UpdateAsync(UpdateEmailSettingsDto input); Task UpdateAsync(UpdateEmailSettingsDto input);
}
} }

25
modules/setting-management/src/Volo.Abp.SettingManagement.Application.Contracts/Volo/Abp/SettingManagement/SettingManagementPermissionDefinitionProvider.cs

@ -2,22 +2,21 @@
using Volo.Abp.Localization; using Volo.Abp.Localization;
using Volo.Abp.SettingManagement.Localization; using Volo.Abp.SettingManagement.Localization;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
public class SettingManagementPermissionDefinitionProvider : PermissionDefinitionProvider
{ {
public class SettingManagementPermissionDefinitionProvider : PermissionDefinitionProvider public override void Define(IPermissionDefinitionContext context)
{ {
public override void Define(IPermissionDefinitionContext context) var moduleGroup = context.AddGroup(SettingManagementPermissions.GroupName, L("Permission:SettingManagement"));
{
var moduleGroup = context.AddGroup(SettingManagementPermissions.GroupName, L("Permission:SettingManagement"));
moduleGroup moduleGroup
.AddPermission(SettingManagementPermissions.Emailing, L("Permission:Emailing")) .AddPermission(SettingManagementPermissions.Emailing, L("Permission:Emailing"))
.StateCheckers.Add(new AllowTenantsToChangeEmailSettingsFeatureSimpleStateChecker()); .StateCheckers.Add(new AllowTenantsToChangeEmailSettingsFeatureSimpleStateChecker());
} }
private static LocalizableString L(string name) private static LocalizableString L(string name)
{ {
return LocalizableString.Create<AbpSettingManagementResource>(name); return LocalizableString.Create<AbpSettingManagementResource>(name);
}
} }
} }

17
modules/setting-management/src/Volo.Abp.SettingManagement.Application.Contracts/Volo/Abp/SettingManagement/SettingManagementPermissions.cs

@ -1,16 +1,15 @@
using Volo.Abp.Reflection; using Volo.Abp.Reflection;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
public class SettingManagementPermissions
{ {
public class SettingManagementPermissions public const string GroupName = "SettingManagement";
{
public const string GroupName = "SettingManagement";
public const string Emailing = GroupName + ".Emailing"; public const string Emailing = GroupName + ".Emailing";
public static string[] GetAll() public static string[] GetAll()
{ {
return ReflectionHelper.GetPublicConstantsRecursively(typeof(SettingManagementPermissions)); return ReflectionHelper.GetPublicConstantsRecursively(typeof(SettingManagementPermissions));
}
} }
} }

11
modules/setting-management/src/Volo.Abp.SettingManagement.Application.Contracts/Volo/Abp/SettingManagement/SettingManagementRemoteServiceConsts.cs

@ -1,9 +1,8 @@
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
public class SettingManagementRemoteServiceConsts
{ {
public class SettingManagementRemoteServiceConsts public const string RemoteServiceName = "SettingManagement";
{
public const string RemoteServiceName = "SettingManagement";
public const string ModuleName = "settingManagement"; public const string ModuleName = "settingManagement";
}
} }

47
modules/setting-management/src/Volo.Abp.SettingManagement.Application.Contracts/Volo/Abp/SettingManagement/UpdateEmailSettingsDto.cs

@ -1,38 +1,37 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Volo.Abp.Auditing; using Volo.Abp.Auditing;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
public class UpdateEmailSettingsDto
{ {
public class UpdateEmailSettingsDto [MaxLength(256)]
{ public string SmtpHost { get; set; }
[MaxLength(256)]
public string SmtpHost { get; set; }
[Range(1, 65535)] [Range(1, 65535)]
public int SmtpPort { get; set; } public int SmtpPort { get; set; }
[MaxLength(1024)] [MaxLength(1024)]
public string SmtpUserName { get; set; } public string SmtpUserName { get; set; }
[MaxLength(1024)] [MaxLength(1024)]
[DataType(DataType.Password)] [DataType(DataType.Password)]
[DisableAuditing] [DisableAuditing]
public string SmtpPassword { get; set; } public string SmtpPassword { get; set; }
[MaxLength(1024)] [MaxLength(1024)]
public string SmtpDomain { get; set; } public string SmtpDomain { get; set; }
public bool SmtpEnableSsl { get; set; } public bool SmtpEnableSsl { get; set; }
public bool SmtpUseDefaultCredentials { get; set; } public bool SmtpUseDefaultCredentials { get; set; }
[MaxLength(1024)] [MaxLength(1024)]
[Required] [Required]
public string DefaultFromAddress { get; set; } public string DefaultFromAddress { get; set; }
[MaxLength(1024)] [MaxLength(1024)]
[Required] [Required]
public string DefaultFromDisplayName { get; set; } public string DefaultFromDisplayName { get; set; }
}
} }

19
modules/setting-management/src/Volo.Abp.SettingManagement.Application/Volo/Abp/SettingManagement/AbpSettingManagementApplicationModule.cs

@ -2,15 +2,14 @@
using Volo.Abp.Emailing; using Volo.Abp.Emailing;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
[DependsOn(
typeof(AbpDddApplicationModule),
typeof(AbpSettingManagementDomainModule),
typeof(AbpSettingManagementApplicationContractsModule),
typeof(AbpEmailingModule)
)]
public class AbpSettingManagementApplicationModule : AbpModule
{ {
[DependsOn(
typeof(AbpDddApplicationModule),
typeof(AbpSettingManagementDomainModule),
typeof(AbpSettingManagementApplicationContractsModule),
typeof(AbpEmailingModule)
)]
public class AbpSettingManagementApplicationModule : AbpModule
{
}
} }

100
modules/setting-management/src/Volo.Abp.SettingManagement.Application/Volo/Abp/SettingManagement/EmailSettingsAppService.cs

@ -5,67 +5,67 @@ using Volo.Abp.Emailing;
using Volo.Abp.MultiTenancy; using Volo.Abp.MultiTenancy;
using Volo.Abp.Features; using Volo.Abp.Features;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
[Authorize(SettingManagementPermissions.Emailing)]
public class EmailSettingsAppService : SettingManagementAppServiceBase, IEmailSettingsAppService
{ {
[Authorize(SettingManagementPermissions.Emailing)] protected ISettingManager SettingManager { get; }
public class EmailSettingsAppService : SettingManagementAppServiceBase, IEmailSettingsAppService
public EmailSettingsAppService(ISettingManager settingManager)
{ {
protected ISettingManager SettingManager { get; } SettingManager = settingManager;
}
public EmailSettingsAppService(ISettingManager settingManager) public virtual async Task<EmailSettingsDto> GetAsync()
{ {
SettingManager = settingManager; await CheckFeatureAsync();
}
public virtual async Task<EmailSettingsDto> GetAsync() var settingsDto = new EmailSettingsDto
{ {
await CheckFeatureAsync(); SmtpHost = await SettingProvider.GetOrNullAsync(EmailSettingNames.Smtp.Host),
SmtpPort = Convert.ToInt32(await SettingProvider.GetOrNullAsync(EmailSettingNames.Smtp.Port)),
var settingsDto = new EmailSettingsDto { SmtpUserName = await SettingProvider.GetOrNullAsync(EmailSettingNames.Smtp.UserName),
SmtpHost = await SettingProvider.GetOrNullAsync(EmailSettingNames.Smtp.Host), SmtpPassword = await SettingProvider.GetOrNullAsync(EmailSettingNames.Smtp.Password),
SmtpPort = Convert.ToInt32(await SettingProvider.GetOrNullAsync(EmailSettingNames.Smtp.Port)), SmtpDomain = await SettingProvider.GetOrNullAsync(EmailSettingNames.Smtp.Domain),
SmtpUserName = await SettingProvider.GetOrNullAsync(EmailSettingNames.Smtp.UserName), SmtpEnableSsl = Convert.ToBoolean(await SettingProvider.GetOrNullAsync(EmailSettingNames.Smtp.EnableSsl)),
SmtpPassword = await SettingProvider.GetOrNullAsync(EmailSettingNames.Smtp.Password), SmtpUseDefaultCredentials = Convert.ToBoolean(await SettingProvider.GetOrNullAsync(EmailSettingNames.Smtp.UseDefaultCredentials)),
SmtpDomain = await SettingProvider.GetOrNullAsync(EmailSettingNames.Smtp.Domain), DefaultFromAddress = await SettingProvider.GetOrNullAsync(EmailSettingNames.DefaultFromAddress),
SmtpEnableSsl = Convert.ToBoolean(await SettingProvider.GetOrNullAsync(EmailSettingNames.Smtp.EnableSsl)), DefaultFromDisplayName = await SettingProvider.GetOrNullAsync(EmailSettingNames.DefaultFromDisplayName),
SmtpUseDefaultCredentials = Convert.ToBoolean(await SettingProvider.GetOrNullAsync(EmailSettingNames.Smtp.UseDefaultCredentials)), };
DefaultFromAddress = await SettingProvider.GetOrNullAsync(EmailSettingNames.DefaultFromAddress),
DefaultFromDisplayName = await SettingProvider.GetOrNullAsync(EmailSettingNames.DefaultFromDisplayName),
};
if (CurrentTenant.IsAvailable)
{
settingsDto.SmtpHost = await SettingManager.GetOrNullForTenantAsync(EmailSettingNames.Smtp.Host, CurrentTenant.GetId(), false);
settingsDto.SmtpUserName = await SettingManager.GetOrNullForTenantAsync(EmailSettingNames.Smtp.UserName, CurrentTenant.GetId(), false);
settingsDto.SmtpPassword = await SettingManager.GetOrNullForTenantAsync(EmailSettingNames.Smtp.Password, CurrentTenant.GetId(), false);
settingsDto.SmtpDomain = await SettingManager.GetOrNullForTenantAsync(EmailSettingNames.Smtp.Domain, CurrentTenant.GetId(), false);
}
return settingsDto; if (CurrentTenant.IsAvailable)
{
settingsDto.SmtpHost = await SettingManager.GetOrNullForTenantAsync(EmailSettingNames.Smtp.Host, CurrentTenant.GetId(), false);
settingsDto.SmtpUserName = await SettingManager.GetOrNullForTenantAsync(EmailSettingNames.Smtp.UserName, CurrentTenant.GetId(), false);
settingsDto.SmtpPassword = await SettingManager.GetOrNullForTenantAsync(EmailSettingNames.Smtp.Password, CurrentTenant.GetId(), false);
settingsDto.SmtpDomain = await SettingManager.GetOrNullForTenantAsync(EmailSettingNames.Smtp.Domain, CurrentTenant.GetId(), false);
} }
public virtual async Task UpdateAsync(UpdateEmailSettingsDto input) return settingsDto;
{ }
await CheckFeatureAsync();
await SettingManager.SetForTenantOrGlobalAsync(CurrentTenant.Id, EmailSettingNames.Smtp.Host, input.SmtpHost); public virtual async Task UpdateAsync(UpdateEmailSettingsDto input)
await SettingManager.SetForTenantOrGlobalAsync(CurrentTenant.Id, EmailSettingNames.Smtp.Port, input.SmtpPort.ToString()); {
await SettingManager.SetForTenantOrGlobalAsync(CurrentTenant.Id, EmailSettingNames.Smtp.UserName, input.SmtpUserName); await CheckFeatureAsync();
await SettingManager.SetForTenantOrGlobalAsync(CurrentTenant.Id, EmailSettingNames.Smtp.Password, input.SmtpPassword);
await SettingManager.SetForTenantOrGlobalAsync(CurrentTenant.Id, EmailSettingNames.Smtp.Domain, input.SmtpDomain); await SettingManager.SetForTenantOrGlobalAsync(CurrentTenant.Id, EmailSettingNames.Smtp.Host, input.SmtpHost);
await SettingManager.SetForTenantOrGlobalAsync(CurrentTenant.Id, EmailSettingNames.Smtp.EnableSsl, input.SmtpEnableSsl.ToString()); await SettingManager.SetForTenantOrGlobalAsync(CurrentTenant.Id, EmailSettingNames.Smtp.Port, input.SmtpPort.ToString());
await SettingManager.SetForTenantOrGlobalAsync(CurrentTenant.Id, EmailSettingNames.Smtp.UseDefaultCredentials, input.SmtpUseDefaultCredentials.ToString().ToLowerInvariant()); await SettingManager.SetForTenantOrGlobalAsync(CurrentTenant.Id, EmailSettingNames.Smtp.UserName, input.SmtpUserName);
await SettingManager.SetForTenantOrGlobalAsync(CurrentTenant.Id, EmailSettingNames.DefaultFromAddress, input.DefaultFromAddress); await SettingManager.SetForTenantOrGlobalAsync(CurrentTenant.Id, EmailSettingNames.Smtp.Password, input.SmtpPassword);
await SettingManager.SetForTenantOrGlobalAsync(CurrentTenant.Id, EmailSettingNames.DefaultFromDisplayName, input.DefaultFromDisplayName); await SettingManager.SetForTenantOrGlobalAsync(CurrentTenant.Id, EmailSettingNames.Smtp.Domain, input.SmtpDomain);
} await SettingManager.SetForTenantOrGlobalAsync(CurrentTenant.Id, EmailSettingNames.Smtp.EnableSsl, input.SmtpEnableSsl.ToString());
await SettingManager.SetForTenantOrGlobalAsync(CurrentTenant.Id, EmailSettingNames.Smtp.UseDefaultCredentials, input.SmtpUseDefaultCredentials.ToString().ToLowerInvariant());
await SettingManager.SetForTenantOrGlobalAsync(CurrentTenant.Id, EmailSettingNames.DefaultFromAddress, input.DefaultFromAddress);
await SettingManager.SetForTenantOrGlobalAsync(CurrentTenant.Id, EmailSettingNames.DefaultFromDisplayName, input.DefaultFromDisplayName);
}
protected virtual async Task CheckFeatureAsync() protected virtual async Task CheckFeatureAsync()
{
await FeatureChecker.CheckEnabledAsync(SettingManagementFeatures.Enable);
if (CurrentTenant.IsAvailable)
{ {
await FeatureChecker.CheckEnabledAsync(SettingManagementFeatures.Enable); await FeatureChecker.CheckEnabledAsync(SettingManagementFeatures.AllowTenantsToChangeEmailSettings);
if (CurrentTenant.IsAvailable)
{
await FeatureChecker.CheckEnabledAsync(SettingManagementFeatures.AllowTenantsToChangeEmailSettings);
}
} }
} }
} }

13
modules/setting-management/src/Volo.Abp.SettingManagement.Application/Volo/Abp/SettingManagement/SettingManagementAppServiceBase.cs

@ -1,14 +1,13 @@
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Volo.Abp.SettingManagement.Localization; using Volo.Abp.SettingManagement.Localization;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
public abstract class SettingManagementAppServiceBase : ApplicationService
{ {
public abstract class SettingManagementAppServiceBase : ApplicationService protected SettingManagementAppServiceBase()
{ {
protected SettingManagementAppServiceBase() ObjectMapperContext = typeof(AbpSettingManagementApplicationModule);
{ LocalizationResource = typeof(AbpSettingManagementResource);
ObjectMapperContext = typeof(AbpSettingManagementApplicationModule);
LocalizationResource = typeof(AbpSettingManagementResource);
}
} }
} }

15
modules/setting-management/src/Volo.Abp.SettingManagement.Blazor.Server/AbpSettingManagementBlazorServerModule.cs

@ -1,13 +1,12 @@
using Volo.Abp.AspNetCore.Components.Server.Theming; using Volo.Abp.AspNetCore.Components.Server.Theming;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
namespace Volo.Abp.SettingManagement.Blazor.Server namespace Volo.Abp.SettingManagement.Blazor.Server;
[DependsOn(
typeof(AbpSettingManagementBlazorModule),
typeof(AbpAspNetCoreComponentsServerThemingModule)
)]
public class AbpSettingManagementBlazorServerModule : AbpModule
{ {
[DependsOn(
typeof(AbpSettingManagementBlazorModule),
typeof(AbpAspNetCoreComponentsServerThemingModule)
)]
public class AbpSettingManagementBlazorServerModule : AbpModule
{
}
} }

17
modules/setting-management/src/Volo.Abp.SettingManagement.Blazor.WebAssembly/AbpSettingManagementBlazorWebAssemblyModule.cs

@ -1,14 +1,13 @@
using Volo.Abp.AspNetCore.Components.WebAssembly.Theming; using Volo.Abp.AspNetCore.Components.WebAssembly.Theming;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
namespace Volo.Abp.SettingManagement.Blazor.WebAssembly namespace Volo.Abp.SettingManagement.Blazor.WebAssembly;
[DependsOn(
typeof(AbpSettingManagementBlazorModule),
typeof(AbpAspNetCoreComponentsWebAssemblyThemingModule),
typeof(AbpSettingManagementHttpApiClientModule)
)]
public class AbpSettingManagementBlazorWebAssemblyModule : AbpModule
{ {
[DependsOn(
typeof(AbpSettingManagementBlazorModule),
typeof(AbpAspNetCoreComponentsWebAssemblyThemingModule),
typeof(AbpSettingManagementHttpApiClientModule)
)]
public class AbpSettingManagementBlazorWebAssemblyModule : AbpModule
{
}
} }

53
modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/AbpSettingManagementBlazorModule.cs

@ -7,38 +7,37 @@ using Volo.Abp.SettingManagement.Blazor.Menus;
using Volo.Abp.SettingManagement.Blazor.Settings; using Volo.Abp.SettingManagement.Blazor.Settings;
using Volo.Abp.UI.Navigation; using Volo.Abp.UI.Navigation;
namespace Volo.Abp.SettingManagement.Blazor namespace Volo.Abp.SettingManagement.Blazor;
[DependsOn(
typeof(AbpAutoMapperModule),
typeof(AbpAspNetCoreComponentsWebThemingModule),
typeof(AbpSettingManagementApplicationContractsModule)
)]
public class AbpSettingManagementBlazorModule : AbpModule
{ {
[DependsOn( public override void ConfigureServices(ServiceConfigurationContext context)
typeof(AbpAutoMapperModule),
typeof(AbpAspNetCoreComponentsWebThemingModule),
typeof(AbpSettingManagementApplicationContractsModule)
)]
public class AbpSettingManagementBlazorModule : AbpModule
{ {
public override void ConfigureServices(ServiceConfigurationContext context) context.Services.AddAutoMapperObjectMapper<AbpSettingManagementBlazorModule>();
{
context.Services.AddAutoMapperObjectMapper<AbpSettingManagementBlazorModule>();
Configure<AbpAutoMapperOptions>(options => Configure<AbpAutoMapperOptions>(options =>
{ {
options.AddProfile<SettingManagementBlazorAutoMapperProfile>(validate: true); options.AddProfile<SettingManagementBlazorAutoMapperProfile>(validate: true);
}); });
Configure<AbpNavigationOptions>(options => Configure<AbpNavigationOptions>(options =>
{ {
options.MenuContributors.Add(new SettingManagementMenuContributor()); options.MenuContributors.Add(new SettingManagementMenuContributor());
}); });
Configure<AbpRouterOptions>(options => Configure<AbpRouterOptions>(options =>
{ {
options.AdditionalAssemblies.Add(typeof(AbpSettingManagementBlazorModule).Assembly); options.AdditionalAssemblies.Add(typeof(AbpSettingManagementBlazorModule).Assembly);
}); });
Configure<SettingManagementComponentOptions>(options => Configure<SettingManagementComponentOptions>(options =>
{ {
options.Contributors.Add(new EmailingPageContributor()); options.Contributors.Add(new EmailingPageContributor());
}); });
}
} }
} }

13
modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/ISettingComponentContributor.cs

@ -1,11 +1,10 @@
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Volo.Abp.SettingManagement.Blazor namespace Volo.Abp.SettingManagement.Blazor;
public interface ISettingComponentContributor
{ {
public interface ISettingComponentContributor Task ConfigureAsync(SettingComponentCreationContext context);
{
Task ConfigureAsync(SettingComponentCreationContext context);
Task<bool> CheckPermissionsAsync(SettingComponentCreationContext context); Task<bool> CheckPermissionsAsync(SettingComponentCreationContext context);
} }
}

79
modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Menus/SettingManagementMenuContributor.cs

@ -6,59 +6,58 @@ using Volo.Abp.Features;
using Volo.Abp.SettingManagement.Localization; using Volo.Abp.SettingManagement.Localization;
using Volo.Abp.UI.Navigation; using Volo.Abp.UI.Navigation;
namespace Volo.Abp.SettingManagement.Blazor.Menus namespace Volo.Abp.SettingManagement.Blazor.Menus;
public class SettingManagementMenuContributor : IMenuContributor
{ {
public class SettingManagementMenuContributor : IMenuContributor public async Task ConfigureMenuAsync(MenuConfigurationContext context)
{ {
public async Task ConfigureMenuAsync(MenuConfigurationContext context) if (context.Menu.Name == StandardMenus.Main)
{ {
if (context.Menu.Name == StandardMenus.Main) await ConfigureMainMenuAsync(context);
{
await ConfigureMainMenuAsync(context);
}
} }
}
private async Task ConfigureMainMenuAsync(MenuConfigurationContext context) private async Task ConfigureMainMenuAsync(MenuConfigurationContext context)
{
var settingManagementPageOptions = context.ServiceProvider.GetRequiredService<IOptions<SettingManagementComponentOptions>>().Value;
var settingPageCreationContext = new SettingComponentCreationContext(context.ServiceProvider);
if (!settingManagementPageOptions.Contributors.Any() ||
!(await CheckAnyOfPagePermissionsGranted(settingManagementPageOptions, settingPageCreationContext))
)
{ {
var settingManagementPageOptions = context.ServiceProvider.GetRequiredService<IOptions<SettingManagementComponentOptions>>().Value; return;
var settingPageCreationContext = new SettingComponentCreationContext(context.ServiceProvider); }
if (!settingManagementPageOptions.Contributors.Any() ||
!(await CheckAnyOfPagePermissionsGranted(settingManagementPageOptions, settingPageCreationContext))
)
{
return;
}
var l = context.GetLocalizer<AbpSettingManagementResource>(); var l = context.GetLocalizer<AbpSettingManagementResource>();
/* This may happen if MVC UI is being used in the same application. /* This may happen if MVC UI is being used in the same application.
* In this case, we are removing the MVC setting management UI. */ * In this case, we are removing the MVC setting management UI. */
context.Menu.GetAdministration().TryRemoveMenuItem(SettingManagementMenus.GroupName); context.Menu.GetAdministration().TryRemoveMenuItem(SettingManagementMenus.GroupName);
context.Menu context.Menu
.GetAdministration() .GetAdministration()
.AddItem( .AddItem(
new ApplicationMenuItem( new ApplicationMenuItem(
SettingManagementMenus.GroupName, SettingManagementMenus.GroupName,
l["Settings"], l["Settings"],
"~/setting-management", "~/setting-management",
icon: "fa fa-cog" icon: "fa fa-cog"
).RequireFeatures(SettingManagementFeatures.Enable) ).RequireFeatures(SettingManagementFeatures.Enable)
); );
} }
protected virtual async Task<bool> CheckAnyOfPagePermissionsGranted( protected virtual async Task<bool> CheckAnyOfPagePermissionsGranted(
SettingManagementComponentOptions settingManagementComponentOptions, SettingManagementComponentOptions settingManagementComponentOptions,
SettingComponentCreationContext settingComponentCreationContext) SettingComponentCreationContext settingComponentCreationContext)
{
foreach (var contributor in settingManagementComponentOptions.Contributors)
{ {
foreach (var contributor in settingManagementComponentOptions.Contributors) if (await contributor.CheckPermissionsAsync(settingComponentCreationContext))
{ {
if (await contributor.CheckPermissionsAsync(settingComponentCreationContext)) return true;
{
return true;
}
} }
return false;
} }
return false;
} }
} }

11
modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Menus/SettingManagementMenus.cs

@ -1,7 +1,6 @@
namespace Volo.Abp.SettingManagement.Blazor.Menus namespace Volo.Abp.SettingManagement.Blazor.Menus;
public class SettingManagementMenus
{ {
public class SettingManagementMenus public const string GroupName = "SettingManagement";
{ }
public const string GroupName = "SettingManagement";
}
}

75
modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Pages/SettingManagement/EmailSettingGroup/EmailSettingGroupViewComponent.razor.cs

@ -6,55 +6,54 @@ using Volo.Abp.AspNetCore.Components.Messages;
using Volo.Abp.AspNetCore.Components.Web.Configuration; using Volo.Abp.AspNetCore.Components.Web.Configuration;
using Volo.Abp.SettingManagement.Localization; using Volo.Abp.SettingManagement.Localization;
namespace Volo.Abp.SettingManagement.Blazor.Pages.SettingManagement.EmailSettingGroup namespace Volo.Abp.SettingManagement.Blazor.Pages.SettingManagement.EmailSettingGroup;
public partial class EmailSettingGroupViewComponent
{ {
public partial class EmailSettingGroupViewComponent [Inject]
{ protected IEmailSettingsAppService EmailSettingsAppService { get; set; }
[Inject]
protected IEmailSettingsAppService EmailSettingsAppService { get; set; }
[Inject]
private ICurrentApplicationConfigurationCacheResetService CurrentApplicationConfigurationCacheResetService { get; set; }
[Inject] [Inject]
protected IUiMessageService UiMessageService { get; set; } private ICurrentApplicationConfigurationCacheResetService CurrentApplicationConfigurationCacheResetService { get; set; }
protected EmailSettingsDto EmailSettings; [Inject]
protected IUiMessageService UiMessageService { get; set; }
protected Validations IdentitySettingValidation; protected EmailSettingsDto EmailSettings;
public EmailSettingGroupViewComponent() protected Validations IdentitySettingValidation;
public EmailSettingGroupViewComponent()
{
ObjectMapperContext = typeof(AbpSettingManagementBlazorModule);
LocalizationResource = typeof(AbpSettingManagementResource);
}
protected override async Task OnInitializedAsync()
{
try
{ {
ObjectMapperContext = typeof(AbpSettingManagementBlazorModule); EmailSettings = await EmailSettingsAppService.GetAsync();
LocalizationResource = typeof(AbpSettingManagementResource);
} }
catch (Exception ex)
protected override async Task OnInitializedAsync()
{ {
try await HandleErrorAsync(ex);
{
EmailSettings = await EmailSettingsAppService.GetAsync();
}
catch (Exception ex)
{
await HandleErrorAsync(ex);
}
} }
}
protected virtual async Task UpdateSettingsAsync()
{
try
{
await EmailSettingsAppService.UpdateAsync(ObjectMapper.Map<EmailSettingsDto, UpdateEmailSettingsDto>(EmailSettings));
await CurrentApplicationConfigurationCacheResetService.ResetAsync();
protected virtual async Task UpdateSettingsAsync() await UiMessageService.Success(L["SuccessfullySaved"]);
}
catch (Exception ex)
{ {
try await HandleErrorAsync(ex);
{
await EmailSettingsAppService.UpdateAsync(ObjectMapper.Map<EmailSettingsDto, UpdateEmailSettingsDto>(EmailSettings));
await CurrentApplicationConfigurationCacheResetService.ResetAsync();
await UiMessageService.Success(L["SuccessfullySaved"]);
}
catch (Exception ex)
{
await HandleErrorAsync(ex);
}
} }
} }
} }

57
modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Pages/SettingManagement/SettingManagement.razor.cs

@ -8,44 +8,43 @@ using Microsoft.Extensions.Options;
using Volo.Abp.BlazoriseUI; using Volo.Abp.BlazoriseUI;
using Volo.Abp.SettingManagement.Localization; using Volo.Abp.SettingManagement.Localization;
namespace Volo.Abp.SettingManagement.Blazor.Pages.SettingManagement namespace Volo.Abp.SettingManagement.Blazor.Pages.SettingManagement;
public partial class SettingManagement
{ {
public partial class SettingManagement [Inject]
{ protected IServiceProvider ServiceProvider { get; set; }
[Inject]
protected IServiceProvider ServiceProvider { get; set; }
protected SettingComponentCreationContext SettingComponentCreationContext { get; set; } protected SettingComponentCreationContext SettingComponentCreationContext { get; set; }
[Inject] [Inject]
protected IOptions<SettingManagementComponentOptions> _options { get; set; } protected IOptions<SettingManagementComponentOptions> _options { get; set; }
[Inject] [Inject]
protected IStringLocalizer<AbpSettingManagementResource> L { get; set; } protected IStringLocalizer<AbpSettingManagementResource> L { get; set; }
protected SettingManagementComponentOptions Options => _options.Value; protected SettingManagementComponentOptions Options => _options.Value;
protected List<RenderFragment> SettingItemRenders { get; set; } = new List<RenderFragment>(); protected List<RenderFragment> SettingItemRenders { get; set; } = new List<RenderFragment>();
protected string SelectedGroup; protected string SelectedGroup;
protected List<BreadcrumbItem> BreadcrumbItems = new List<BreadcrumbItem>(); protected List<BreadcrumbItem> BreadcrumbItems = new List<BreadcrumbItem>();
protected async override Task OnInitializedAsync() protected async override Task OnInitializedAsync()
{ {
SettingComponentCreationContext = new SettingComponentCreationContext(ServiceProvider); SettingComponentCreationContext = new SettingComponentCreationContext(ServiceProvider);
foreach (var contributor in Options.Contributors) foreach (var contributor in Options.Contributors)
{ {
await contributor.ConfigureAsync(SettingComponentCreationContext); await contributor.ConfigureAsync(SettingComponentCreationContext);
} }
SettingItemRenders.Clear(); SettingItemRenders.Clear();
SelectedGroup = GetNormalizedString(SettingComponentCreationContext.Groups.First().Id); SelectedGroup = GetNormalizedString(SettingComponentCreationContext.Groups.First().Id);
} }
protected virtual string GetNormalizedString(string value) protected virtual string GetNormalizedString(string value)
{ {
return value.Replace('.', '_'); return value.Replace('.', '_');
}
} }
} }

21
modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/SettingComponentCreationContext.cs

@ -2,19 +2,18 @@
using System.Collections.Generic; using System.Collections.Generic;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
namespace Volo.Abp.SettingManagement.Blazor namespace Volo.Abp.SettingManagement.Blazor;
public class SettingComponentCreationContext : IServiceProviderAccessor
{ {
public class SettingComponentCreationContext : IServiceProviderAccessor public IServiceProvider ServiceProvider { get; }
{
public IServiceProvider ServiceProvider { get; }
public List<SettingComponentGroup> Groups { get; } public List<SettingComponentGroup> Groups { get; }
public SettingComponentCreationContext(IServiceProvider serviceProvider) public SettingComponentCreationContext(IServiceProvider serviceProvider)
{ {
ServiceProvider = serviceProvider; ServiceProvider = serviceProvider;
Groups = new List<SettingComponentGroup>(); Groups = new List<SettingComponentGroup>();
}
} }
} }

56
modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/SettingComponentGroup.cs

@ -1,39 +1,35 @@
using System; using System;
using JetBrains.Annotations; using JetBrains.Annotations;
namespace Volo.Abp.SettingManagement.Blazor namespace Volo.Abp.SettingManagement.Blazor;
public class SettingComponentGroup
{ {
public class SettingComponentGroup public string Id {
{ get => _id;
public string Id set => _id = Check.NotNullOrWhiteSpace(value, nameof(Id));
{ }
get => _id; private string _id;
set => _id = Check.NotNullOrWhiteSpace(value, nameof(Id));
}
private string _id;
public string DisplayName public string DisplayName {
{ get => _displayName;
get => _displayName; set => _displayName = Check.NotNullOrWhiteSpace(value, nameof(DisplayName));
set => _displayName = Check.NotNullOrWhiteSpace(value, nameof(DisplayName)); }
} private string _displayName;
private string _displayName;
public Type ComponentType public Type ComponentType {
{ get => _componentType;
get => _componentType; set => _componentType = Check.NotNull(value, nameof(ComponentType));
set => _componentType = Check.NotNull(value, nameof(ComponentType)); }
} private Type _componentType;
private Type _componentType;
public object Parameter { get; set; } public object Parameter { get; set; }
public SettingComponentGroup([NotNull] string id, [NotNull] string displayName, [NotNull] Type componentType, object parameter = null) public SettingComponentGroup([NotNull] string id, [NotNull] string displayName, [NotNull] Type componentType, object parameter = null)
{ {
Id = id; Id = id;
DisplayName = displayName; DisplayName = displayName;
ComponentType = componentType; ComponentType = componentType;
Parameter = parameter; Parameter = parameter;
}
} }
} }

11
modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/SettingManagementBlazorAutoMapperProfile.cs

@ -1,12 +1,11 @@
using AutoMapper; using AutoMapper;
namespace Volo.Abp.SettingManagement.Blazor namespace Volo.Abp.SettingManagement.Blazor;
public class SettingManagementBlazorAutoMapperProfile : Profile
{ {
public class SettingManagementBlazorAutoMapperProfile : Profile public SettingManagementBlazorAutoMapperProfile()
{ {
public SettingManagementBlazorAutoMapperProfile() CreateMap<EmailSettingsDto, UpdateEmailSettingsDto>();
{
CreateMap<EmailSettingsDto, UpdateEmailSettingsDto>();
}
} }
} }

15
modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/SettingManagementComponentOptions.cs

@ -1,14 +1,13 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace Volo.Abp.SettingManagement.Blazor namespace Volo.Abp.SettingManagement.Blazor;
public class SettingManagementComponentOptions
{ {
public class SettingManagementComponentOptions public List<ISettingComponentContributor> Contributors { get; }
{
public List<ISettingComponentContributor> Contributors { get; }
public SettingManagementComponentOptions() public SettingManagementComponentOptions()
{ {
Contributors = new List<ISettingComponentContributor>(); Contributors = new List<ISettingComponentContributor>();
}
} }
} }

73
modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Settings/EmailingPageContributor.cs

@ -7,57 +7,56 @@ using Volo.Abp.MultiTenancy;
using Volo.Abp.SettingManagement.Blazor.Pages.SettingManagement.EmailSettingGroup; using Volo.Abp.SettingManagement.Blazor.Pages.SettingManagement.EmailSettingGroup;
using Volo.Abp.SettingManagement.Localization; using Volo.Abp.SettingManagement.Localization;
namespace Volo.Abp.SettingManagement.Blazor.Settings namespace Volo.Abp.SettingManagement.Blazor.Settings;
public class EmailingPageContributor : ISettingComponentContributor
{ {
public class EmailingPageContributor: ISettingComponentContributor public async Task ConfigureAsync(SettingComponentCreationContext context)
{ {
public async Task ConfigureAsync(SettingComponentCreationContext context) if (!await CheckPermissionsInternalAsync(context))
{ {
if (!await CheckPermissionsInternalAsync(context)) return;
{
return;
}
var l = context.ServiceProvider.GetRequiredService<IStringLocalizer<AbpSettingManagementResource>>();
context.Groups.Add(
new SettingComponentGroup(
"Volo.Abp.SettingManagement",
l["Menu:Emailing"],
typeof(EmailSettingGroupViewComponent)
)
);
} }
public async Task<bool> CheckPermissionsAsync(SettingComponentCreationContext context) var l = context.ServiceProvider.GetRequiredService<IStringLocalizer<AbpSettingManagementResource>>();
context.Groups.Add(
new SettingComponentGroup(
"Volo.Abp.SettingManagement",
l["Menu:Emailing"],
typeof(EmailSettingGroupViewComponent)
)
);
}
public async Task<bool> CheckPermissionsAsync(SettingComponentCreationContext context)
{
return await CheckPermissionsInternalAsync(context);
}
private async Task<bool> CheckPermissionsInternalAsync(SettingComponentCreationContext context)
{
if (!await CheckFeatureAsync(context))
{ {
return await CheckPermissionsInternalAsync(context); return false;
} }
private async Task<bool> CheckPermissionsInternalAsync(SettingComponentCreationContext context) var authorizationService = context.ServiceProvider.GetRequiredService<IAuthorizationService>();
{
if (!await CheckFeatureAsync(context))
{
return false;
}
var authorizationService = context.ServiceProvider.GetRequiredService<IAuthorizationService>(); return await authorizationService.IsGrantedAsync(SettingManagementPermissions.Emailing);
}
return await authorizationService.IsGrantedAsync(SettingManagementPermissions.Emailing); private async Task<bool> CheckFeatureAsync(SettingComponentCreationContext context)
} {
var currentTenant = context.ServiceProvider.GetRequiredService<ICurrentTenant>();
private async Task<bool> CheckFeatureAsync(SettingComponentCreationContext context) if (!currentTenant.IsAvailable)
{ {
var currentTenant = context.ServiceProvider.GetRequiredService<ICurrentTenant>(); return true;
}
if (!currentTenant.IsAvailable)
{
return true;
}
var featureCheck = context.ServiceProvider.GetRequiredService<IFeatureChecker>(); var featureCheck = context.ServiceProvider.GetRequiredService<IFeatureChecker>();
return await featureCheck.IsEnabledAsync(SettingManagementFeatures.AllowTenantsToChangeEmailSettings); return await featureCheck.IsEnabledAsync(SettingManagementFeatures.AllowTenantsToChangeEmailSettings);
}
} }
} }

33
modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/AbpSettingManagementDomainSharedModule.cs

@ -5,26 +5,25 @@ using Volo.Abp.SettingManagement.Localization;
using Volo.Abp.Validation; using Volo.Abp.Validation;
using Volo.Abp.VirtualFileSystem; using Volo.Abp.VirtualFileSystem;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
[DependsOn(typeof(AbpLocalizationModule),
typeof(AbpValidationModule),
typeof(AbpFeaturesModule))]
public class AbpSettingManagementDomainSharedModule : AbpModule
{ {
[DependsOn(typeof(AbpLocalizationModule), public override void ConfigureServices(ServiceConfigurationContext context)
typeof(AbpValidationModule),
typeof(AbpFeaturesModule))]
public class AbpSettingManagementDomainSharedModule : AbpModule
{ {
public override void ConfigureServices(ServiceConfigurationContext context) Configure<AbpVirtualFileSystemOptions>(options =>
{ {
Configure<AbpVirtualFileSystemOptions>(options => options.FileSets.AddEmbedded<AbpSettingManagementDomainSharedModule>();
{ });
options.FileSets.AddEmbedded<AbpSettingManagementDomainSharedModule>();
});
Configure<AbpLocalizationOptions>(options => Configure<AbpLocalizationOptions>(options =>
{ {
options.Resources options.Resources
.Add<AbpSettingManagementResource>("en") .Add<AbpSettingManagementResource>("en")
.AddVirtualJson("/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement"); .AddVirtualJson("/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement");
}); });
}
} }
} }

9
modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/AbpSettingManagementResource.cs

@ -1,10 +1,9 @@
using Volo.Abp.Localization; using Volo.Abp.Localization;
namespace Volo.Abp.SettingManagement.Localization namespace Volo.Abp.SettingManagement.Localization;
[LocalizationResourceName("AbpSettingManagement")]
public class AbpSettingManagementResource
{ {
[LocalizationResourceName("AbpSettingManagement")]
public class AbpSettingManagementResource
{
}
} }

49
modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/SettingConsts.cs

@ -1,27 +1,26 @@
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
public static class SettingConsts
{ {
public static class SettingConsts /// <summary>
{ /// Default value: 128
/// <summary> /// </summary>
/// Default value: 128 public static int MaxNameLength { get; set; } = 128;
/// </summary>
public static int MaxNameLength { get; set; } = 128; /// <summary>
/// Default value: 2048
/// <summary> /// </summary>
/// Default value: 2048 public static int MaxValueLength { get; set; } = 2048;
/// </summary>
public static int MaxValueLength { get; set; } = 2048; public static int MaxValueLengthValue { get; set; } = MaxValueLength;
public static int MaxValueLengthValue { get; set; } = MaxValueLength; /// <summary>
/// Default value: 64
/// <summary> /// </summary>
/// Default value: 64 public static int MaxProviderNameLength { get; set; } = 64;
/// </summary>
public static int MaxProviderNameLength { get; set; } = 64; /// <summary>
/// Default value: 64
/// <summary> /// </summary>
/// Default value: 64 public static int MaxProviderKeyLength { get; set; } = 64;
/// </summary>
public static int MaxProviderKeyLength { get; set; } = 64;
}
} }

47
modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/SettingManagementFeatureDefinitionProvider.cs

@ -3,34 +3,33 @@ using Volo.Abp.Localization;
using Volo.Abp.SettingManagement.Localization; using Volo.Abp.SettingManagement.Localization;
using Volo.Abp.Validation.StringValues; using Volo.Abp.Validation.StringValues;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
public class SettingManagementFeatureDefinitionProvider : FeatureDefinitionProvider
{ {
public class SettingManagementFeatureDefinitionProvider : FeatureDefinitionProvider public override void Define(IFeatureDefinitionContext context)
{ {
public override void Define(IFeatureDefinitionContext context) var group = context.AddGroup(SettingManagementFeatures.GroupName,
{ L("Feature:SettingManagementGroup"));
var group = context.AddGroup(SettingManagementFeatures.GroupName,
L("Feature:SettingManagementGroup"));
var settingEnableFeature = group.AddFeature( var settingEnableFeature = group.AddFeature(
SettingManagementFeatures.Enable, SettingManagementFeatures.Enable,
"true", "true",
L("Feature:SettingManagementEnable"), L("Feature:SettingManagementEnable"),
L("Feature:SettingManagementEnableDescription"), L("Feature:SettingManagementEnableDescription"),
new ToggleStringValueType()); new ToggleStringValueType());
settingEnableFeature.CreateChild( settingEnableFeature.CreateChild(
SettingManagementFeatures.AllowTenantsToChangeEmailSettings, SettingManagementFeatures.AllowTenantsToChangeEmailSettings,
"false", "false",
L("Feature:AllowTenantsToChangeEmailSettings"), L("Feature:AllowTenantsToChangeEmailSettings"),
L("AllowTenantsToChangeEmailSettingsDescription"), L("AllowTenantsToChangeEmailSettingsDescription"),
new ToggleStringValueType(), new ToggleStringValueType(),
isAvailableToHost: false); isAvailableToHost: false);
} }
private static LocalizableString L(string name) private static LocalizableString L(string name)
{ {
return LocalizableString.Create<AbpSettingManagementResource>(name); return LocalizableString.Create<AbpSettingManagementResource>(name);
}
} }
} }

13
modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/SettingManagementFeatures.cs

@ -1,11 +1,10 @@
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
public class SettingManagementFeatures
{ {
public class SettingManagementFeatures public const string GroupName = "SettingManagement";
{
public const string GroupName = "SettingManagement";
public const string Enable = GroupName + ".Enable"; public const string Enable = GroupName + ".Enable";
public const string AllowTenantsToChangeEmailSettings = GroupName + ".AllowTenantsToChangeEmailSettings"; public const string AllowTenantsToChangeEmailSettings = GroupName + ".AllowTenantsToChangeEmailSettings";
}
} }

13
modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/AbpSettingManagementDbProperties.cs

@ -1,13 +1,12 @@
using Volo.Abp.Data; using Volo.Abp.Data;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
public static class AbpSettingManagementDbProperties
{ {
public static class AbpSettingManagementDbProperties public static string DbTablePrefix { get; set; } = AbpCommonDbProperties.DbTablePrefix;
{
public static string DbTablePrefix { get; set; } = AbpCommonDbProperties.DbTablePrefix;
public static string DbSchema { get; set; } = AbpCommonDbProperties.DbSchema; public static string DbSchema { get; set; } = AbpCommonDbProperties.DbSchema;
public const string ConnectionStringName = "AbpSettingManagement"; public const string ConnectionStringName = "AbpSettingManagement";
}
} }

35
modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/AbpSettingManagementDomainModule.cs

@ -3,26 +3,25 @@ using Volo.Abp.Domain;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
using Volo.Abp.Settings; using Volo.Abp.Settings;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
[DependsOn(
typeof(AbpSettingsModule),
typeof(AbpDddDomainModule),
typeof(AbpSettingManagementDomainSharedModule),
typeof(AbpCachingModule)
)]
public class AbpSettingManagementDomainModule : AbpModule
{ {
[DependsOn( public override void ConfigureServices(ServiceConfigurationContext context)
typeof(AbpSettingsModule),
typeof(AbpDddDomainModule),
typeof(AbpSettingManagementDomainSharedModule),
typeof(AbpCachingModule)
)]
public class AbpSettingManagementDomainModule : AbpModule
{ {
public override void ConfigureServices(ServiceConfigurationContext context) Configure<SettingManagementOptions>(options =>
{ {
Configure<SettingManagementOptions>(options => options.Providers.Add<DefaultValueSettingManagementProvider>();
{ options.Providers.Add<ConfigurationSettingManagementProvider>();
options.Providers.Add<DefaultValueSettingManagementProvider>(); options.Providers.Add<GlobalSettingManagementProvider>();
options.Providers.Add<ConfigurationSettingManagementProvider>(); options.Providers.Add<TenantSettingManagementProvider>();
options.Providers.Add<GlobalSettingManagementProvider>(); options.Providers.Add<UserSettingManagementProvider>();
options.Providers.Add<TenantSettingManagementProvider>(); });
options.Providers.Add<UserSettingManagementProvider>();
});
}
} }
} }

43
modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/ConfigurationSettingManagementProvider.cs

@ -3,32 +3,31 @@ using Microsoft.Extensions.Configuration;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
using Volo.Abp.Settings; using Volo.Abp.Settings;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
public class ConfigurationSettingManagementProvider : ISettingManagementProvider, ITransientDependency
{ {
public class ConfigurationSettingManagementProvider : ISettingManagementProvider, ITransientDependency public string Name => ConfigurationSettingValueProvider.ProviderName;
{
public string Name => ConfigurationSettingValueProvider.ProviderName;
protected IConfiguration Configuration { get; } protected IConfiguration Configuration { get; }
public ConfigurationSettingManagementProvider(IConfiguration configuration) public ConfigurationSettingManagementProvider(IConfiguration configuration)
{ {
Configuration = configuration; Configuration = configuration;
} }
public virtual Task<string> GetOrNullAsync(SettingDefinition setting, string providerKey) public virtual Task<string> GetOrNullAsync(SettingDefinition setting, string providerKey)
{ {
return Task.FromResult(Configuration[ConfigurationSettingValueProvider.ConfigurationNamePrefix + setting.Name]); return Task.FromResult(Configuration[ConfigurationSettingValueProvider.ConfigurationNamePrefix + setting.Name]);
} }
public virtual Task SetAsync(SettingDefinition setting, string value, string providerKey) public virtual Task SetAsync(SettingDefinition setting, string value, string providerKey)
{ {
throw new AbpException($"Can not set a setting value to the application configuration."); throw new AbpException($"Can not set a setting value to the application configuration.");
} }
public virtual Task ClearAsync(SettingDefinition setting, string providerKey) public virtual Task ClearAsync(SettingDefinition setting, string providerKey)
{ {
throw new AbpException($"Can not set a setting value to the application configuration."); throw new AbpException($"Can not set a setting value to the application configuration.");
}
} }
} }

21
modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/ConfigurationValueSettingManagerExtensions.cs

@ -3,18 +3,17 @@ using System.Threading.Tasks;
using JetBrains.Annotations; using JetBrains.Annotations;
using Volo.Abp.Settings; using Volo.Abp.Settings;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
public static class ConfigurationValueSettingManagerExtensions
{ {
public static class ConfigurationValueSettingManagerExtensions public static Task<string> GetOrNullConfigurationAsync(this ISettingManager settingManager, [NotNull] string name, bool fallback = true)
{ {
public static Task<string> GetOrNullConfigurationAsync(this ISettingManager settingManager, [NotNull] string name, bool fallback = true) return settingManager.GetOrNullAsync(name, ConfigurationSettingValueProvider.ProviderName, null, fallback);
{ }
return settingManager.GetOrNullAsync(name, ConfigurationSettingValueProvider.ProviderName, null, fallback);
}
public static Task<List<SettingValue>> GetAllConfigurationAsync(this ISettingManager settingManager, bool fallback = true) public static Task<List<SettingValue>> GetAllConfigurationAsync(this ISettingManager settingManager, bool fallback = true)
{ {
return settingManager.GetAllAsync(ConfigurationSettingValueProvider.ProviderName, null, fallback); return settingManager.GetAllAsync(ConfigurationSettingValueProvider.ProviderName, null, fallback);
}
} }
} }

33
modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/DefaultValueSettingManagementProvider.cs

@ -2,25 +2,24 @@
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
using Volo.Abp.Settings; using Volo.Abp.Settings;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
public class DefaultValueSettingManagementProvider : ISettingManagementProvider, ISingletonDependency
{ {
public class DefaultValueSettingManagementProvider : ISettingManagementProvider, ISingletonDependency public string Name => DefaultValueSettingValueProvider.ProviderName;
{
public string Name => DefaultValueSettingValueProvider.ProviderName;
public virtual Task<string> GetOrNullAsync(SettingDefinition setting, string providerKey) public virtual Task<string> GetOrNullAsync(SettingDefinition setting, string providerKey)
{ {
return Task.FromResult(setting.DefaultValue); return Task.FromResult(setting.DefaultValue);
} }
public virtual Task SetAsync(SettingDefinition setting, string value, string providerKey) public virtual Task SetAsync(SettingDefinition setting, string value, string providerKey)
{ {
throw new AbpException($"Can not set default value of a setting. It is only possible while defining the setting in a {typeof(ISettingDefinitionProvider)} implementation."); throw new AbpException($"Can not set default value of a setting. It is only possible while defining the setting in a {typeof(ISettingDefinitionProvider)} implementation.");
} }
public virtual Task ClearAsync(SettingDefinition setting, string providerKey) public virtual Task ClearAsync(SettingDefinition setting, string providerKey)
{ {
throw new AbpException($"Can not clear default value of a setting. It is only possible while defining the setting in a {typeof(ISettingDefinitionProvider)} implementation."); throw new AbpException($"Can not clear default value of a setting. It is only possible while defining the setting in a {typeof(ISettingDefinitionProvider)} implementation.");
}
} }
} }

21
modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/DefaultValueSettingManagerExtensions.cs

@ -3,18 +3,17 @@ using System.Threading.Tasks;
using JetBrains.Annotations; using JetBrains.Annotations;
using Volo.Abp.Settings; using Volo.Abp.Settings;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
public static class DefaultValueSettingManagerExtensions
{ {
public static class DefaultValueSettingManagerExtensions public static Task<string> GetOrNullDefaultAsync(this ISettingManager settingManager, [NotNull] string name, bool fallback = true)
{ {
public static Task<string> GetOrNullDefaultAsync(this ISettingManager settingManager, [NotNull] string name, bool fallback = true) return settingManager.GetOrNullAsync(name, DefaultValueSettingValueProvider.ProviderName, null, fallback);
{ }
return settingManager.GetOrNullAsync(name, DefaultValueSettingValueProvider.ProviderName, null, fallback);
}
public static Task<List<SettingValue>> GetAllDefaultAsync(this ISettingManager settingManager, bool fallback = true) public static Task<List<SettingValue>> GetAllDefaultAsync(this ISettingManager settingManager, bool fallback = true)
{ {
return settingManager.GetAllAsync(DefaultValueSettingValueProvider.ProviderName, null, fallback); return settingManager.GetAllAsync(DefaultValueSettingValueProvider.ProviderName, null, fallback);
}
} }
} }

25
modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/GlobalSettingManagementProvider.cs

@ -1,21 +1,20 @@
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
using Volo.Abp.Settings; using Volo.Abp.Settings;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
public class GlobalSettingManagementProvider : SettingManagementProvider, ITransientDependency
{ {
public class GlobalSettingManagementProvider : SettingManagementProvider, ITransientDependency public override string Name => GlobalSettingValueProvider.ProviderName;
{
public override string Name => GlobalSettingValueProvider.ProviderName;
public GlobalSettingManagementProvider(ISettingManagementStore settingManagementStore) public GlobalSettingManagementProvider(ISettingManagementStore settingManagementStore)
: base(settingManagementStore) : base(settingManagementStore)
{ {
} }
protected override string NormalizeProviderKey(string providerKey) protected override string NormalizeProviderKey(string providerKey)
{ {
return null; return null;
}
} }
} }

27
modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/GlobalSettingManagerExtensions.cs

@ -3,23 +3,22 @@ using System.Threading.Tasks;
using JetBrains.Annotations; using JetBrains.Annotations;
using Volo.Abp.Settings; using Volo.Abp.Settings;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
public static class GlobalSettingManagerExtensions
{ {
public static class GlobalSettingManagerExtensions public static Task<string> GetOrNullGlobalAsync(this ISettingManager settingManager, [NotNull] string name, bool fallback = true)
{ {
public static Task<string> GetOrNullGlobalAsync(this ISettingManager settingManager, [NotNull] string name, bool fallback = true) return settingManager.GetOrNullAsync(name, GlobalSettingValueProvider.ProviderName, null, fallback);
{ }
return settingManager.GetOrNullAsync(name, GlobalSettingValueProvider.ProviderName, null, fallback);
}
public static Task<List<SettingValue>> GetAllGlobalAsync(this ISettingManager settingManager, bool fallback = true) public static Task<List<SettingValue>> GetAllGlobalAsync(this ISettingManager settingManager, bool fallback = true)
{ {
return settingManager.GetAllAsync(GlobalSettingValueProvider.ProviderName, null, fallback); return settingManager.GetAllAsync(GlobalSettingValueProvider.ProviderName, null, fallback);
} }
public static Task SetGlobalAsync(this ISettingManager settingManager, [NotNull] string name, [CanBeNull] string value) public static Task SetGlobalAsync(this ISettingManager settingManager, [NotNull] string name, [CanBeNull] string value)
{ {
return settingManager.SetAsync(name, value, GlobalSettingValueProvider.ProviderName, null); return settingManager.SetAsync(name, value, GlobalSettingValueProvider.ProviderName, null);
}
} }
} }

15
modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/ISettingManagementProvider.cs

@ -2,16 +2,15 @@
using JetBrains.Annotations; using JetBrains.Annotations;
using Volo.Abp.Settings; using Volo.Abp.Settings;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
public interface ISettingManagementProvider
{ {
public interface ISettingManagementProvider string Name { get; }
{
string Name { get; }
Task<string> GetOrNullAsync([NotNull] SettingDefinition setting, [CanBeNull] string providerKey); Task<string> GetOrNullAsync([NotNull] SettingDefinition setting, [CanBeNull] string providerKey);
Task SetAsync([NotNull] SettingDefinition setting, [NotNull] string value, [CanBeNull] string providerKey); Task SetAsync([NotNull] SettingDefinition setting, [NotNull] string value, [CanBeNull] string providerKey);
Task ClearAsync([NotNull] SettingDefinition setting, [CanBeNull] string providerKey); Task ClearAsync([NotNull] SettingDefinition setting, [CanBeNull] string providerKey);
}
} }

17
modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/ISettingManagementStore.cs

@ -2,18 +2,17 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Settings; using Volo.Abp.Settings;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
public interface ISettingManagementStore
{ {
public interface ISettingManagementStore Task<string> GetOrNullAsync(string name, string providerName, string providerKey);
{
Task<string> GetOrNullAsync(string name, string providerName, string providerKey);
Task<List<SettingValue>> GetListAsync(string providerName, string providerKey); Task<List<SettingValue>> GetListAsync(string providerName, string providerKey);
Task<List<SettingValue>> GetListAsync(string[] names, string providerName, string providerKey); Task<List<SettingValue>> GetListAsync(string[] names, string providerName, string providerKey);
Task SetAsync(string name, string value, string providerName, string providerKey); Task SetAsync(string name, string value, string providerName, string providerKey);
Task DeleteAsync(string name, string providerName, string providerKey); Task DeleteAsync(string name, string providerName, string providerKey);
}
} }

15
modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/ISettingManager.cs

@ -3,14 +3,13 @@ using System.Threading.Tasks;
using JetBrains.Annotations; using JetBrains.Annotations;
using Volo.Abp.Settings; using Volo.Abp.Settings;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
public interface ISettingManager
{ {
public interface ISettingManager Task<string> GetOrNullAsync([NotNull] string name, [NotNull] string providerName, [CanBeNull] string providerKey, bool fallback = true);
{
Task<string> GetOrNullAsync([NotNull]string name, [NotNull] string providerName, [CanBeNull] string providerKey, bool fallback = true);
Task<List<SettingValue>> GetAllAsync([NotNull] string providerName, [CanBeNull] string providerKey, bool fallback = true); Task<List<SettingValue>> GetAllAsync([NotNull] string providerName, [CanBeNull] string providerKey, bool fallback = true);
Task SetAsync([NotNull] string name, [CanBeNull] string value, [NotNull] string providerName, [CanBeNull] string providerKey, bool forceToSet = false); Task SetAsync([NotNull] string name, [CanBeNull] string value, [NotNull] string providerName, [CanBeNull] string providerKey, bool forceToSet = false);
} }
}

35
modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/ISettingRepository.cs

@ -4,25 +4,24 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories; using Volo.Abp.Domain.Repositories;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
public interface ISettingRepository : IBasicRepository<Setting, Guid>
{ {
public interface ISettingRepository : IBasicRepository<Setting, Guid> Task<Setting> FindAsync(
{ string name,
Task<Setting> FindAsync( string providerName,
string name, string providerKey,
string providerName, CancellationToken cancellationToken = default);
string providerKey,
CancellationToken cancellationToken = default);
Task<List<Setting>> GetListAsync( Task<List<Setting>> GetListAsync(
string providerName, string providerName,
string providerKey, string providerKey,
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);
Task<List<Setting>> GetListAsync( Task<List<Setting>> GetListAsync(
string[] names, string[] names,
string providerName, string providerName,
string providerKey, string providerKey,
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);
}
} }

81
modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/Setting.cs

@ -2,47 +2,46 @@
using JetBrains.Annotations; using JetBrains.Annotations;
using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Entities;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
public class Setting : Entity<Guid>, IAggregateRoot<Guid>
{ {
public class Setting : Entity<Guid>, IAggregateRoot<Guid> [NotNull]
public virtual string Name { get; protected set; }
[NotNull]
public virtual string Value { get; internal set; }
[CanBeNull]
public virtual string ProviderName { get; protected set; }
[CanBeNull]
public virtual string ProviderKey { get; protected set; }
protected Setting()
{
}
public Setting(
Guid id,
[NotNull] string name,
[NotNull] string value,
[CanBeNull] string providerName = null,
[CanBeNull] string providerKey = null)
{
Check.NotNull(name, nameof(name));
Check.NotNull(value, nameof(value));
Id = id;
Name = name;
Value = value;
ProviderName = providerName;
ProviderKey = providerKey;
}
public override string ToString()
{ {
[NotNull] return $"{base.ToString()}, Name = {Name}, Value = {Value}, ProviderName = {ProviderName}, ProviderKey = {ProviderKey}";
public virtual string Name { get; protected set; }
[NotNull]
public virtual string Value { get; internal set; }
[CanBeNull]
public virtual string ProviderName { get; protected set; }
[CanBeNull]
public virtual string ProviderKey { get; protected set; }
protected Setting()
{
}
public Setting(
Guid id,
[NotNull] string name,
[NotNull] string value,
[CanBeNull] string providerName = null,
[CanBeNull] string providerKey = null)
{
Check.NotNull(name, nameof(name));
Check.NotNull(value, nameof(value));
Id = id;
Name = name;
Value = value;
ProviderName = providerName;
ProviderKey = providerKey;
}
public override string ToString()
{
return $"{base.ToString()}, Name = {Name}, Value = {Value}, ProviderName = {ProviderName}, ProviderKey = {ProviderKey}";
}
} }
} }

45
modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/SettingCacheItem.cs

@ -3,35 +3,34 @@ using System.Linq;
using Volo.Abp.MultiTenancy; using Volo.Abp.MultiTenancy;
using Volo.Abp.Text.Formatting; using Volo.Abp.Text.Formatting;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
[Serializable]
[IgnoreMultiTenancy]
public class SettingCacheItem
{ {
[Serializable] private const string CacheKeyFormat = "pn:{0},pk:{1},n:{2}";
[IgnoreMultiTenancy]
public class SettingCacheItem
{
private const string CacheKeyFormat = "pn:{0},pk:{1},n:{2}";
public string Value { get; set; } public string Value { get; set; }
public SettingCacheItem() public SettingCacheItem()
{ {
} }
public SettingCacheItem(string value) public SettingCacheItem(string value)
{ {
Value = value; Value = value;
} }
public static string CalculateCacheKey(string name, string providerName, string providerKey) public static string CalculateCacheKey(string name, string providerName, string providerKey)
{ {
return string.Format(CacheKeyFormat, providerName, providerKey, name); return string.Format(CacheKeyFormat, providerName, providerKey, name);
} }
public static string GetSettingNameFormCacheKeyOrNull(string cacheKey) public static string GetSettingNameFormCacheKeyOrNull(string cacheKey)
{ {
var result = FormattedStringValueExtracter.Extract(cacheKey, CacheKeyFormat, true); var result = FormattedStringValueExtracter.Extract(cacheKey, CacheKeyFormat, true);
return result.IsMatch ? result.Matches.Last().Value : null; return result.IsMatch ? result.Matches.Last().Value : null;
}
} }
} }

41
modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/SettingCacheItemInvalidator.cs

@ -4,31 +4,30 @@ using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Entities.Events; using Volo.Abp.Domain.Entities.Events;
using Volo.Abp.EventBus; using Volo.Abp.EventBus;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
public class SettingCacheItemInvalidator : ILocalEventHandler<EntityChangedEventData<Setting>>, ITransientDependency
{ {
public class SettingCacheItemInvalidator : ILocalEventHandler<EntityChangedEventData<Setting>>, ITransientDependency protected IDistributedCache<SettingCacheItem> Cache { get; }
{
protected IDistributedCache<SettingCacheItem> Cache { get; }
public SettingCacheItemInvalidator(IDistributedCache<SettingCacheItem> cache) public SettingCacheItemInvalidator(IDistributedCache<SettingCacheItem> cache)
{ {
Cache = cache; Cache = cache;
} }
public virtual async Task HandleEventAsync(EntityChangedEventData<Setting> eventData) public virtual async Task HandleEventAsync(EntityChangedEventData<Setting> eventData)
{ {
var cacheKey = CalculateCacheKey( var cacheKey = CalculateCacheKey(
eventData.Entity.Name, eventData.Entity.Name,
eventData.Entity.ProviderName, eventData.Entity.ProviderName,
eventData.Entity.ProviderKey eventData.Entity.ProviderKey
); );
await Cache.RemoveAsync(cacheKey, considerUow: true); await Cache.RemoveAsync(cacheKey, considerUow: true);
} }
protected virtual string CalculateCacheKey(string name, string providerName, string providerKey) protected virtual string CalculateCacheKey(string name, string providerName, string providerKey)
{ {
return SettingCacheItem.CalculateCacheKey(name, providerName, providerKey); return SettingCacheItem.CalculateCacheKey(name, providerName, providerKey);
}
} }
} }

15
modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/SettingManagementOptions.cs

@ -1,14 +1,13 @@
using Volo.Abp.Collections; using Volo.Abp.Collections;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
public class SettingManagementOptions
{ {
public class SettingManagementOptions public ITypeList<ISettingManagementProvider> Providers { get; }
{
public ITypeList<ISettingManagementProvider> Providers { get; }
public SettingManagementOptions() public SettingManagementOptions()
{ {
Providers = new TypeList<ISettingManagementProvider>(); Providers = new TypeList<ISettingManagementProvider>();
}
} }
} }

63
modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/SettingManagementProvider.cs

@ -1,38 +1,37 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Settings; using Volo.Abp.Settings;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
public abstract class SettingManagementProvider : ISettingManagementProvider
{ {
public abstract class SettingManagementProvider : ISettingManagementProvider public abstract string Name { get; }
//TODO: Rename to Store
protected ISettingManagementStore SettingManagementStore { get; }
protected SettingManagementProvider(ISettingManagementStore settingManagementStore)
{
SettingManagementStore = settingManagementStore;
}
public virtual async Task<string> GetOrNullAsync(SettingDefinition setting, string providerKey)
{
return await SettingManagementStore.GetOrNullAsync(setting.Name, Name, NormalizeProviderKey(providerKey));
}
public virtual async Task SetAsync(SettingDefinition setting, string value, string providerKey)
{
await SettingManagementStore.SetAsync(setting.Name, value, Name, NormalizeProviderKey(providerKey));
}
public virtual async Task ClearAsync(SettingDefinition setting, string providerKey)
{
await SettingManagementStore.DeleteAsync(setting.Name, Name, NormalizeProviderKey(providerKey));
}
protected virtual string NormalizeProviderKey(string providerKey)
{ {
public abstract string Name { get; } return providerKey;
//TODO: Rename to Store
protected ISettingManagementStore SettingManagementStore { get; }
protected SettingManagementProvider(ISettingManagementStore settingManagementStore)
{
SettingManagementStore = settingManagementStore;
}
public virtual async Task<string> GetOrNullAsync(SettingDefinition setting, string providerKey)
{
return await SettingManagementStore.GetOrNullAsync(setting.Name, Name, NormalizeProviderKey(providerKey));
}
public virtual async Task SetAsync(SettingDefinition setting, string value, string providerKey)
{
await SettingManagementStore.SetAsync(setting.Name, value, Name, NormalizeProviderKey(providerKey));
}
public virtual async Task ClearAsync(SettingDefinition setting, string providerKey)
{
await SettingManagementStore.DeleteAsync(setting.Name, Name, NormalizeProviderKey(providerKey));
}
protected virtual string NormalizeProviderKey(string providerKey)
{
return providerKey;
}
} }
} }

301
modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/SettingManagementStore.cs

@ -7,208 +7,207 @@ using Volo.Abp.Guids;
using Volo.Abp.Settings; using Volo.Abp.Settings;
using Volo.Abp.Uow; using Volo.Abp.Uow;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
public class SettingManagementStore : ISettingManagementStore, ITransientDependency
{ {
public class SettingManagementStore : ISettingManagementStore, ITransientDependency protected IDistributedCache<SettingCacheItem> Cache { get; }
protected ISettingDefinitionManager SettingDefinitionManager { get; }
protected ISettingRepository SettingRepository { get; }
protected IGuidGenerator GuidGenerator { get; }
public SettingManagementStore(
ISettingRepository settingRepository,
IGuidGenerator guidGenerator,
IDistributedCache<SettingCacheItem> cache,
ISettingDefinitionManager settingDefinitionManager)
{ {
protected IDistributedCache<SettingCacheItem> Cache { get; } SettingRepository = settingRepository;
protected ISettingDefinitionManager SettingDefinitionManager { get; } GuidGenerator = guidGenerator;
protected ISettingRepository SettingRepository { get; } Cache = cache;
protected IGuidGenerator GuidGenerator { get; } SettingDefinitionManager = settingDefinitionManager;
}
public SettingManagementStore(
ISettingRepository settingRepository, [UnitOfWork]
IGuidGenerator guidGenerator, public virtual async Task<string> GetOrNullAsync(string name, string providerName, string providerKey)
IDistributedCache<SettingCacheItem> cache, {
ISettingDefinitionManager settingDefinitionManager) return (await GetCacheItemAsync(name, providerName, providerKey)).Value;
}
[UnitOfWork]
public virtual async Task SetAsync(string name, string value, string providerName, string providerKey)
{
var setting = await SettingRepository.FindAsync(name, providerName, providerKey);
if (setting == null)
{ {
SettingRepository = settingRepository; setting = new Setting(GuidGenerator.Create(), name, value, providerName, providerKey);
GuidGenerator = guidGenerator; await SettingRepository.InsertAsync(setting);
Cache = cache;
SettingDefinitionManager = settingDefinitionManager;
} }
else
[UnitOfWork]
public virtual async Task<string> GetOrNullAsync(string name, string providerName, string providerKey)
{ {
return (await GetCacheItemAsync(name, providerName, providerKey)).Value; setting.Value = value;
await SettingRepository.UpdateAsync(setting);
} }
[UnitOfWork] await Cache.SetAsync(CalculateCacheKey(name, providerName, providerKey), new SettingCacheItem(setting?.Value), considerUow: true);
public virtual async Task SetAsync(string name, string value, string providerName, string providerKey) }
{
var setting = await SettingRepository.FindAsync(name, providerName, providerKey);
if (setting == null)
{
setting = new Setting(GuidGenerator.Create(), name, value, providerName, providerKey);
await SettingRepository.InsertAsync(setting);
}
else
{
setting.Value = value;
await SettingRepository.UpdateAsync(setting);
}
await Cache.SetAsync(CalculateCacheKey(name, providerName, providerKey), new SettingCacheItem(setting?.Value), considerUow: true); public virtual async Task<List<SettingValue>> GetListAsync(string providerName, string providerKey)
} {
var settings = await SettingRepository.GetListAsync(providerName, providerKey);
return settings.Select(s => new SettingValue(s.Name, s.Value)).ToList();
}
public virtual async Task<List<SettingValue>> GetListAsync(string providerName, string providerKey) [UnitOfWork]
public virtual async Task DeleteAsync(string name, string providerName, string providerKey)
{
var setting = await SettingRepository.FindAsync(name, providerName, providerKey);
if (setting != null)
{ {
var settings = await SettingRepository.GetListAsync(providerName, providerKey); await SettingRepository.DeleteAsync(setting);
return settings.Select(s => new SettingValue(s.Name, s.Value)).ToList(); await Cache.RemoveAsync(CalculateCacheKey(name, providerName, providerKey), considerUow: true);
} }
}
protected virtual async Task<SettingCacheItem> GetCacheItemAsync(string name, string providerName, string providerKey)
{
var cacheKey = CalculateCacheKey(name, providerName, providerKey);
var cacheItem = await Cache.GetAsync(cacheKey, considerUow: true);
[UnitOfWork] if (cacheItem != null)
public virtual async Task DeleteAsync(string name, string providerName, string providerKey)
{ {
var setting = await SettingRepository.FindAsync(name, providerName, providerKey); return cacheItem;
if (setting != null)
{
await SettingRepository.DeleteAsync(setting);
await Cache.RemoveAsync(CalculateCacheKey(name, providerName, providerKey), considerUow: true);
}
} }
protected virtual async Task<SettingCacheItem> GetCacheItemAsync(string name, string providerName, string providerKey) cacheItem = new SettingCacheItem(null);
{
var cacheKey = CalculateCacheKey(name, providerName, providerKey);
var cacheItem = await Cache.GetAsync(cacheKey, considerUow: true);
if (cacheItem != null) await SetCacheItemsAsync(providerName, providerKey, name, cacheItem);
{
return cacheItem;
}
cacheItem = new SettingCacheItem(null); return cacheItem;
}
await SetCacheItemsAsync(providerName, providerKey, name, cacheItem); private async Task SetCacheItemsAsync(
string providerName,
string providerKey,
string currentName,
SettingCacheItem currentCacheItem)
{
var settingDefinitions = SettingDefinitionManager.GetAll();
var settingsDictionary = (await SettingRepository.GetListAsync(providerName, providerKey))
.ToDictionary(s => s.Name, s => s.Value);
return cacheItem; var cacheItems = new List<KeyValuePair<string, SettingCacheItem>>();
}
private async Task SetCacheItemsAsync( foreach (var settingDefinition in settingDefinitions)
string providerName,
string providerKey,
string currentName,
SettingCacheItem currentCacheItem)
{ {
var settingDefinitions = SettingDefinitionManager.GetAll(); var settingValue = settingsDictionary.GetOrDefault(settingDefinition.Name);
var settingsDictionary = (await SettingRepository.GetListAsync(providerName, providerKey))
.ToDictionary(s => s.Name, s => s.Value);
var cacheItems = new List<KeyValuePair<string, SettingCacheItem>>(); cacheItems.Add(
new KeyValuePair<string, SettingCacheItem>(
CalculateCacheKey(settingDefinition.Name, providerName, providerKey),
new SettingCacheItem(settingValue)
)
);
foreach (var settingDefinition in settingDefinitions) if (settingDefinition.Name == currentName)
{ {
var settingValue = settingsDictionary.GetOrDefault(settingDefinition.Name); currentCacheItem.Value = settingValue;
cacheItems.Add(
new KeyValuePair<string, SettingCacheItem>(
CalculateCacheKey(settingDefinition.Name, providerName, providerKey),
new SettingCacheItem(settingValue)
)
);
if (settingDefinition.Name == currentName)
{
currentCacheItem.Value = settingValue;
}
} }
await Cache.SetManyAsync(cacheItems, considerUow: true);
} }
[UnitOfWork] await Cache.SetManyAsync(cacheItems, considerUow: true);
public async Task<List<SettingValue>> GetListAsync(string[] names, string providerName, string providerKey) }
{
Check.NotNullOrEmpty(names, nameof(names));
var result = new List<SettingValue>();
if (names.Length == 1) [UnitOfWork]
{ public async Task<List<SettingValue>> GetListAsync(string[] names, string providerName, string providerKey)
var name = names.First(); {
result.Add(new SettingValue(name, (await GetCacheItemAsync(name, providerName, providerKey)).Value)); Check.NotNullOrEmpty(names, nameof(names));
return result;
}
var cacheItems = await GetCacheItemsAsync(names, providerName, providerKey); var result = new List<SettingValue>();
foreach (var item in cacheItems)
{
result.Add(new SettingValue(GetSettingNameFormCacheKeyOrNull(item.Key), item.Value?.Value));
}
if (names.Length == 1)
{
var name = names.First();
result.Add(new SettingValue(name, (await GetCacheItemAsync(name, providerName, providerKey)).Value));
return result; return result;
} }
protected virtual async Task<List<KeyValuePair<string, SettingCacheItem>>> GetCacheItemsAsync(string[] names, string providerName, string providerKey) var cacheItems = await GetCacheItemsAsync(names, providerName, providerKey);
foreach (var item in cacheItems)
{ {
var cacheKeys = names.Select(x => CalculateCacheKey(x, providerName, providerKey)).ToList(); result.Add(new SettingValue(GetSettingNameFormCacheKeyOrNull(item.Key), item.Value?.Value));
}
var cacheItems = (await Cache.GetManyAsync(cacheKeys, considerUow: true)).ToList(); return result;
}
if (cacheItems.All(x => x.Value != null)) protected virtual async Task<List<KeyValuePair<string, SettingCacheItem>>> GetCacheItemsAsync(string[] names, string providerName, string providerKey)
{ {
return cacheItems; var cacheKeys = names.Select(x => CalculateCacheKey(x, providerName, providerKey)).ToList();
}
var notCacheKeys = cacheItems.Where(x => x.Value == null).Select(x => x.Key).ToList(); var cacheItems = (await Cache.GetManyAsync(cacheKeys, considerUow: true)).ToList();
var newCacheItems = await SetCacheItemsAsync(providerName, providerKey, notCacheKeys); if (cacheItems.All(x => x.Value != null))
{
return cacheItems;
}
var result = new List<KeyValuePair<string, SettingCacheItem>>(); var notCacheKeys = cacheItems.Where(x => x.Value == null).Select(x => x.Key).ToList();
foreach (var key in cacheKeys)
{
var item = newCacheItems.FirstOrDefault(x => x.Key == key);
if (item.Value == null)
{
item = cacheItems.FirstOrDefault(x => x.Key == key);
}
result.Add(new KeyValuePair<string, SettingCacheItem>(key, item.Value)); var newCacheItems = await SetCacheItemsAsync(providerName, providerKey, notCacheKeys);
var result = new List<KeyValuePair<string, SettingCacheItem>>();
foreach (var key in cacheKeys)
{
var item = newCacheItems.FirstOrDefault(x => x.Key == key);
if (item.Value == null)
{
item = cacheItems.FirstOrDefault(x => x.Key == key);
} }
return result; result.Add(new KeyValuePair<string, SettingCacheItem>(key, item.Value));
} }
private async Task<List<KeyValuePair<string, SettingCacheItem>>> SetCacheItemsAsync( return result;
string providerName, }
string providerKey,
List<string> notCacheKeys)
{
var settingDefinitions = SettingDefinitionManager.GetAll().Where(x => notCacheKeys.Any(k => GetSettingNameFormCacheKeyOrNull(k) == x.Name));
var settingsDictionary = (await SettingRepository.GetListAsync(notCacheKeys.Select(GetSettingNameFormCacheKeyOrNull).ToArray(), providerName, providerKey)) private async Task<List<KeyValuePair<string, SettingCacheItem>>> SetCacheItemsAsync(
.ToDictionary(s => s.Name, s => s.Value); string providerName,
string providerKey,
List<string> notCacheKeys)
{
var settingDefinitions = SettingDefinitionManager.GetAll().Where(x => notCacheKeys.Any(k => GetSettingNameFormCacheKeyOrNull(k) == x.Name));
var cacheItems = new List<KeyValuePair<string, SettingCacheItem>>(); var settingsDictionary = (await SettingRepository.GetListAsync(notCacheKeys.Select(GetSettingNameFormCacheKeyOrNull).ToArray(), providerName, providerKey))
.ToDictionary(s => s.Name, s => s.Value);
foreach (var settingDefinition in settingDefinitions) var cacheItems = new List<KeyValuePair<string, SettingCacheItem>>();
{
var settingValue = settingsDictionary.GetOrDefault(settingDefinition.Name);
cacheItems.Add(
new KeyValuePair<string, SettingCacheItem>(
CalculateCacheKey(settingDefinition.Name, providerName, providerKey),
new SettingCacheItem(settingValue)
)
);
}
await Cache.SetManyAsync(cacheItems, considerUow: true); foreach (var settingDefinition in settingDefinitions)
{
return cacheItems; var settingValue = settingsDictionary.GetOrDefault(settingDefinition.Name);
cacheItems.Add(
new KeyValuePair<string, SettingCacheItem>(
CalculateCacheKey(settingDefinition.Name, providerName, providerKey),
new SettingCacheItem(settingValue)
)
);
} }
await Cache.SetManyAsync(cacheItems, considerUow: true);
protected virtual string CalculateCacheKey(string name, string providerName, string providerKey) return cacheItems;
{ }
return SettingCacheItem.CalculateCacheKey(name, providerName, providerKey);
}
protected virtual string GetSettingNameFormCacheKeyOrNull(string key)
{ protected virtual string CalculateCacheKey(string name, string providerName, string providerKey)
//TODO: throw ex when name is null? {
return SettingCacheItem.GetSettingNameFormCacheKeyOrNull(key); return SettingCacheItem.CalculateCacheKey(name, providerName, providerKey);
} }
protected virtual string GetSettingNameFormCacheKeyOrNull(string key)
{
//TODO: throw ex when name is null?
return SettingCacheItem.GetSettingNameFormCacheKeyOrNull(key);
} }
} }

293
modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/SettingManager.cs

@ -7,195 +7,194 @@ using Microsoft.Extensions.Options;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
using Volo.Abp.Settings; using Volo.Abp.Settings;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
public class SettingManager : ISettingManager, ISingletonDependency
{ {
public class SettingManager : ISettingManager, ISingletonDependency protected ISettingDefinitionManager SettingDefinitionManager { get; }
protected ISettingEncryptionService SettingEncryptionService { get; }
protected List<ISettingManagementProvider> Providers => _lazyProviders.Value;
protected SettingManagementOptions Options { get; }
private readonly Lazy<List<ISettingManagementProvider>> _lazyProviders;
public SettingManager(
IOptions<SettingManagementOptions> options,
IServiceProvider serviceProvider,
ISettingDefinitionManager settingDefinitionManager,
ISettingEncryptionService settingEncryptionService)
{ {
protected ISettingDefinitionManager SettingDefinitionManager { get; } SettingDefinitionManager = settingDefinitionManager;
protected ISettingEncryptionService SettingEncryptionService { get; } SettingEncryptionService = settingEncryptionService;
protected List<ISettingManagementProvider> Providers => _lazyProviders.Value; Options = options.Value;
protected SettingManagementOptions Options { get; }
private readonly Lazy<List<ISettingManagementProvider>> _lazyProviders; //TODO: Instead, use IHybridServiceScopeFactory and create a scope..?
public SettingManager( _lazyProviders = new Lazy<List<ISettingManagementProvider>>(
IOptions<SettingManagementOptions> options, () => Options
IServiceProvider serviceProvider, .Providers
ISettingDefinitionManager settingDefinitionManager, .Select(c => serviceProvider.GetRequiredService(c) as ISettingManagementProvider)
ISettingEncryptionService settingEncryptionService) .ToList(),
{ true
SettingDefinitionManager = settingDefinitionManager; );
SettingEncryptionService = settingEncryptionService; }
Options = options.Value;
//TODO: Instead, use IHybridServiceScopeFactory and create a scope..?
_lazyProviders = new Lazy<List<ISettingManagementProvider>>(
() => Options
.Providers
.Select(c => serviceProvider.GetRequiredService(c) as ISettingManagementProvider)
.ToList(),
true
);
}
public virtual Task<string> GetOrNullAsync(string name, string providerName, string providerKey, bool fallback = true)
{
Check.NotNull(name, nameof(name));
Check.NotNull(providerName, nameof(providerName));
return GetOrNullInternalAsync(name, providerName, providerKey, fallback); public virtual Task<string> GetOrNullAsync(string name, string providerName, string providerKey, bool fallback = true)
} {
Check.NotNull(name, nameof(name));
Check.NotNull(providerName, nameof(providerName));
public virtual async Task<List<SettingValue>> GetAllAsync(string providerName, string providerKey, bool fallback = true) return GetOrNullInternalAsync(name, providerName, providerKey, fallback);
{ }
Check.NotNull(providerName, nameof(providerName));
var settingDefinitions = SettingDefinitionManager.GetAll(); public virtual async Task<List<SettingValue>> GetAllAsync(string providerName, string providerKey, bool fallback = true)
var providers = Enumerable.Reverse(Providers) {
.SkipWhile(c => c.Name != providerName); Check.NotNull(providerName, nameof(providerName));
if (!fallback) var settingDefinitions = SettingDefinitionManager.GetAll();
{ var providers = Enumerable.Reverse(Providers)
providers = providers.TakeWhile(c => c.Name == providerName); .SkipWhile(c => c.Name != providerName);
}
var providerList = providers.Reverse().ToList(); if (!fallback)
{
providers = providers.TakeWhile(c => c.Name == providerName);
}
if (!providerList.Any()) var providerList = providers.Reverse().ToList();
{
return new List<SettingValue>();
}
var settingValues = new Dictionary<string, SettingValue>(); if (!providerList.Any())
{
return new List<SettingValue>();
}
foreach (var setting in settingDefinitions) var settingValues = new Dictionary<string, SettingValue>();
{
string value = null;
if (setting.IsInherited) foreach (var setting in settingDefinitions)
{ {
foreach (var provider in providerList) string value = null;
{
var providerValue = await provider.GetOrNullAsync( if (setting.IsInherited)
setting, {
provider.Name == providerName ? providerKey : null foreach (var provider in providerList)
);
if (providerValue != null)
{
value = providerValue;
}
}
}
else
{ {
value = await providerList[0].GetOrNullAsync( var providerValue = await provider.GetOrNullAsync(
setting, setting,
providerKey provider.Name == providerName ? providerKey : null
); );
} if (providerValue != null)
{
if (setting.IsEncrypted) value = providerValue;
{ }
value = SettingEncryptionService.Decrypt(setting, value);
}
if (value != null)
{
settingValues[setting.Name] = new SettingValue(setting.Name, value);
} }
} }
else
return settingValues.Values.ToList();
}
public virtual async Task SetAsync(string name, string value, string providerName, string providerKey, bool forceToSet = false)
{
Check.NotNull(name, nameof(name));
Check.NotNull(providerName, nameof(providerName));
var setting = SettingDefinitionManager.Get(name);
var providers = Enumerable
.Reverse(Providers)
.SkipWhile(p => p.Name != providerName)
.ToList();
if (!providers.Any())
{ {
return; value = await providerList[0].GetOrNullAsync(
setting,
providerKey
);
} }
if (setting.IsEncrypted) if (setting.IsEncrypted)
{ {
value = SettingEncryptionService.Encrypt(setting, value); value = SettingEncryptionService.Decrypt(setting, value);
} }
if (providers.Count > 1 && !forceToSet && setting.IsInherited && value != null) if (value != null)
{ {
var fallbackValue = await GetOrNullInternalAsync(name, providers[1].Name, null); settingValues[setting.Name] = new SettingValue(setting.Name, value);
if (fallbackValue == value)
{
//Clear the value if it's same as it's fallback value
value = null;
}
} }
}
providers = providers return settingValues.Values.ToList();
.TakeWhile(p => p.Name == providerName) }
.ToList(); //Getting list for case of there are more than one provider with same providerName
if (value == null) public virtual async Task SetAsync(string name, string value, string providerName, string providerKey, bool forceToSet = false)
{ {
foreach (var provider in providers) Check.NotNull(name, nameof(name));
{ Check.NotNull(providerName, nameof(providerName));
await provider.ClearAsync(setting, providerKey);
} var setting = SettingDefinitionManager.Get(name);
}
else var providers = Enumerable
{ .Reverse(Providers)
foreach (var provider in providers) .SkipWhile(p => p.Name != providerName)
{ .ToList();
await provider.SetAsync(setting, value, providerKey);
} if (!providers.Any())
} {
return;
} }
protected virtual async Task<string> GetOrNullInternalAsync(string name, string providerName, string providerKey, bool fallback = true) if (setting.IsEncrypted)
{ {
var setting = SettingDefinitionManager.Get(name); value = SettingEncryptionService.Encrypt(setting, value);
var providers = Enumerable }
.Reverse(Providers);
if (providerName != null) if (providers.Count > 1 && !forceToSet && setting.IsInherited && value != null)
{
var fallbackValue = await GetOrNullInternalAsync(name, providers[1].Name, null);
if (fallbackValue == value)
{ {
providers = providers.SkipWhile(c => c.Name != providerName); //Clear the value if it's same as it's fallback value
value = null;
} }
}
if (!fallback || !setting.IsInherited) providers = providers
.TakeWhile(p => p.Name == providerName)
.ToList(); //Getting list for case of there are more than one provider with same providerName
if (value == null)
{
foreach (var provider in providers)
{ {
providers = providers.TakeWhile(c => c.Name == providerName); await provider.ClearAsync(setting, providerKey);
} }
}
string value = null; else
{
foreach (var provider in providers) foreach (var provider in providers)
{ {
value = await provider.GetOrNullAsync( await provider.SetAsync(setting, value, providerKey);
setting,
provider.Name == providerName ? providerKey : null
);
if (value != null)
{
break;
}
} }
}
}
if (setting.IsEncrypted) protected virtual async Task<string> GetOrNullInternalAsync(string name, string providerName, string providerKey, bool fallback = true)
{
var setting = SettingDefinitionManager.Get(name);
var providers = Enumerable
.Reverse(Providers);
if (providerName != null)
{
providers = providers.SkipWhile(c => c.Name != providerName);
}
if (!fallback || !setting.IsInherited)
{
providers = providers.TakeWhile(c => c.Name == providerName);
}
string value = null;
foreach (var provider in providers)
{
value = await provider.GetOrNullAsync(
setting,
provider.Name == providerName ? providerKey : null
);
if (value != null)
{ {
value = SettingEncryptionService.Decrypt(setting, value); break;
} }
}
return value; if (setting.IsEncrypted)
{
value = SettingEncryptionService.Decrypt(setting, value);
} }
return value;
} }
} }

31
modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/SettingStore.cs

@ -3,25 +3,24 @@ using System.Threading.Tasks;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
using Volo.Abp.Settings; using Volo.Abp.Settings;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
public class SettingStore : ISettingStore, ITransientDependency
{ {
public class SettingStore : ISettingStore, ITransientDependency protected ISettingManagementStore ManagementStore { get; }
{
protected ISettingManagementStore ManagementStore { get; }
public SettingStore(ISettingManagementStore managementStore) public SettingStore(ISettingManagementStore managementStore)
{ {
ManagementStore = managementStore; ManagementStore = managementStore;
} }
public virtual Task<string> GetOrNullAsync(string name, string providerName, string providerKey) public virtual Task<string> GetOrNullAsync(string name, string providerName, string providerKey)
{ {
return ManagementStore.GetOrNullAsync(name, providerName, providerKey); return ManagementStore.GetOrNullAsync(name, providerName, providerKey);
} }
public virtual Task<List<SettingValue>> GetAllAsync(string[] names, string providerName, string providerKey) public virtual Task<List<SettingValue>> GetAllAsync(string[] names, string providerName, string providerKey)
{ {
return ManagementStore.GetListAsync(names, providerName, providerKey); return ManagementStore.GetListAsync(names, providerName, providerKey);
}
} }
} }

39
modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/TenantSettingManagementProvider.cs

@ -2,30 +2,29 @@
using Volo.Abp.MultiTenancy; using Volo.Abp.MultiTenancy;
using Volo.Abp.Settings; using Volo.Abp.Settings;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
public class TenantSettingManagementProvider : SettingManagementProvider, ITransientDependency
{ {
public class TenantSettingManagementProvider : SettingManagementProvider, ITransientDependency public override string Name => TenantSettingValueProvider.ProviderName;
{
public override string Name => TenantSettingValueProvider.ProviderName;
protected ICurrentTenant CurrentTenant { get; } protected ICurrentTenant CurrentTenant { get; }
public TenantSettingManagementProvider( public TenantSettingManagementProvider(
ISettingManagementStore settingManagementStore, ISettingManagementStore settingManagementStore,
ICurrentTenant currentTenant) ICurrentTenant currentTenant)
: base(settingManagementStore) : base(settingManagementStore)
{ {
CurrentTenant = currentTenant; CurrentTenant = currentTenant;
} }
protected override string NormalizeProviderKey(string providerKey) protected override string NormalizeProviderKey(string providerKey)
{
if (providerKey != null)
{ {
if (providerKey != null) return providerKey;
{
return providerKey;
}
return CurrentTenant.Id?.ToString();
} }
return CurrentTenant.Id?.ToString();
} }
} }

65
modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/TenantSettingManagerExtensions.cs

@ -4,48 +4,47 @@ using System.Threading.Tasks;
using JetBrains.Annotations; using JetBrains.Annotations;
using Volo.Abp.Settings; using Volo.Abp.Settings;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
public static class TenantSettingManagerExtensions
{ {
public static class TenantSettingManagerExtensions public static Task<string> GetOrNullForTenantAsync(this ISettingManager settingManager, [NotNull] string name, Guid tenantId, bool fallback = true)
{ {
public static Task<string> GetOrNullForTenantAsync(this ISettingManager settingManager, [NotNull] string name, Guid tenantId, bool fallback = true) return settingManager.GetOrNullAsync(name, TenantSettingValueProvider.ProviderName, tenantId.ToString(), fallback);
{ }
return settingManager.GetOrNullAsync(name, TenantSettingValueProvider.ProviderName, tenantId.ToString(), fallback);
}
public static Task<string> GetOrNullForCurrentTenantAsync(this ISettingManager settingManager, [NotNull] string name, bool fallback = true) public static Task<string> GetOrNullForCurrentTenantAsync(this ISettingManager settingManager, [NotNull] string name, bool fallback = true)
{ {
return settingManager.GetOrNullAsync(name, TenantSettingValueProvider.ProviderName, null, fallback); return settingManager.GetOrNullAsync(name, TenantSettingValueProvider.ProviderName, null, fallback);
} }
public static Task<List<SettingValue>> GetAllForTenantAsync(this ISettingManager settingManager, Guid tenantId, bool fallback = true) public static Task<List<SettingValue>> GetAllForTenantAsync(this ISettingManager settingManager, Guid tenantId, bool fallback = true)
{ {
return settingManager.GetAllAsync(TenantSettingValueProvider.ProviderName, tenantId.ToString(), fallback); return settingManager.GetAllAsync(TenantSettingValueProvider.ProviderName, tenantId.ToString(), fallback);
} }
public static Task<List<SettingValue>> GetAllForCurrentTenantAsync(this ISettingManager settingManager, bool fallback = true) public static Task<List<SettingValue>> GetAllForCurrentTenantAsync(this ISettingManager settingManager, bool fallback = true)
{ {
return settingManager.GetAllAsync(TenantSettingValueProvider.ProviderName, null, fallback); return settingManager.GetAllAsync(TenantSettingValueProvider.ProviderName, null, fallback);
} }
public static Task SetForTenantAsync(this ISettingManager settingManager, Guid tenantId, [NotNull] string name, [CanBeNull] string value, bool forceToSet = false) public static Task SetForTenantAsync(this ISettingManager settingManager, Guid tenantId, [NotNull] string name, [CanBeNull] string value, bool forceToSet = false)
{ {
return settingManager.SetAsync(name, value, TenantSettingValueProvider.ProviderName, tenantId.ToString(), forceToSet); return settingManager.SetAsync(name, value, TenantSettingValueProvider.ProviderName, tenantId.ToString(), forceToSet);
} }
public static Task SetForCurrentTenantAsync(this ISettingManager settingManager, [NotNull] string name, [CanBeNull] string value, bool forceToSet = false) public static Task SetForCurrentTenantAsync(this ISettingManager settingManager, [NotNull] string name, [CanBeNull] string value, bool forceToSet = false)
{ {
return settingManager.SetAsync(name, value, TenantSettingValueProvider.ProviderName, null, forceToSet); return settingManager.SetAsync(name, value, TenantSettingValueProvider.ProviderName, null, forceToSet);
} }
public static Task SetForTenantOrGlobalAsync(this ISettingManager settingManager, Guid? tenantId, [NotNull] string name, [CanBeNull] string value, bool forceToSet = false) public static Task SetForTenantOrGlobalAsync(this ISettingManager settingManager, Guid? tenantId, [NotNull] string name, [CanBeNull] string value, bool forceToSet = false)
{
if (tenantId.HasValue)
{ {
if (tenantId.HasValue) return settingManager.SetForTenantAsync(tenantId.Value, name, value, forceToSet);
{
return settingManager.SetForTenantAsync(tenantId.Value, name, value, forceToSet);
}
return settingManager.SetGlobalAsync(name, value);
} }
return settingManager.SetGlobalAsync(name, value);
} }
} }

39
modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/UserSettingManagementProvider.cs

@ -2,30 +2,29 @@
using Volo.Abp.Settings; using Volo.Abp.Settings;
using Volo.Abp.Users; using Volo.Abp.Users;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
public class UserSettingManagementProvider : SettingManagementProvider, ITransientDependency
{ {
public class UserSettingManagementProvider : SettingManagementProvider, ITransientDependency public override string Name => UserSettingValueProvider.ProviderName;
{
public override string Name => UserSettingValueProvider.ProviderName;
protected ICurrentUser CurrentUser { get; } protected ICurrentUser CurrentUser { get; }
public UserSettingManagementProvider( public UserSettingManagementProvider(
ISettingManagementStore settingManagementStore, ISettingManagementStore settingManagementStore,
ICurrentUser currentUser) ICurrentUser currentUser)
: base(settingManagementStore) : base(settingManagementStore)
{ {
CurrentUser = currentUser; CurrentUser = currentUser;
} }
protected override string NormalizeProviderKey(string providerKey) protected override string NormalizeProviderKey(string providerKey)
{
if (providerKey != null)
{ {
if (providerKey != null) return providerKey;
{
return providerKey;
}
return CurrentUser.Id?.ToString();
} }
return CurrentUser.Id?.ToString();
} }
} }

63
modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/UserSettingManagerExtensions.cs

@ -5,40 +5,39 @@ using JetBrains.Annotations;
using Volo.Abp.Settings; using Volo.Abp.Settings;
using Volo.Abp.Users; using Volo.Abp.Users;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
//TODO: Consider to move to another package?
public static class UserSettingManagerExtensions
{ {
//TODO: Consider to move to another package? public static Task<string> GetOrNullForUserAsync(this ISettingManager settingManager, [NotNull] string name, Guid userId, bool fallback = true)
{
return settingManager.GetOrNullAsync(name, UserSettingValueProvider.ProviderName, userId.ToString(), fallback);
}
public static Task<string> GetOrNullForCurrentUserAsync(this ISettingManager settingManager, [NotNull] string name, bool fallback = true)
{
return settingManager.GetOrNullAsync(name, UserSettingValueProvider.ProviderName, null, fallback);
}
public static Task<List<SettingValue>> GetAllForUserAsync(this ISettingManager settingManager, Guid userId, bool fallback = true)
{
return settingManager.GetAllAsync(UserSettingValueProvider.ProviderName, userId.ToString(), fallback);
}
public static Task<List<SettingValue>> GetAllForCurrentUserAsync(this ISettingManager settingManager, bool fallback = true)
{
return settingManager.GetAllAsync(UserSettingValueProvider.ProviderName, null, fallback);
}
public static Task SetForUserAsync(this ISettingManager settingManager, Guid userId, [NotNull] string name, [CanBeNull] string value, bool forceToSet = false)
{
return settingManager.SetAsync(name, value, UserSettingValueProvider.ProviderName, userId.ToString(), forceToSet);
}
public static class UserSettingManagerExtensions public static Task SetForCurrentUserAsync(this ISettingManager settingManager, [NotNull] string name, [CanBeNull] string value, bool forceToSet = false)
{ {
public static Task<string> GetOrNullForUserAsync(this ISettingManager settingManager, [NotNull] string name, Guid userId, bool fallback = true) return settingManager.SetAsync(name, value, UserSettingValueProvider.ProviderName, null, forceToSet);
{
return settingManager.GetOrNullAsync(name, UserSettingValueProvider.ProviderName, userId.ToString(), fallback);
}
public static Task<string> GetOrNullForCurrentUserAsync(this ISettingManager settingManager, [NotNull] string name, bool fallback = true)
{
return settingManager.GetOrNullAsync(name, UserSettingValueProvider.ProviderName, null, fallback);
}
public static Task<List<SettingValue>> GetAllForUserAsync(this ISettingManager settingManager, Guid userId, bool fallback = true)
{
return settingManager.GetAllAsync(UserSettingValueProvider.ProviderName, userId.ToString(), fallback);
}
public static Task<List<SettingValue>> GetAllForCurrentUserAsync(this ISettingManager settingManager, bool fallback = true)
{
return settingManager.GetAllAsync(UserSettingValueProvider.ProviderName, null, fallback);
}
public static Task SetForUserAsync(this ISettingManager settingManager, Guid userId, [NotNull] string name, [CanBeNull] string value, bool forceToSet = false)
{
return settingManager.SetAsync(name, value, UserSettingValueProvider.ProviderName, userId.ToString(), forceToSet);
}
public static Task SetForCurrentUserAsync(this ISettingManager settingManager, [NotNull] string name, [CanBeNull] string value, bool forceToSet = false)
{
return settingManager.SetAsync(name, value, UserSettingValueProvider.ProviderName, null, forceToSet);
}
} }
} }

25
modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo/Abp/SettingManagement/EntityFrameworkCore/AbpSettingManagementEntityFrameworkCoreModule.cs

@ -2,22 +2,21 @@ using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
namespace Volo.Abp.SettingManagement.EntityFrameworkCore namespace Volo.Abp.SettingManagement.EntityFrameworkCore;
[DependsOn(
typeof(AbpSettingManagementDomainModule),
typeof(AbpEntityFrameworkCoreModule)
)]
public class AbpSettingManagementEntityFrameworkCoreModule : AbpModule
{ {
[DependsOn( public override void ConfigureServices(ServiceConfigurationContext context)
typeof(AbpSettingManagementDomainModule),
typeof(AbpEntityFrameworkCoreModule)
)]
public class AbpSettingManagementEntityFrameworkCoreModule : AbpModule
{ {
public override void ConfigureServices(ServiceConfigurationContext context) context.Services.AddAbpDbContext<SettingManagementDbContext>(options =>
{ {
context.Services.AddAbpDbContext<SettingManagementDbContext>(options => options.AddDefaultRepositories<ISettingManagementDbContext>();
{
options.AddDefaultRepositories<ISettingManagementDbContext>();
options.AddRepository<Setting, EfCoreSettingRepository>(); options.AddRepository<Setting, EfCoreSettingRepository>();
}); });
}
} }
} }

79
modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo/Abp/SettingManagement/EntityFrameworkCore/EfCoreSettingRepository.cs

@ -7,50 +7,49 @@ using Microsoft.EntityFrameworkCore;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore; using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore;
namespace Volo.Abp.SettingManagement.EntityFrameworkCore namespace Volo.Abp.SettingManagement.EntityFrameworkCore;
public class EfCoreSettingRepository : EfCoreRepository<ISettingManagementDbContext, Setting, Guid>,
ISettingRepository
{ {
public class EfCoreSettingRepository : EfCoreRepository<ISettingManagementDbContext, Setting, Guid>, public EfCoreSettingRepository(IDbContextProvider<ISettingManagementDbContext> dbContextProvider)
ISettingRepository : base(dbContextProvider)
{ {
public EfCoreSettingRepository(IDbContextProvider<ISettingManagementDbContext> dbContextProvider) }
: base(dbContextProvider)
{
}
public virtual async Task<Setting> FindAsync( public virtual async Task<Setting> FindAsync(
string name, string name,
string providerName, string providerName,
string providerKey, string providerKey,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()) return await (await GetDbSetAsync())
.OrderBy(x => x.Id) .OrderBy(x => x.Id)
.FirstOrDefaultAsync( .FirstOrDefaultAsync(
s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey, s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey,
GetCancellationToken(cancellationToken)); GetCancellationToken(cancellationToken));
} }
public virtual async Task<List<Setting>> GetListAsync( public virtual async Task<List<Setting>> GetListAsync(
string providerName, string providerName,
string providerKey, string providerKey,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()) return await (await GetDbSetAsync())
.Where( .Where(
s => s.ProviderName == providerName && s.ProviderKey == providerKey s => s.ProviderName == providerName && s.ProviderKey == providerKey
).ToListAsync(GetCancellationToken(cancellationToken)); ).ToListAsync(GetCancellationToken(cancellationToken));
} }
public virtual async Task<List<Setting>> GetListAsync( public virtual async Task<List<Setting>> GetListAsync(
string[] names, string[] names,
string providerName, string providerName,
string providerKey, string providerKey,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()) return await (await GetDbSetAsync())
.Where( .Where(
s => names.Contains(s.Name) && s.ProviderName == providerName && s.ProviderKey == providerKey s => names.Contains(s.Name) && s.ProviderName == providerName && s.ProviderKey == providerKey
).ToListAsync(GetCancellationToken(cancellationToken)); ).ToListAsync(GetCancellationToken(cancellationToken));
}
} }
} }

13
modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo/Abp/SettingManagement/EntityFrameworkCore/ISettingManagementDbContext.cs

@ -3,12 +3,11 @@ using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.MultiTenancy; using Volo.Abp.MultiTenancy;
namespace Volo.Abp.SettingManagement.EntityFrameworkCore namespace Volo.Abp.SettingManagement.EntityFrameworkCore;
[IgnoreMultiTenancy]
[ConnectionStringName(AbpSettingManagementDbProperties.ConnectionStringName)]
public interface ISettingManagementDbContext : IEfCoreDbContext
{ {
[IgnoreMultiTenancy] DbSet<Setting> Settings { get; }
[ConnectionStringName(AbpSettingManagementDbProperties.ConnectionStringName)]
public interface ISettingManagementDbContext : IEfCoreDbContext
{
DbSet<Setting> Settings { get; }
}
} }

29
modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo/Abp/SettingManagement/EntityFrameworkCore/SettingManagementDbContext.cs

@ -3,25 +3,24 @@ using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.MultiTenancy; using Volo.Abp.MultiTenancy;
namespace Volo.Abp.SettingManagement.EntityFrameworkCore namespace Volo.Abp.SettingManagement.EntityFrameworkCore;
[IgnoreMultiTenancy]
[ConnectionStringName(AbpSettingManagementDbProperties.ConnectionStringName)]
public class SettingManagementDbContext : AbpDbContext<SettingManagementDbContext>, ISettingManagementDbContext
{ {
[IgnoreMultiTenancy] public DbSet<Setting> Settings { get; set; }
[ConnectionStringName(AbpSettingManagementDbProperties.ConnectionStringName)]
public class SettingManagementDbContext : AbpDbContext<SettingManagementDbContext>, ISettingManagementDbContext
{
public DbSet<Setting> Settings { get; set; }
public SettingManagementDbContext(DbContextOptions<SettingManagementDbContext> options) public SettingManagementDbContext(DbContextOptions<SettingManagementDbContext> options)
: base(options) : base(options)
{ {
} }
protected override void OnModelCreating(ModelBuilder builder) protected override void OnModelCreating(ModelBuilder builder)
{ {
base.OnModelCreating(builder); base.OnModelCreating(builder);
builder.ConfigureSettingManagement(); builder.ConfigureSettingManagement();
}
} }
} }

49
modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo/Abp/SettingManagement/EntityFrameworkCore/SettingManagementDbContextModelBuilderExtensions.cs

@ -2,41 +2,40 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.Modeling; using Volo.Abp.EntityFrameworkCore.Modeling;
namespace Volo.Abp.SettingManagement.EntityFrameworkCore namespace Volo.Abp.SettingManagement.EntityFrameworkCore;
public static class SettingManagementDbContextModelBuilderExtensions
{ {
public static class SettingManagementDbContextModelBuilderExtensions //TODO: Instead of getting parameters, get a action of SettingManagementModelBuilderConfigurationOptions like other modules
public static void ConfigureSettingManagement(
[NotNull] this ModelBuilder builder)
{ {
//TODO: Instead of getting parameters, get a action of SettingManagementModelBuilderConfigurationOptions like other modules Check.NotNull(builder, nameof(builder));
public static void ConfigureSettingManagement(
[NotNull] this ModelBuilder builder)
{
Check.NotNull(builder, nameof(builder));
if (builder.IsTenantOnlyDatabase()) if (builder.IsTenantOnlyDatabase())
{ {
return; return;
} }
builder.Entity<Setting>(b => builder.Entity<Setting>(b =>
{ {
b.ToTable(AbpSettingManagementDbProperties.DbTablePrefix + "Settings", AbpSettingManagementDbProperties.DbSchema); b.ToTable(AbpSettingManagementDbProperties.DbTablePrefix + "Settings", AbpSettingManagementDbProperties.DbSchema);
b.ConfigureByConvention(); b.ConfigureByConvention();
b.Property(x => x.Name).HasMaxLength(SettingConsts.MaxNameLength).IsRequired(); b.Property(x => x.Name).HasMaxLength(SettingConsts.MaxNameLength).IsRequired();
if (builder.IsUsingOracle()) { SettingConsts.MaxValueLengthValue = 2000; } if (builder.IsUsingOracle()) { SettingConsts.MaxValueLengthValue = 2000; }
b.Property(x => x.Value).HasMaxLength(SettingConsts.MaxValueLengthValue).IsRequired(); b.Property(x => x.Value).HasMaxLength(SettingConsts.MaxValueLengthValue).IsRequired();
b.Property(x => x.ProviderName).HasMaxLength(SettingConsts.MaxProviderNameLength); b.Property(x => x.ProviderName).HasMaxLength(SettingConsts.MaxProviderNameLength);
b.Property(x => x.ProviderKey).HasMaxLength(SettingConsts.MaxProviderKeyLength); b.Property(x => x.ProviderKey).HasMaxLength(SettingConsts.MaxProviderKeyLength);
b.HasIndex(x => new {x.Name, x.ProviderName, x.ProviderKey}).IsUnique(true); b.HasIndex(x => new { x.Name, x.ProviderName, x.ProviderKey }).IsUnique(true);
b.ApplyObjectExtensionMappings(); b.ApplyObjectExtensionMappings();
}); });
builder.TryConfigureObjectExtensions<SettingManagementDbContext>(); builder.TryConfigureObjectExtensions<SettingManagementDbContext>();
}
} }
} }

7
modules/setting-management/src/Volo.Abp.SettingManagement.HttpApi.Client/ClientProxies/EmailSettingsClientProxy.cs

@ -1,8 +1,7 @@
// This file is part of EmailSettingsClientProxy, you can customize it here // This file is part of EmailSettingsClientProxy, you can customize it here
// ReSharper disable once CheckNamespace // ReSharper disable once CheckNamespace
namespace Volo.Abp.SettingManagement.ClientProxies namespace Volo.Abp.SettingManagement.ClientProxies;
public partial class EmailSettingsClientProxy
{ {
public partial class EmailSettingsClientProxy
{
}
} }

31
modules/setting-management/src/Volo.Abp.SettingManagement.HttpApi.Client/Volo/Abp/SettingManagement/AbpSettingManagementHttpApiClientModule.cs

@ -3,24 +3,23 @@ using Volo.Abp.Http.Client;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
using Volo.Abp.VirtualFileSystem; using Volo.Abp.VirtualFileSystem;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
[DependsOn(
typeof(AbpSettingManagementApplicationContractsModule),
typeof(AbpHttpClientModule))]
public class AbpSettingManagementHttpApiClientModule : AbpModule
{ {
[DependsOn( public override void ConfigureServices(ServiceConfigurationContext context)
typeof(AbpSettingManagementApplicationContractsModule),
typeof(AbpHttpClientModule))]
public class AbpSettingManagementHttpApiClientModule : AbpModule
{ {
public override void ConfigureServices(ServiceConfigurationContext context) context.Services.AddStaticHttpClientProxies(
{ typeof(AbpSettingManagementApplicationContractsModule).Assembly,
context.Services.AddStaticHttpClientProxies( SettingManagementRemoteServiceConsts.RemoteServiceName
typeof(AbpSettingManagementApplicationContractsModule).Assembly, );
SettingManagementRemoteServiceConsts.RemoteServiceName
);
Configure<AbpVirtualFileSystemOptions>(options => Configure<AbpVirtualFileSystemOptions>(options =>
{ {
options.FileSets.AddEmbedded<AbpSettingManagementHttpApiClientModule>(); options.FileSets.AddEmbedded<AbpSettingManagementHttpApiClientModule>();
}); });
}
} }
} }

41
modules/setting-management/src/Volo.Abp.SettingManagement.HttpApi/Volo/Abp/SettingManagement/AbpSettingManagementHttpApiModule.cs

@ -5,31 +5,30 @@ using Volo.Abp.Localization;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
using Volo.Abp.SettingManagement.Localization; using Volo.Abp.SettingManagement.Localization;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
[DependsOn(
typeof(AbpSettingManagementApplicationContractsModule),
typeof(AbpAspNetCoreMvcModule))]
public class AbpSettingManagementHttpApiModule : AbpModule
{ {
[DependsOn( public override void PreConfigureServices(ServiceConfigurationContext context)
typeof(AbpSettingManagementApplicationContractsModule),
typeof(AbpAspNetCoreMvcModule))]
public class AbpSettingManagementHttpApiModule : AbpModule
{ {
public override void PreConfigureServices(ServiceConfigurationContext context) PreConfigure<IMvcBuilder>(mvcBuilder =>
{ {
PreConfigure<IMvcBuilder>(mvcBuilder => mvcBuilder.AddApplicationPartIfNotExists(typeof(AbpSettingManagementHttpApiModule).Assembly);
{ });
mvcBuilder.AddApplicationPartIfNotExists(typeof(AbpSettingManagementHttpApiModule).Assembly); }
});
}
public override void ConfigureServices(ServiceConfigurationContext context) public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpLocalizationOptions>(options =>
{ {
Configure<AbpLocalizationOptions>(options => options.Resources
{ .Get<AbpSettingManagementResource>()
options.Resources .AddBaseTypes(
.Get<AbpSettingManagementResource>() typeof(AbpUiResource)
.AddBaseTypes( );
typeof(AbpUiResource) });
);
});
}
} }
} }

41
modules/setting-management/src/Volo.Abp.SettingManagement.HttpApi/Volo/Abp/SettingManagement/EmailSettingsController.cs

@ -2,30 +2,29 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
[RemoteService(Name = SettingManagementRemoteServiceConsts.RemoteServiceName)]
[Area(SettingManagementRemoteServiceConsts.ModuleName)]
[Route("api/setting-management/emailing")]
public class EmailSettingsController : AbpControllerBase, IEmailSettingsAppService
{ {
[RemoteService(Name = SettingManagementRemoteServiceConsts.RemoteServiceName)] private readonly IEmailSettingsAppService _emailSettingsAppService;
[Area(SettingManagementRemoteServiceConsts.ModuleName)]
[Route("api/setting-management/emailing")]
public class EmailSettingsController : AbpControllerBase, IEmailSettingsAppService
{
private readonly IEmailSettingsAppService _emailSettingsAppService;
public EmailSettingsController(IEmailSettingsAppService emailSettingsAppService) public EmailSettingsController(IEmailSettingsAppService emailSettingsAppService)
{ {
_emailSettingsAppService = emailSettingsAppService; _emailSettingsAppService = emailSettingsAppService;
} }
[HttpGet] [HttpGet]
public Task<EmailSettingsDto> GetAsync() public Task<EmailSettingsDto> GetAsync()
{ {
return _emailSettingsAppService.GetAsync(); return _emailSettingsAppService.GetAsync();
} }
[HttpPost] [HttpPost]
public Task UpdateAsync(UpdateEmailSettingsDto input) public Task UpdateAsync(UpdateEmailSettingsDto input)
{ {
return _emailSettingsAppService.UpdateAsync(input); return _emailSettingsAppService.UpdateAsync(input);
}
} }
} }

23
modules/setting-management/src/Volo.Abp.SettingManagement.Installer/Volo/Abp/SettingManagement/AbpSettingManagementInstallerModule.cs

@ -2,20 +2,19 @@
using Volo.Abp.Studio; using Volo.Abp.Studio;
using Volo.Abp.VirtualFileSystem; using Volo.Abp.VirtualFileSystem;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
[DependsOn(
typeof(AbpStudioModuleInstallerModule),
typeof(AbpVirtualFileSystemModule)
)]
public class AbpSettingManagementInstallerModule : AbpModule
{ {
[DependsOn( public override void ConfigureServices(ServiceConfigurationContext context)
typeof(AbpStudioModuleInstallerModule),
typeof(AbpVirtualFileSystemModule)
)]
public class AbpSettingManagementInstallerModule : AbpModule
{ {
public override void ConfigureServices(ServiceConfigurationContext context) Configure<AbpVirtualFileSystemOptions>(options =>
{ {
Configure<AbpVirtualFileSystemOptions>(options => options.FileSets.AddEmbedded<AbpSettingManagementInstallerModule>();
{ });
options.FileSets.AddEmbedded<AbpSettingManagementInstallerModule>();
});
}
} }
} }

29
modules/setting-management/src/Volo.Abp.SettingManagement.Installer/Volo/Abp/SettingManagement/SettingManagementInstallerPipelineBuilder.cs

@ -3,22 +3,21 @@ using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
using Volo.Abp.Studio.ModuleInstalling; using Volo.Abp.Studio.ModuleInstalling;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
[Dependency(ServiceLifetime.Transient, ReplaceServices = true)]
[ExposeServices(typeof(IModuleInstallingPipelineBuilder))]
public class SettingManagementInstallerPipelineBuilder : ModuleInstallingPipelineBuilderBase, IModuleInstallingPipelineBuilder, ITransientDependency
{ {
[Dependency(ServiceLifetime.Transient, ReplaceServices = true)] public async Task<ModuleInstallingPipeline> BuildAsync(ModuleInstallingContext context)
[ExposeServices(typeof(IModuleInstallingPipelineBuilder))]
public class SettingManagementInstallerPipelineBuilder : ModuleInstallingPipelineBuilderBase, IModuleInstallingPipelineBuilder, ITransientDependency
{ {
public async Task<ModuleInstallingPipeline> BuildAsync(ModuleInstallingContext context) context.AddEfCoreConfigurationMethodDeclaration(
{ new EfCoreConfigurationMethodDeclaration(
context.AddEfCoreConfigurationMethodDeclaration( "Volo.Abp.SettingManagement.EntityFrameworkCore",
new EfCoreConfigurationMethodDeclaration( "ConfigureSettingManagement"
"Volo.Abp.SettingManagement.EntityFrameworkCore", )
"ConfigureSettingManagement" );
)
); return GetBasePipeline(context);
return GetBasePipeline(context);
}
} }
} }

25
modules/setting-management/src/Volo.Abp.SettingManagement.MongoDB/Volo/Abp/SettingManagement/MongoDB/AbpSettingManagementMongoDbModule.cs

@ -2,22 +2,21 @@
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
using Volo.Abp.MongoDB; using Volo.Abp.MongoDB;
namespace Volo.Abp.SettingManagement.MongoDB namespace Volo.Abp.SettingManagement.MongoDB;
[DependsOn(
typeof(AbpSettingManagementDomainModule),
typeof(AbpMongoDbModule)
)]
public class AbpSettingManagementMongoDbModule : AbpModule
{ {
[DependsOn( public override void ConfigureServices(ServiceConfigurationContext context)
typeof(AbpSettingManagementDomainModule),
typeof(AbpMongoDbModule)
)]
public class AbpSettingManagementMongoDbModule : AbpModule
{ {
public override void ConfigureServices(ServiceConfigurationContext context) context.Services.AddMongoDbContext<SettingManagementMongoDbContext>(options =>
{ {
context.Services.AddMongoDbContext<SettingManagementMongoDbContext>(options => options.AddDefaultRepositories<ISettingManagementMongoDbContext>();
{
options.AddDefaultRepositories<ISettingManagementMongoDbContext>();
options.AddRepository<Setting, MongoSettingRepository>(); options.AddRepository<Setting, MongoSettingRepository>();
}); });
}
} }
} }

13
modules/setting-management/src/Volo.Abp.SettingManagement.MongoDB/Volo/Abp/SettingManagement/MongoDB/ISettingManagementMongoDbContext.cs

@ -3,12 +3,11 @@ using Volo.Abp.Data;
using Volo.Abp.MongoDB; using Volo.Abp.MongoDB;
using Volo.Abp.MultiTenancy; using Volo.Abp.MultiTenancy;
namespace Volo.Abp.SettingManagement.MongoDB namespace Volo.Abp.SettingManagement.MongoDB;
[IgnoreMultiTenancy]
[ConnectionStringName(AbpSettingManagementDbProperties.ConnectionStringName)]
public interface ISettingManagementMongoDbContext : IAbpMongoDbContext
{ {
[IgnoreMultiTenancy] IMongoCollection<Setting> Settings { get; }
[ConnectionStringName(AbpSettingManagementDbProperties.ConnectionStringName)]
public interface ISettingManagementMongoDbContext : IAbpMongoDbContext
{
IMongoCollection<Setting> Settings { get; }
}
} }

75
modules/setting-management/src/Volo.Abp.SettingManagement.MongoDB/Volo/Abp/SettingManagement/MongoDB/MongoSettingRepository.cs

@ -8,48 +8,47 @@ using MongoDB.Driver.Linq;
using Volo.Abp.Domain.Repositories.MongoDB; using Volo.Abp.Domain.Repositories.MongoDB;
using Volo.Abp.MongoDB; using Volo.Abp.MongoDB;
namespace Volo.Abp.SettingManagement.MongoDB namespace Volo.Abp.SettingManagement.MongoDB;
public class MongoSettingRepository : MongoDbRepository<ISettingManagementMongoDbContext, Setting, Guid>,
ISettingRepository
{ {
public class MongoSettingRepository : MongoDbRepository<ISettingManagementMongoDbContext, Setting, Guid>, public MongoSettingRepository(IMongoDbContextProvider<ISettingManagementMongoDbContext> dbContextProvider)
ISettingRepository : base(dbContextProvider)
{ {
public MongoSettingRepository(IMongoDbContextProvider<ISettingManagementMongoDbContext> dbContextProvider) }
: base(dbContextProvider)
{
}
public virtual async Task<Setting> FindAsync( public virtual async Task<Setting> FindAsync(
string name, string name,
string providerName, string providerName,
string providerKey, string providerKey,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return await (await GetMongoQueryableAsync(cancellationToken)) return await (await GetMongoQueryableAsync(cancellationToken))
.OrderBy(x => x.Id) .OrderBy(x => x.Id)
.FirstOrDefaultAsync( .FirstOrDefaultAsync(
s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey, s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey,
GetCancellationToken(cancellationToken)); GetCancellationToken(cancellationToken));
} }
public virtual async Task<List<Setting>> GetListAsync( public virtual async Task<List<Setting>> GetListAsync(
string providerName, string providerName,
string providerKey, string providerKey,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return await (await GetMongoQueryableAsync(cancellationToken)) return await (await GetMongoQueryableAsync(cancellationToken))
.Where(s => s.ProviderName == providerName && s.ProviderKey == providerKey) .Where(s => s.ProviderName == providerName && s.ProviderKey == providerKey)
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public virtual async Task<List<Setting>> GetListAsync( public virtual async Task<List<Setting>> GetListAsync(
string[] names, string[] names,
string providerName, string providerName,
string providerKey, string providerKey,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return await (await GetMongoQueryableAsync(cancellationToken)) return await (await GetMongoQueryableAsync(cancellationToken))
.Where(s => names.Contains(s.Name) && s.ProviderName == providerName && s.ProviderKey == providerKey) .Where(s => names.Contains(s.Name) && s.ProviderName == providerName && s.ProviderKey == providerKey)
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
}
} }
} }

21
modules/setting-management/src/Volo.Abp.SettingManagement.MongoDB/Volo/Abp/SettingManagement/MongoDB/SettingManagementMongoDbContext.cs

@ -3,19 +3,18 @@ using Volo.Abp.Data;
using Volo.Abp.MongoDB; using Volo.Abp.MongoDB;
using Volo.Abp.MultiTenancy; using Volo.Abp.MultiTenancy;
namespace Volo.Abp.SettingManagement.MongoDB namespace Volo.Abp.SettingManagement.MongoDB;
[IgnoreMultiTenancy]
[ConnectionStringName(AbpSettingManagementDbProperties.ConnectionStringName)]
public class SettingManagementMongoDbContext : AbpMongoDbContext, ISettingManagementMongoDbContext
{ {
[IgnoreMultiTenancy] public IMongoCollection<Setting> Settings => Collection<Setting>();
[ConnectionStringName(AbpSettingManagementDbProperties.ConnectionStringName)]
public class SettingManagementMongoDbContext : AbpMongoDbContext, ISettingManagementMongoDbContext
{
public IMongoCollection<Setting> Settings => Collection<Setting>();
protected override void CreateModel(IMongoModelBuilder modelBuilder) protected override void CreateModel(IMongoModelBuilder modelBuilder)
{ {
base.CreateModel(modelBuilder); base.CreateModel(modelBuilder);
modelBuilder.ConfigureSettingManagement(); modelBuilder.ConfigureSettingManagement();
}
} }
} }

23
modules/setting-management/src/Volo.Abp.SettingManagement.MongoDB/Volo/Abp/SettingManagement/MongoDB/SettingManagementMongoDbContextExtensions.cs

@ -1,18 +1,17 @@
using Volo.Abp.MongoDB; using Volo.Abp.MongoDB;
namespace Volo.Abp.SettingManagement.MongoDB namespace Volo.Abp.SettingManagement.MongoDB;
public static class SettingManagementMongoDbContextExtensions
{ {
public static class SettingManagementMongoDbContextExtensions public static void ConfigureSettingManagement(
this IMongoModelBuilder builder)
{ {
public static void ConfigureSettingManagement( Check.NotNull(builder, nameof(builder));
this IMongoModelBuilder builder)
{
Check.NotNull(builder, nameof(builder));
builder.Entity<Setting>(b => builder.Entity<Setting>(b =>
{ {
b.CollectionName = AbpSettingManagementDbProperties.DbTablePrefix + "Settings"; b.CollectionName = AbpSettingManagementDbProperties.DbTablePrefix + "Settings";
}); });
}
} }
} }

79
modules/setting-management/src/Volo.Abp.SettingManagement.Web/AbpSettingManagementWebModule.cs

@ -10,54 +10,53 @@ using Volo.Abp.SettingManagement.Web.Settings;
using Volo.Abp.UI.Navigation; using Volo.Abp.UI.Navigation;
using Volo.Abp.VirtualFileSystem; using Volo.Abp.VirtualFileSystem;
namespace Volo.Abp.SettingManagement.Web namespace Volo.Abp.SettingManagement.Web;
[DependsOn(
typeof(AbpSettingManagementApplicationContractsModule),
typeof(AbpAspNetCoreMvcUiThemeSharedModule),
typeof(AbpSettingManagementDomainSharedModule)
)]
public class AbpSettingManagementWebModule : AbpModule
{ {
[DependsOn( public override void PreConfigureServices(ServiceConfigurationContext context)
typeof(AbpSettingManagementApplicationContractsModule),
typeof(AbpAspNetCoreMvcUiThemeSharedModule),
typeof(AbpSettingManagementDomainSharedModule)
)]
public class AbpSettingManagementWebModule : AbpModule
{ {
public override void PreConfigureServices(ServiceConfigurationContext context) PreConfigure<IMvcBuilder>(mvcBuilder =>
{ {
PreConfigure<IMvcBuilder>(mvcBuilder => mvcBuilder.AddApplicationPartIfNotExists(typeof(AbpSettingManagementWebModule).Assembly);
{ });
mvcBuilder.AddApplicationPartIfNotExists(typeof(AbpSettingManagementWebModule).Assembly); }
});
}
public override void ConfigureServices(ServiceConfigurationContext context) public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpNavigationOptions>(options =>
{ {
Configure<AbpNavigationOptions>(options => options.MenuContributors.Add(new SettingManagementMainMenuContributor());
{ });
options.MenuContributors.Add(new SettingManagementMainMenuContributor());
});
Configure<SettingManagementPageOptions>(options => Configure<SettingManagementPageOptions>(options =>
{ {
options.Contributors.Add(new EmailingPageContributor()); options.Contributors.Add(new EmailingPageContributor());
}); });
Configure<AbpVirtualFileSystemOptions>(options => Configure<AbpVirtualFileSystemOptions>(options =>
{ {
options.FileSets.AddEmbedded<AbpSettingManagementWebModule>(); options.FileSets.AddEmbedded<AbpSettingManagementWebModule>();
}); });
Configure<AbpBundlingOptions>(options => Configure<AbpBundlingOptions>(options =>
{ {
options.ScriptBundles options.ScriptBundles
.Configure(typeof(IndexModel).FullName, .Configure(typeof(IndexModel).FullName,
configuration => configuration =>
{ {
configuration.AddFiles("/Pages/SettingManagement/Components/EmailSettingGroup/Default.js"); configuration.AddFiles("/Pages/SettingManagement/Components/EmailSettingGroup/Default.js");
}); });
}); });
Configure<DynamicJavaScriptProxyOptions>(options => Configure<DynamicJavaScriptProxyOptions>(options =>
{ {
options.DisableModule(SettingManagementRemoteServiceConsts.ModuleName); options.DisableModule(SettingManagementRemoteServiceConsts.ModuleName);
}); });
}
} }
} }

81
modules/setting-management/src/Volo.Abp.SettingManagement.Web/Navigation/SettingManagementMainMenuContributor.cs

@ -7,58 +7,57 @@ using Volo.Abp.SettingManagement.Web.Pages.SettingManagement;
using Volo.Abp.UI.Navigation; using Volo.Abp.UI.Navigation;
using Volo.Abp.SettingManagement.Localization; using Volo.Abp.SettingManagement.Localization;
namespace Volo.Abp.SettingManagement.Web.Navigation namespace Volo.Abp.SettingManagement.Web.Navigation;
public class SettingManagementMainMenuContributor : IMenuContributor
{ {
public class SettingManagementMainMenuContributor : IMenuContributor public virtual async Task ConfigureMenuAsync(MenuConfigurationContext context)
{ {
public virtual async Task ConfigureMenuAsync(MenuConfigurationContext context) if (context.Menu.Name != StandardMenus.Main)
{ {
if (context.Menu.Name != StandardMenus.Main) return;
{ }
return;
}
if (context.Menu.FindMenuItem(SettingManagementMenuNames.GroupName) != null) if (context.Menu.FindMenuItem(SettingManagementMenuNames.GroupName) != null)
{ {
/* This may happen if blazor server UI is being used in the same application. /* This may happen if blazor server UI is being used in the same application.
* In this case, we don't add the MVC setting management UI. */ * In this case, we don't add the MVC setting management UI. */
return; return;
} }
var settingManagementPageOptions = context.ServiceProvider.GetRequiredService<IOptions<SettingManagementPageOptions>>().Value; var settingManagementPageOptions = context.ServiceProvider.GetRequiredService<IOptions<SettingManagementPageOptions>>().Value;
var settingPageCreationContext = new SettingPageCreationContext(context.ServiceProvider); var settingPageCreationContext = new SettingPageCreationContext(context.ServiceProvider);
if (!settingManagementPageOptions.Contributors.Any() || if (!settingManagementPageOptions.Contributors.Any() ||
!(await CheckAnyOfPagePermissionsGranted(settingManagementPageOptions, settingPageCreationContext))) !(await CheckAnyOfPagePermissionsGranted(settingManagementPageOptions, settingPageCreationContext)))
{ {
return; return;
} }
var l = context.GetLocalizer<AbpSettingManagementResource>(); var l = context.GetLocalizer<AbpSettingManagementResource>();
context.Menu context.Menu
.GetAdministration() .GetAdministration()
.AddItem( .AddItem(
new ApplicationMenuItem( new ApplicationMenuItem(
SettingManagementMenuNames.GroupName, SettingManagementMenuNames.GroupName,
l["Settings"], l["Settings"],
"~/SettingManagement", "~/SettingManagement",
icon: "fa fa-cog" icon: "fa fa-cog"
).RequireFeatures(SettingManagementFeatures.Enable) ).RequireFeatures(SettingManagementFeatures.Enable)
); );
} }
protected virtual async Task<bool> CheckAnyOfPagePermissionsGranted( protected virtual async Task<bool> CheckAnyOfPagePermissionsGranted(
SettingManagementPageOptions settingManagementPageOptions, SettingManagementPageOptions settingManagementPageOptions,
SettingPageCreationContext settingPageCreationContext) SettingPageCreationContext settingPageCreationContext)
{
foreach (var contributor in settingManagementPageOptions.Contributors)
{ {
foreach (var contributor in settingManagementPageOptions.Contributors) if (await contributor.CheckPermissionsAsync(settingPageCreationContext))
{ {
if (await contributor.CheckPermissionsAsync(settingPageCreationContext)) return true;
{
return true;
}
} }
return false;
} }
return false;
} }
} }

9
modules/setting-management/src/Volo.Abp.SettingManagement.Web/Navigation/SettingManagementMenuNames.cs

@ -1,7 +1,6 @@
namespace Volo.Abp.SettingManagement.Web.Navigation namespace Volo.Abp.SettingManagement.Web.Navigation;
public class SettingManagementMenuNames
{ {
public class SettingManagementMenuNames public const string GroupName = "SettingManagement";
{
public const string GroupName = "SettingManagement";
}
} }

27
modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/Components/EmailSettingGroup/EmailSettingGroupViewComponent.cs

@ -2,23 +2,22 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc;
namespace Volo.Abp.SettingManagement.Web.Pages.SettingManagement.Components.EmailSettingGroup namespace Volo.Abp.SettingManagement.Web.Pages.SettingManagement.Components.EmailSettingGroup;
public class EmailSettingGroupViewComponent : AbpViewComponent
{ {
public class EmailSettingGroupViewComponent : AbpViewComponent protected IEmailSettingsAppService EmailSettingsAppService { get; }
{
protected IEmailSettingsAppService EmailSettingsAppService { get; }
public EmailSettingGroupViewComponent(IEmailSettingsAppService emailSettingsAppService) public EmailSettingGroupViewComponent(IEmailSettingsAppService emailSettingsAppService)
{ {
ObjectMapperContext = typeof(AbpSettingManagementWebModule); ObjectMapperContext = typeof(AbpSettingManagementWebModule);
EmailSettingsAppService = emailSettingsAppService; EmailSettingsAppService = emailSettingsAppService;
} }
public virtual async Task<IViewComponentResult> InvokeAsync() public virtual async Task<IViewComponentResult> InvokeAsync()
{ {
var model = await EmailSettingsAppService.GetAsync(); var model = await EmailSettingsAppService.GetAsync();
return View("~/Pages/SettingManagement/Components/EmailSettingGroup/Default.cshtml", model); return View("~/Pages/SettingManagement/Components/EmailSettingGroup/Default.cshtml", model);
}
} }
} }

13
modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/ISettingPageContributor.cs

@ -1,11 +1,10 @@
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Volo.Abp.SettingManagement.Web.Pages.SettingManagement namespace Volo.Abp.SettingManagement.Web.Pages.SettingManagement;
public interface ISettingPageContributor
{ {
public interface ISettingPageContributor Task ConfigureAsync(SettingPageCreationContext context);
{
Task ConfigureAsync(SettingPageCreationContext context);
Task<bool> CheckPermissionsAsync(SettingPageCreationContext context); Task<bool> CheckPermissionsAsync(SettingPageCreationContext context);
} }
}

65
modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/Index.cshtml.cs

@ -6,48 +6,47 @@ using Volo.Abp.AspNetCore.Mvc.UI.RazorPages;
using Volo.Abp.EventBus.Local; using Volo.Abp.EventBus.Local;
using Volo.Abp.Features; using Volo.Abp.Features;
namespace Volo.Abp.SettingManagement.Web.Pages.SettingManagement namespace Volo.Abp.SettingManagement.Web.Pages.SettingManagement;
[RequiresFeature(SettingManagementFeatures.Enable)]
public class IndexModel : AbpPageModel
{ {
[RequiresFeature(SettingManagementFeatures.Enable)] public SettingPageCreationContext SettingPageCreationContext { get; private set; }
public class IndexModel : AbpPageModel
protected ILocalEventBus LocalEventBus { get; }
protected SettingManagementPageOptions Options { get; }
public IndexModel(
IOptions<SettingManagementPageOptions> options,
ILocalEventBus localEventBus)
{ {
public SettingPageCreationContext SettingPageCreationContext { get; private set; } LocalEventBus = localEventBus;
Options = options.Value;
}
protected ILocalEventBus LocalEventBus { get; } public virtual async Task<IActionResult> OnGetAsync()
protected SettingManagementPageOptions Options { get; } {
SettingPageCreationContext = new SettingPageCreationContext(ServiceProvider);
public IndexModel( foreach (var contributor in Options.Contributors)
IOptions<SettingManagementPageOptions> options,
ILocalEventBus localEventBus)
{ {
LocalEventBus = localEventBus; await contributor.ConfigureAsync(SettingPageCreationContext);
Options = options.Value;
} }
public virtual async Task<IActionResult> OnGetAsync() return Page();
{ }
SettingPageCreationContext = new SettingPageCreationContext(ServiceProvider);
foreach (var contributor in Options.Contributors)
{
await contributor.ConfigureAsync(SettingPageCreationContext);
}
return Page();
}
public virtual Task<IActionResult> OnPostAsync() public virtual Task<IActionResult> OnPostAsync()
{ {
return Task.FromResult<IActionResult>(Page()); return Task.FromResult<IActionResult>(Page());
} }
public virtual async Task<NoContentResult> OnPostRefreshConfigurationAsync() public virtual async Task<NoContentResult> OnPostRefreshConfigurationAsync()
{ {
await LocalEventBus.PublishAsync( await LocalEventBus.PublishAsync(
new CurrentApplicationConfigurationCacheResetEventData() new CurrentApplicationConfigurationCacheResetEventData()
); );
return NoContent(); return NoContent();
}
} }
} }

15
modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/SettingManagementPageOptions.cs

@ -1,14 +1,13 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace Volo.Abp.SettingManagement.Web.Pages.SettingManagement namespace Volo.Abp.SettingManagement.Web.Pages.SettingManagement;
public class SettingManagementPageOptions
{ {
public class SettingManagementPageOptions public List<ISettingPageContributor> Contributors { get; }
{
public List<ISettingPageContributor> Contributors { get; }
public SettingManagementPageOptions() public SettingManagementPageOptions()
{ {
Contributors = new List<ISettingPageContributor>(); Contributors = new List<ISettingPageContributor>();
}
} }
} }

21
modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/SettingPageCreationContext.cs

@ -2,19 +2,18 @@
using System.Collections.Generic; using System.Collections.Generic;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
namespace Volo.Abp.SettingManagement.Web.Pages.SettingManagement namespace Volo.Abp.SettingManagement.Web.Pages.SettingManagement;
public class SettingPageCreationContext : IServiceProviderAccessor
{ {
public class SettingPageCreationContext : IServiceProviderAccessor public IServiceProvider ServiceProvider { get; }
{
public IServiceProvider ServiceProvider { get; }
public List<SettingPageGroup> Groups { get; } public List<SettingPageGroup> Groups { get; }
public SettingPageCreationContext(IServiceProvider serviceProvider) public SettingPageCreationContext(IServiceProvider serviceProvider)
{ {
ServiceProvider = serviceProvider; ServiceProvider = serviceProvider;
Groups = new List<SettingPageGroup>(); Groups = new List<SettingPageGroup>();
}
} }
} }

56
modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/SettingPageGroup.cs

@ -1,39 +1,35 @@
using System; using System;
using JetBrains.Annotations; using JetBrains.Annotations;
namespace Volo.Abp.SettingManagement.Web.Pages.SettingManagement namespace Volo.Abp.SettingManagement.Web.Pages.SettingManagement;
public class SettingPageGroup
{ {
public class SettingPageGroup public string Id {
{ get => _id;
public string Id set => _id = Check.NotNullOrWhiteSpace(value, nameof(Id));
{ }
get => _id; private string _id;
set => _id = Check.NotNullOrWhiteSpace(value, nameof(Id));
}
private string _id;
public string DisplayName public string DisplayName {
{ get => _displayName;
get => _displayName; set => _displayName = Check.NotNullOrWhiteSpace(value, nameof(DisplayName));
set => _displayName = Check.NotNullOrWhiteSpace(value, nameof(DisplayName)); }
} private string _displayName;
private string _displayName;
public Type ComponentType public Type ComponentType {
{ get => _componentType;
get => _componentType; set => _componentType = Check.NotNull(value, nameof(ComponentType));
set => _componentType = Check.NotNull(value, nameof(ComponentType)); }
} private Type _componentType;
private Type _componentType;
public object Parameter { get; set; } public object Parameter { get; set; }
public SettingPageGroup([NotNull] string id, [NotNull] string displayName, [NotNull] Type componentType, object parameter = null) public SettingPageGroup([NotNull] string id, [NotNull] string displayName, [NotNull] Type componentType, object parameter = null)
{ {
Id = id; Id = id;
DisplayName = displayName; DisplayName = displayName;
ComponentType = componentType; ComponentType = componentType;
Parameter = parameter; Parameter = parameter;
}
} }
} }

27
modules/setting-management/src/Volo.Abp.SettingManagement.Web/Properties/launchSettings.json

@ -0,0 +1,27 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:50943/",
"sslPort": 44372
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Volo.Abp.SettingManagement.Web": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:5001;http://localhost:5000"
}
}
}

77
modules/setting-management/src/Volo.Abp.SettingManagement.Web/Settings/EmailingPageContributor.cs

@ -8,58 +8,57 @@ using Volo.Abp.SettingManagement.Localization;
using Volo.Abp.SettingManagement.Web.Pages.SettingManagement; using Volo.Abp.SettingManagement.Web.Pages.SettingManagement;
using Volo.Abp.SettingManagement.Web.Pages.SettingManagement.Components.EmailSettingGroup; using Volo.Abp.SettingManagement.Web.Pages.SettingManagement.Components.EmailSettingGroup;
namespace Volo.Abp.SettingManagement.Web.Settings namespace Volo.Abp.SettingManagement.Web.Settings;
public class EmailingPageContributor : ISettingPageContributor
{ {
public class EmailingPageContributor: ISettingPageContributor public async Task ConfigureAsync(SettingPageCreationContext context)
{ {
public async Task ConfigureAsync(SettingPageCreationContext context) if (!await CheckPermissionsInternalAsync(context))
{ {
if (!await CheckPermissionsInternalAsync(context)) return;
{
return;
}
var l = context.ServiceProvider.GetRequiredService<IStringLocalizer<AbpSettingManagementResource>>();
context.Groups.Add(
new SettingPageGroup(
"Volo.Abp.EmailSetting",
l["Menu:Emailing"],
typeof(EmailSettingGroupViewComponent)
)
);
} }
public async Task<bool> CheckPermissionsAsync(SettingPageCreationContext context) var l = context.ServiceProvider.GetRequiredService<IStringLocalizer<AbpSettingManagementResource>>();
context.Groups.Add(
new SettingPageGroup(
"Volo.Abp.EmailSetting",
l["Menu:Emailing"],
typeof(EmailSettingGroupViewComponent)
)
);
}
public async Task<bool> CheckPermissionsAsync(SettingPageCreationContext context)
{
return await CheckPermissionsInternalAsync(context);
}
private async Task<bool> CheckPermissionsInternalAsync(SettingPageCreationContext context)
{
if (!await CheckFeatureAsync(context))
{ {
return await CheckPermissionsInternalAsync(context); return false;
} }
private async Task<bool> CheckPermissionsInternalAsync(SettingPageCreationContext context) var authorizationService = context.ServiceProvider.GetRequiredService<IAuthorizationService>();
{
if (!await CheckFeatureAsync(context))
{
return false;
}
var authorizationService = context.ServiceProvider.GetRequiredService<IAuthorizationService>(); return await authorizationService.IsGrantedAsync(SettingManagementPermissions.Emailing);
}
return await authorizationService.IsGrantedAsync(SettingManagementPermissions.Emailing); private async Task<bool> CheckFeatureAsync(SettingPageCreationContext context)
{
var featureCheck = context.ServiceProvider.GetRequiredService<IFeatureChecker>();
if (!await featureCheck.IsEnabledAsync(SettingManagementFeatures.Enable))
{
return false;
} }
private async Task<bool> CheckFeatureAsync(SettingPageCreationContext context) if (context.ServiceProvider.GetRequiredService<ICurrentTenant>().IsAvailable)
{ {
var featureCheck = context.ServiceProvider.GetRequiredService<IFeatureChecker>(); return await featureCheck.IsEnabledAsync(SettingManagementFeatures.AllowTenantsToChangeEmailSettings);
if (!await featureCheck.IsEnabledAsync(SettingManagementFeatures.Enable))
{
return false;
}
if (context.ServiceProvider.GetRequiredService<ICurrentTenant>().IsAvailable)
{
return await featureCheck.IsEnabledAsync(SettingManagementFeatures.AllowTenantsToChangeEmailSettings);
}
return true;
} }
return true;
} }
} }

49
modules/setting-management/test/Volo.Abp.SettingManagement.EntityFrameworkCore.Tests/Volo/Abp/SettingManagement/EntityFrameworkCore/AbpSettingManagementEntityFrameworkCoreTestModule.cs

@ -7,38 +7,37 @@ using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.Sqlite; using Volo.Abp.EntityFrameworkCore.Sqlite;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
namespace Volo.Abp.SettingManagement.EntityFrameworkCore namespace Volo.Abp.SettingManagement.EntityFrameworkCore;
[DependsOn(
typeof(AbpSettingManagementTestBaseModule),
typeof(AbpSettingManagementEntityFrameworkCoreModule),
typeof(AbpEntityFrameworkCoreSqliteModule)
)]
public class AbpSettingManagementEntityFrameworkCoreTestModule : AbpModule
{ {
[DependsOn( public override void ConfigureServices(ServiceConfigurationContext context)
typeof(AbpSettingManagementTestBaseModule),
typeof(AbpSettingManagementEntityFrameworkCoreModule),
typeof(AbpEntityFrameworkCoreSqliteModule)
)]
public class AbpSettingManagementEntityFrameworkCoreTestModule : AbpModule
{ {
public override void ConfigureServices(ServiceConfigurationContext context) var sqliteConnection = CreateDatabaseAndGetConnection();
{
var sqliteConnection = CreateDatabaseAndGetConnection();
Configure<AbpDbContextOptions>(options => Configure<AbpDbContextOptions>(options =>
{
options.Configure(abpDbContextConfigurationContext =>
{ {
options.Configure(abpDbContextConfigurationContext => abpDbContextConfigurationContext.DbContextOptions.UseSqlite(sqliteConnection);
{
abpDbContextConfigurationContext.DbContextOptions.UseSqlite(sqliteConnection);
});
}); });
} });
}
private static SqliteConnection CreateDatabaseAndGetConnection() private static SqliteConnection CreateDatabaseAndGetConnection()
{ {
var connection = new SqliteConnection("Data Source=:memory:"); var connection = new SqliteConnection("Data Source=:memory:");
connection.Open(); connection.Open();
new SettingManagementDbContext( new SettingManagementDbContext(
new DbContextOptionsBuilder<SettingManagementDbContext>().UseSqlite(connection).Options new DbContextOptionsBuilder<SettingManagementDbContext>().UseSqlite(connection).Options
).GetService<IRelationalDatabaseCreator>().CreateTables(); ).GetService<IRelationalDatabaseCreator>().CreateTables();
return connection; return connection;
}
} }
} }

7
modules/setting-management/test/Volo.Abp.SettingManagement.EntityFrameworkCore.Tests/Volo/Abp/SettingManagement/EntityFrameworkCore/SettingRepository_Tests.cs

@ -1,7 +1,6 @@
namespace Volo.Abp.SettingManagement.EntityFrameworkCore namespace Volo.Abp.SettingManagement.EntityFrameworkCore;
public class SettingRepository_Tests : SettingRepository_Tests<AbpSettingManagementEntityFrameworkCoreTestModule>
{ {
public class SettingRepository_Tests : SettingRepository_Tests<AbpSettingManagementEntityFrameworkCoreTestModule>
{
}
} }

33
modules/setting-management/test/Volo.Abp.SettingManagement.MongoDB.Tests/Volo/Abp/SettingManagement/MongoDB/AbpSettingManagementMongoDbTestModule.cs

@ -3,25 +3,24 @@ using Volo.Abp.Data;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
using Volo.Abp.Uow; using Volo.Abp.Uow;
namespace Volo.Abp.SettingManagement.MongoDB namespace Volo.Abp.SettingManagement.MongoDB;
[DependsOn(
typeof(AbpSettingManagementMongoDbModule),
typeof(AbpSettingManagementTestBaseModule)
)]
public class AbpSettingManagementMongoDbTestModule : AbpModule
{ {
[DependsOn( public override void ConfigureServices(ServiceConfigurationContext context)
typeof(AbpSettingManagementMongoDbModule),
typeof(AbpSettingManagementTestBaseModule)
)]
public class AbpSettingManagementMongoDbTestModule : AbpModule
{ {
public override void ConfigureServices(ServiceConfigurationContext context) var stringArray = MongoDbFixture.ConnectionString.Split('?');
{ var connectionString = stringArray[0].EnsureEndsWith('/') +
var stringArray = MongoDbFixture.ConnectionString.Split('?'); "Db_" +
var connectionString = stringArray[0].EnsureEndsWith('/') + Guid.NewGuid().ToString("N") + "/?" + stringArray[1];
"Db_" +
Guid.NewGuid().ToString("N") + "/?" + stringArray[1];
Configure<AbpDbConnectionOptions>(options => Configure<AbpDbConnectionOptions>(options =>
{ {
options.ConnectionStrings.Default = connectionString; options.ConnectionStrings.Default = connectionString;
}); });
}
} }
} }

27
modules/setting-management/test/Volo.Abp.SettingManagement.MongoDB.Tests/Volo/Abp/SettingManagement/MongoDB/MongoDbFixture.cs

@ -1,22 +1,21 @@
using System; using System;
using Mongo2Go; using Mongo2Go;
namespace Volo.Abp.SettingManagement.MongoDB namespace Volo.Abp.SettingManagement.MongoDB;
public class MongoDbFixture : IDisposable
{ {
public class MongoDbFixture : IDisposable private static readonly MongoDbRunner MongoDbRunner;
{ public static readonly string ConnectionString;
private static readonly MongoDbRunner MongoDbRunner;
public static readonly string ConnectionString;
static MongoDbFixture() static MongoDbFixture()
{ {
MongoDbRunner = MongoDbRunner.Start(singleNodeReplSet: true, singleNodeReplSetWaitTimeout: 20); MongoDbRunner = MongoDbRunner.Start(singleNodeReplSet: true, singleNodeReplSetWaitTimeout: 20);
ConnectionString = MongoDbRunner.ConnectionString; ConnectionString = MongoDbRunner.ConnectionString;
} }
public void Dispose() public void Dispose()
{ {
MongoDbRunner?.Dispose(); MongoDbRunner?.Dispose();
}
} }
} }

13
modules/setting-management/test/Volo.Abp.SettingManagement.MongoDB.Tests/Volo/Abp/SettingManagement/MongoDB/MongoTestCollection.cs

@ -1,10 +1,9 @@
using Xunit; using Xunit;
namespace Volo.Abp.SettingManagement.MongoDB namespace Volo.Abp.SettingManagement.MongoDB;
[CollectionDefinition(Name)]
public class MongoTestCollection : ICollectionFixture<MongoDbFixture>
{ {
[CollectionDefinition(Name)] public const string Name = "MongoDB Collection";
public class MongoTestCollection : ICollectionFixture<MongoDbFixture> }
{
public const string Name = "MongoDB Collection";
}
}

9
modules/setting-management/test/Volo.Abp.SettingManagement.MongoDB.Tests/Volo/Abp/SettingManagement/MongoDB/SettingRepository_Tests.cs

@ -1,10 +1,9 @@
using Xunit; using Xunit;
namespace Volo.Abp.SettingManagement.MongoDB namespace Volo.Abp.SettingManagement.MongoDB;
[Collection(MongoTestCollection.Name)]
public class SettingRepository_Tests : SettingRepository_Tests<AbpSettingManagementMongoDbTestModule>
{ {
[Collection(MongoTestCollection.Name)]
public class SettingRepository_Tests : SettingRepository_Tests<AbpSettingManagementMongoDbTestModule>
{
}
} }

35
modules/setting-management/test/Volo.Abp.SettingManagement.TestBase/Volo/Abp/SettingManagement/AbpSettingManagementTestBaseModule.cs

@ -4,27 +4,26 @@ using Volo.Abp.Modularity;
using Volo.Abp.Settings; using Volo.Abp.Settings;
using Volo.Abp.Threading; using Volo.Abp.Threading;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
[DependsOn(
typeof(AbpAutofacModule),
typeof(AbpTestBaseModule),
typeof(AbpSettingManagementDomainModule))]
public class AbpSettingManagementTestBaseModule : AbpModule
{ {
[DependsOn( public override void OnApplicationInitialization(ApplicationInitializationContext context)
typeof(AbpAutofacModule),
typeof(AbpTestBaseModule),
typeof(AbpSettingManagementDomainModule))]
public class AbpSettingManagementTestBaseModule : AbpModule
{ {
public override void OnApplicationInitialization(ApplicationInitializationContext context) SeedTestData(context);
{ }
SeedTestData(context);
}
private static void SeedTestData(ApplicationInitializationContext context) private static void SeedTestData(ApplicationInitializationContext context)
{
using (var scope = context.ServiceProvider.CreateScope())
{ {
using (var scope = context.ServiceProvider.CreateScope()) AsyncHelper.RunSync(() => scope.ServiceProvider
{ .GetRequiredService<SettingTestDataBuilder>()
AsyncHelper.RunSync(()=> scope.ServiceProvider .BuildAsync());
.GetRequiredService<SettingTestDataBuilder>()
.BuildAsync());
}
} }
} }
} }

13
modules/setting-management/test/Volo.Abp.SettingManagement.TestBase/Volo/Abp/SettingManagement/SettingManagementTestBase.cs

@ -1,14 +1,13 @@
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
using Volo.Abp.Testing; using Volo.Abp.Testing;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
public class SettingManagementTestBase<TStartupModule> : AbpIntegratedTest<TStartupModule>
where TStartupModule : IAbpModule
{ {
public class SettingManagementTestBase<TStartupModule> : AbpIntegratedTest<TStartupModule> protected override void SetAbpApplicationCreationOptions(AbpApplicationCreationOptions options)
where TStartupModule : IAbpModule
{ {
protected override void SetAbpApplicationCreationOptions(AbpApplicationCreationOptions options) options.UseAutofac();
{
options.UseAutofac();
}
} }
} }

101
modules/setting-management/test/Volo.Abp.SettingManagement.TestBase/Volo/Abp/SettingManagement/SettingRepository_Tests.cs

@ -5,58 +5,57 @@ using Volo.Abp.Modularity;
using Volo.Abp.Settings; using Volo.Abp.Settings;
using Xunit; using Xunit;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
public abstract class SettingRepository_Tests<TStartupModule> : SettingManagementTestBase<TStartupModule>
where TStartupModule : IAbpModule
{ {
public abstract class SettingRepository_Tests<TStartupModule> : SettingManagementTestBase<TStartupModule> protected ISettingRepository SettingRepository { get; }
where TStartupModule : IAbpModule protected SettingTestData TestData { get; }
protected SettingRepository_Tests()
{
SettingRepository = GetRequiredService<ISettingRepository>();
TestData = GetRequiredService<SettingTestData>();
}
[Fact]
public async Task FindAsync()
{
(await SettingRepository.FindAsync(
"MySetting1",
GlobalSettingValueProvider.ProviderName,
null
)).Value.ShouldBe("42");
(await SettingRepository.FindAsync(
"MySetting2",
UserSettingValueProvider.ProviderName,
TestData.User1Id.ToString()
)).Value.ShouldBe("user1-store-value");
(await SettingRepository.FindAsync(
"Undefined-Setting",
GlobalSettingValueProvider.ProviderName,
null
)).ShouldBeNull();
}
[Fact]
public async Task GetListAsync()
{
var settings = await SettingRepository.GetListAsync(GlobalSettingValueProvider.ProviderName, null);
settings.Any().ShouldBeTrue();
settings.ShouldContain(s => s.Name == "MySetting1" && s.Value == "42");
settings.ShouldContain(s => s.Name == "MySetting2" && s.Value == "default-store-value");
}
[Fact]
public async Task GetList_With_Names()
{ {
protected ISettingRepository SettingRepository { get; } var settings = await SettingRepository.GetListAsync(new[] { "MySetting1", "MySetting2" }, GlobalSettingValueProvider.ProviderName, null);
protected SettingTestData TestData { get; } settings.Any().ShouldBeTrue();
settings.ShouldContain(s => s.Name == "MySetting1" && s.Value == "42");
protected SettingRepository_Tests() settings.ShouldContain(s => s.Name == "MySetting2" && s.Value == "default-store-value");
{
SettingRepository = GetRequiredService<ISettingRepository>();
TestData = GetRequiredService<SettingTestData>();
}
[Fact]
public async Task FindAsync()
{
(await SettingRepository.FindAsync(
"MySetting1",
GlobalSettingValueProvider.ProviderName,
null
)).Value.ShouldBe("42");
(await SettingRepository.FindAsync(
"MySetting2",
UserSettingValueProvider.ProviderName,
TestData.User1Id.ToString()
)).Value.ShouldBe("user1-store-value");
(await SettingRepository.FindAsync(
"Undefined-Setting",
GlobalSettingValueProvider.ProviderName,
null
)).ShouldBeNull();
}
[Fact]
public async Task GetListAsync()
{
var settings = await SettingRepository.GetListAsync(GlobalSettingValueProvider.ProviderName, null);
settings.Any().ShouldBeTrue();
settings.ShouldContain(s => s.Name == "MySetting1" && s.Value == "42");
settings.ShouldContain(s => s.Name == "MySetting2" && s.Value == "default-store-value");
}
[Fact]
public async Task GetList_With_Names()
{
var settings = await SettingRepository.GetListAsync(new []{"MySetting1", "MySetting2"} ,GlobalSettingValueProvider.ProviderName, null);
settings.Any().ShouldBeTrue();
settings.ShouldContain(s => s.Name == "MySetting1" && s.Value == "42");
settings.ShouldContain(s => s.Name == "MySetting2" && s.Value == "default-store-value");
}
} }
} }

15
modules/setting-management/test/Volo.Abp.SettingManagement.TestBase/Volo/Abp/SettingManagement/SettingTestData.cs

@ -1,13 +1,12 @@
using System; using System;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
public class SettingTestData : ISingletonDependency
{ {
public class SettingTestData : ISingletonDependency public Guid User1Id { get; } = Guid.NewGuid();
{ public Guid User2Id { get; } = Guid.NewGuid();
public Guid User1Id { get; } = Guid.NewGuid();
public Guid User2Id { get; } = Guid.NewGuid();
public Guid SettingId { get; } = Guid.NewGuid(); public Guid SettingId { get; } = Guid.NewGuid();
} }
}

139
modules/setting-management/test/Volo.Abp.SettingManagement.TestBase/Volo/Abp/SettingManagement/SettingTestDataBuilder.cs

@ -3,82 +3,81 @@ using Volo.Abp.DependencyInjection;
using Volo.Abp.Guids; using Volo.Abp.Guids;
using Volo.Abp.Settings; using Volo.Abp.Settings;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
public class SettingTestDataBuilder : ITransientDependency
{ {
public class SettingTestDataBuilder : ITransientDependency private readonly ISettingRepository _settingRepository;
{ private readonly IGuidGenerator _guidGenerator;
private readonly ISettingRepository _settingRepository; private readonly SettingTestData _testData;
private readonly IGuidGenerator _guidGenerator;
private readonly SettingTestData _testData;
public SettingTestDataBuilder( public SettingTestDataBuilder(
ISettingRepository settingRepository, ISettingRepository settingRepository,
IGuidGenerator guidGenerator, IGuidGenerator guidGenerator,
SettingTestData testData) SettingTestData testData)
{ {
_settingRepository = settingRepository; _settingRepository = settingRepository;
_guidGenerator = guidGenerator; _guidGenerator = guidGenerator;
_testData = testData; _testData = testData;
} }
public async Task BuildAsync() public async Task BuildAsync()
{ {
await _settingRepository.InsertAsync( await _settingRepository.InsertAsync(
new Setting( new Setting(
_testData.SettingId, _testData.SettingId,
"MySetting1", "MySetting1",
"42", "42",
GlobalSettingValueProvider.ProviderName GlobalSettingValueProvider.ProviderName
) )
); );
await _settingRepository.InsertAsync( await _settingRepository.InsertAsync(
new Setting( new Setting(
_guidGenerator.Create(), _guidGenerator.Create(),
"MySetting2", "MySetting2",
"default-store-value", "default-store-value",
GlobalSettingValueProvider.ProviderName GlobalSettingValueProvider.ProviderName
) )
); );
await _settingRepository.InsertAsync( await _settingRepository.InsertAsync(
new Setting( new Setting(
_guidGenerator.Create(), _guidGenerator.Create(),
"MySetting2", "MySetting2",
"user1-store-value", "user1-store-value",
UserSettingValueProvider.ProviderName, UserSettingValueProvider.ProviderName,
_testData.User1Id.ToString() _testData.User1Id.ToString()
) )
); );
await _settingRepository.InsertAsync( await _settingRepository.InsertAsync(
new Setting( new Setting(
_guidGenerator.Create(), _guidGenerator.Create(),
"MySetting2", "MySetting2",
"user2-store-value", "user2-store-value",
UserSettingValueProvider.ProviderName, UserSettingValueProvider.ProviderName,
_testData.User2Id.ToString() _testData.User2Id.ToString()
) )
); );
await _settingRepository.InsertAsync( await _settingRepository.InsertAsync(
new Setting( new Setting(
_guidGenerator.Create(), _guidGenerator.Create(),
"MySettingWithoutInherit", "MySettingWithoutInherit",
"default-store-value", "default-store-value",
GlobalSettingValueProvider.ProviderName GlobalSettingValueProvider.ProviderName
) )
); );
await _settingRepository.InsertAsync( await _settingRepository.InsertAsync(
new Setting( new Setting(
_guidGenerator.Create(), _guidGenerator.Create(),
"MySettingWithoutInherit", "MySettingWithoutInherit",
"user1-store-value", "user1-store-value",
UserSettingValueProvider.ProviderName, UserSettingValueProvider.ProviderName,
_testData.User1Id.ToString() _testData.User1Id.ToString()
) )
); );
}
} }
} }

23
modules/setting-management/test/Volo.Abp.SettingManagement.TestBase/Volo/Abp/SettingManagement/TestSettingDefinitionProvider.cs

@ -1,18 +1,17 @@
using Volo.Abp.Settings; using Volo.Abp.Settings;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
public class TestSettingDefinitionProvider : SettingDefinitionProvider
{ {
public class TestSettingDefinitionProvider : SettingDefinitionProvider public override void Define(ISettingDefinitionContext context)
{ {
public override void Define(ISettingDefinitionContext context) context.Add(new SettingDefinition("MySetting1"));
{ context.Add(new SettingDefinition("MySetting2"));
context.Add(new SettingDefinition("MySetting1")); context.Add(new SettingDefinition("MySetting3", "123"));
context.Add(new SettingDefinition("MySetting2")); context.Add(new SettingDefinition("MySettingWithoutInherit", isInherited: false));
context.Add(new SettingDefinition("MySetting3", "123")); context.Add(new SettingDefinition("SettingNotSetInStore", defaultValue: "default-value"));
context.Add(new SettingDefinition("MySettingWithoutInherit", isInherited: false));
context.Add(new SettingDefinition("SettingNotSetInStore", defaultValue: "default-value"));
}
} }
} }

15
modules/setting-management/test/Volo.Abp.SettingManagement.Tests/Volo/Abp/SettingManagement/AbpSettingManagementTestModule.cs

@ -2,13 +2,12 @@
using Volo.Abp.SettingManagement.EntityFrameworkCore; using Volo.Abp.SettingManagement.EntityFrameworkCore;
using Volo.Abp.Users; using Volo.Abp.Users;
namespace Volo.Abp.SettingManagement namespace Volo.Abp.SettingManagement;
[DependsOn(
typeof(AbpSettingManagementEntityFrameworkCoreTestModule),
typeof(AbpUsersAbstractionModule))]
public class AbpSettingManagementTestModule : AbpModule //TODO: Rename to Volo.Abp.SettingManagement.Domain.Tests..?
{ {
[DependsOn(
typeof(AbpSettingManagementEntityFrameworkCoreTestModule),
typeof(AbpUsersAbstractionModule))]
public class AbpSettingManagementTestModule : AbpModule //TODO: Rename to Volo.Abp.SettingManagement.Domain.Tests..?
{
}
} }

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save