- @if (string.Equals(await SettingManager.GetOrNullAsync(AccountSettingNames.IsSelfRegistrationEnabled), "true", StringComparison.OrdinalIgnoreCase))
+ @if (string.Equals(await SettingProvider.GetOrNullAsync(AccountSettingNames.IsSelfRegistrationEnabled), "true", StringComparison.OrdinalIgnoreCase))
{
@L["Register"]
}
diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml.cs b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml.cs
index 67a1934eba..d5ffdefd88 100644
--- a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml.cs
+++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml.cs
@@ -48,7 +48,7 @@ namespace Volo.Abp.Account.Web.Pages.Account
protected virtual async Task CheckSelfRegistrationAsync()
{
- if (!await SettingManager.IsTrueAsync(AccountSettingNames.IsSelfRegistrationEnabled))
+ if (!await SettingProvider.IsTrueAsync(AccountSettingNames.IsSelfRegistrationEnabled))
{
throw new UserFriendlyException(L["SelfRegistrationDisabledMessage"]);
}
diff --git a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/ProfileAppService.cs b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/ProfileAppService.cs
index 5152738794..a47734cd0c 100644
--- a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/ProfileAppService.cs
+++ b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/ProfileAppService.cs
@@ -28,12 +28,12 @@ namespace Volo.Abp.Identity
{
var user = await _userManager.GetByIdAsync(CurrentUser.GetId());
- if (await SettingManager.IsTrueAsync(IdentitySettingNames.User.IsUserNameUpdateEnabled))
+ if (await SettingProvider.IsTrueAsync(IdentitySettingNames.User.IsUserNameUpdateEnabled))
{
(await _userManager.SetUserNameAsync(user, input.UserName)).CheckErrors();
}
- if (await SettingManager.IsTrueAsync(IdentitySettingNames.User.IsEmailUpdateEnabled))
+ if (await SettingProvider.IsTrueAsync(IdentitySettingNames.User.IsEmailUpdateEnabled))
{
(await _userManager.SetEmailAsync(user, input.Email)).CheckErrors();
}
diff --git a/modules/identity/src/Volo.Abp.Identity.Domain/Volo.Abp.Identity.Domain.csproj b/modules/identity/src/Volo.Abp.Identity.Domain/Volo.Abp.Identity.Domain.csproj
index 2d7948e20d..733c9195c6 100644
--- a/modules/identity/src/Volo.Abp.Identity.Domain/Volo.Abp.Identity.Domain.csproj
+++ b/modules/identity/src/Volo.Abp.Identity.Domain/Volo.Abp.Identity.Domain.csproj
@@ -23,6 +23,8 @@
+
+
diff --git a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityOptionsFactory.cs b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityOptionsFactory.cs
index 2dce5cdfee..f35f84b027 100644
--- a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityOptionsFactory.cs
+++ b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityOptionsFactory.cs
@@ -10,15 +10,15 @@ namespace Volo.Abp.Identity
{
public class AbpIdentityOptionsFactory : AbpOptionsFactory
{
- private readonly ISettingManager _settingManager;
+ private readonly ISettingProvider _settingProvider;
public AbpIdentityOptionsFactory(
IEnumerable> setups,
IEnumerable> postConfigures,
- ISettingManager settingManager)
+ ISettingProvider settingProvider)
: base(setups, postConfigures)
{
- _settingManager = settingManager;
+ _settingProvider = settingProvider;
}
public override IdentityOptions Create(string name)
@@ -32,19 +32,20 @@ namespace Volo.Abp.Identity
protected virtual void OverrideOptions(IdentityOptions options)
{
- options.Password.RequiredLength = _settingManager.Get(IdentitySettingNames.Password.RequiredLength, options.Password.RequiredLength);
- options.Password.RequiredUniqueChars = _settingManager.Get(IdentitySettingNames.Password.RequiredUniqueChars, options.Password.RequiredUniqueChars);
- options.Password.RequireNonAlphanumeric = _settingManager.Get(IdentitySettingNames.Password.RequireNonAlphanumeric, options.Password.RequireNonAlphanumeric);
- options.Password.RequireLowercase = _settingManager.Get(IdentitySettingNames.Password.RequireLowercase, options.Password.RequireLowercase);
- options.Password.RequireUppercase = _settingManager.Get(IdentitySettingNames.Password.RequireUppercase, options.Password.RequireUppercase);
- options.Password.RequireDigit = _settingManager.Get(IdentitySettingNames.Password.RequireDigit, options.Password.RequireDigit);
-
- options.Lockout.AllowedForNewUsers = _settingManager.Get(IdentitySettingNames.Lockout.AllowedForNewUsers, options.Lockout.AllowedForNewUsers);
- options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromSeconds(_settingManager.Get(IdentitySettingNames.Lockout.LockoutDuration, options.Lockout.DefaultLockoutTimeSpan.TotalSeconds.To()));
- options.Lockout.MaxFailedAccessAttempts = _settingManager.Get(IdentitySettingNames.Lockout.MaxFailedAccessAttempts, options.Lockout.MaxFailedAccessAttempts);
-
- options.SignIn.RequireConfirmedEmail = _settingManager.Get(IdentitySettingNames.SignIn.RequireConfirmedEmail, options.SignIn.RequireConfirmedEmail);
- options.SignIn.RequireConfirmedPhoneNumber = _settingManager.Get(IdentitySettingNames.SignIn.RequireConfirmedPhoneNumber, options.SignIn.RequireConfirmedPhoneNumber);
+
+ options.Password.RequiredLength = _settingProvider.Get(IdentitySettingNames.Password.RequiredLength, options.Password.RequiredLength);
+ options.Password.RequiredUniqueChars = _settingProvider.Get(IdentitySettingNames.Password.RequiredUniqueChars, options.Password.RequiredUniqueChars);
+ options.Password.RequireNonAlphanumeric = _settingProvider.Get(IdentitySettingNames.Password.RequireNonAlphanumeric, options.Password.RequireNonAlphanumeric);
+ options.Password.RequireLowercase = _settingProvider.Get(IdentitySettingNames.Password.RequireLowercase, options.Password.RequireLowercase);
+ options.Password.RequireUppercase = _settingProvider.Get(IdentitySettingNames.Password.RequireUppercase, options.Password.RequireUppercase);
+ options.Password.RequireDigit = _settingProvider.Get(IdentitySettingNames.Password.RequireDigit, options.Password.RequireDigit);
+
+ options.Lockout.AllowedForNewUsers = _settingProvider.Get(IdentitySettingNames.Lockout.AllowedForNewUsers, options.Lockout.AllowedForNewUsers);
+ options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromSeconds(_settingProvider.Get(IdentitySettingNames.Lockout.LockoutDuration, options.Lockout.DefaultLockoutTimeSpan.TotalSeconds.To()));
+ options.Lockout.MaxFailedAccessAttempts = _settingProvider.Get(IdentitySettingNames.Lockout.MaxFailedAccessAttempts, options.Lockout.MaxFailedAccessAttempts);
+
+ options.SignIn.RequireConfirmedEmail = _settingProvider.Get(IdentitySettingNames.SignIn.RequireConfirmedEmail, options.SignIn.RequireConfirmedEmail);
+ options.SignIn.RequireConfirmedPhoneNumber = _settingProvider.Get(IdentitySettingNames.SignIn.RequireConfirmedPhoneNumber, options.SignIn.RequireConfirmedPhoneNumber);
}
}
}
\ No newline at end of file
diff --git a/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/IdentityOptions_Tests.cs b/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/IdentityOptions_Tests.cs
index f65ac22021..e48e2171b9 100644
--- a/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/IdentityOptions_Tests.cs
+++ b/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/IdentityOptions_Tests.cs
@@ -13,13 +13,13 @@ namespace Volo.Abp.Identity
{
public class IdentityOptions_Tests : AbpIdentityDomainTestBase
{
- private ISettingManager _settingManager;
+ private ISettingProvider _settingProvider;
protected override void AfterAddApplication(IServiceCollection services)
{
- _settingManager = Substitute.For();
- _settingManager.GetOrNullAsync(Arg.Any()).Returns((string) null);
- services.Replace(ServiceDescriptor.Singleton(_settingManager));
+ _settingProvider = Substitute.For();
+ _settingProvider.GetOrNullAsync(Arg.Any()).Returns((string) null);
+ services.Replace(ServiceDescriptor.Singleton(_settingProvider));
}
[Fact]
@@ -38,7 +38,7 @@ namespace Volo.Abp.Identity
options.Password.RequiredUniqueChars.ShouldBe(1); //Default value
}
- _settingManager.GetOrNullAsync(IdentitySettingNames.Password.RequiredLength).Returns(Task.FromResult("42"));
+ _settingProvider.GetOrNullAsync(IdentitySettingNames.Password.RequiredLength).Returns(Task.FromResult("42"));
using (var scope2 = ServiceProvider.CreateScope())
{
diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/AbpIdentityServerMongoDbModule.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/AbpIdentityServerMongoDbModule.cs
index 7aa5bdecb8..1076d19ecf 100644
--- a/modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/AbpIdentityServerMongoDbModule.cs
+++ b/modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/AbpIdentityServerMongoDbModule.cs
@@ -31,7 +31,7 @@ namespace Volo.Abp.IdentityServer.MongoDB
options.AddRepository();
options.AddRepository();
options.AddRepository();
- options.AddRepository();
+ options.AddRepository();
});
}
}
diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoPersistedGrantRepository.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoPersistedGrantRepository.cs
index b85d3d3e06..6a3248b9db 100644
--- a/modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoPersistedGrantRepository.cs
+++ b/modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoPersistedGrantRepository.cs
@@ -10,9 +10,9 @@ using Volo.Abp.MongoDB;
namespace Volo.Abp.IdentityServer.MongoDB
{
- public class MongoPersistedGrantRepository : MongoDbRepository, IPersistentGrantRepository
+ public class MongoPersistentGrantRepository : MongoDbRepository, IPersistentGrantRepository
{
- public MongoPersistedGrantRepository(IMongoDbContextProvider dbContextProvider) : base(dbContextProvider)
+ public MongoPersistentGrantRepository(IMongoDbContextProvider dbContextProvider) : base(dbContextProvider)
{
}
diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain.Shared/Volo.Abp.PermissionManagement.Domain.Shared.csproj b/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain.Shared/Volo.Abp.PermissionManagement.Domain.Shared.csproj
index 81362ed9a1..d922ef7357 100644
--- a/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain.Shared/Volo.Abp.PermissionManagement.Domain.Shared.csproj
+++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain.Shared/Volo.Abp.PermissionManagement.Domain.Shared.csproj
@@ -1,4 +1,4 @@
-
+
@@ -14,7 +14,7 @@
-
+
diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain.Shared/Volo/Abp/PermissionManagement/AbpPermissionManagementDomainSharedModule.cs b/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain.Shared/Volo/Abp/PermissionManagement/AbpPermissionManagementDomainSharedModule.cs
index f4c1c07e21..d7bafccea8 100644
--- a/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain.Shared/Volo/Abp/PermissionManagement/AbpPermissionManagementDomainSharedModule.cs
+++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain.Shared/Volo/Abp/PermissionManagement/AbpPermissionManagementDomainSharedModule.cs
@@ -1,9 +1,21 @@
-using Volo.Abp.Modularity;
+using Volo.Abp.Localization;
+using Volo.Abp.Modularity;
+using Volo.Abp.PermissionManagement.Localization;
namespace Volo.Abp.PermissionManagement
{
+ [DependsOn(
+ typeof(AbpLocalizationModule)
+ )]
public class AbpPermissionManagementDomainSharedModule : AbpModule
{
-
+ public override void ConfigureServices(ServiceConfigurationContext context)
+ {
+ Configure(options =>
+ {
+ options.Resources
+ .Add("en");
+ });
+ }
}
}
diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain.Shared/Volo/Abp/PermissionManagement/Localization/AbpPermissionManagementResource.cs b/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain.Shared/Volo/Abp/PermissionManagement/Localization/AbpPermissionManagementResource.cs
new file mode 100644
index 0000000000..7b54011d84
--- /dev/null
+++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain.Shared/Volo/Abp/PermissionManagement/Localization/AbpPermissionManagementResource.cs
@@ -0,0 +1,10 @@
+using Volo.Abp.Localization;
+
+namespace Volo.Abp.PermissionManagement.Localization
+{
+ [LocalizationResourceName("AbpPermissionManagement")]
+ public class AbpPermissionManagementResource
+ {
+
+ }
+}
diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/IPermissionManagementProvider.cs b/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/IPermissionManagementProvider.cs
index b765b1360a..9ee60b0a93 100644
--- a/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/IPermissionManagementProvider.cs
+++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/IPermissionManagementProvider.cs
@@ -5,7 +5,7 @@ using Volo.Abp.DependencyInjection;
namespace Volo.Abp.PermissionManagement
{
- public interface IPermissionManagementProvider : ISingletonDependency
+ public interface IPermissionManagementProvider : ISingletonDependency //TODO: Consider to remove this pre-assumption
{
string Name { get; }
diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionManagementOptions.cs b/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionManagementOptions.cs
index 2e29ab9c29..674f5daa88 100644
--- a/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionManagementOptions.cs
+++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionManagementOptions.cs
@@ -5,6 +5,7 @@ namespace Volo.Abp.PermissionManagement
{
public class PermissionManagementOptions
{
+ //TODO: rename to Providers
public ITypeList ManagementProviders { get; }
public Dictionary ProviderPolicies { get; }
diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.Web/AbpPermissionManagementWebModule.cs b/modules/permission-management/src/Volo.Abp.PermissionManagement.Web/AbpPermissionManagementWebModule.cs
index 37c331b40d..e42f2523ac 100644
--- a/modules/permission-management/src/Volo.Abp.PermissionManagement.Web/AbpPermissionManagementWebModule.cs
+++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.Web/AbpPermissionManagementWebModule.cs
@@ -1,11 +1,13 @@
-using Microsoft.Extensions.DependencyInjection;
+using Localization.Resources.AbpUi;
+using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AspNetCore.Mvc.Localization;
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap;
using Volo.Abp.AutoMapper;
using Volo.Abp.Localization;
+using Volo.Abp.Localization.Resources.AbpValidation;
using Volo.Abp.Modularity;
using Volo.Abp.PermissionManagement.HttpApi;
-using Volo.Abp.PermissionManagement.Web.Localization.Resources.AbpPermissionManagement;
+using Volo.Abp.PermissionManagement.Localization;
using Volo.Abp.VirtualFileSystem;
namespace Volo.Abp.PermissionManagement.Web
@@ -33,8 +35,11 @@ namespace Volo.Abp.PermissionManagement.Web
Configure(options =>
{
options.Resources
- .Add("en")
- .AddVirtualJson("/Localization/Resources/AbpPermissionManagement");
+ .Get()
+ .AddBaseTypes(
+ typeof(AbpValidationResource),
+ typeof(AbpUiResource)
+ ).AddVirtualJson("/Localization/Resources/AbpPermissionManagement");
});
Configure(options =>
diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.Web/Localization/Resources/AbpPermissionManagement/AbpPermissionManagementResource.cs b/modules/permission-management/src/Volo.Abp.PermissionManagement.Web/Localization/Resources/AbpPermissionManagement/AbpPermissionManagementResource.cs
deleted file mode 100644
index 648423ce5a..0000000000
--- a/modules/permission-management/src/Volo.Abp.PermissionManagement.Web/Localization/Resources/AbpPermissionManagement/AbpPermissionManagementResource.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using Localization.Resources.AbpUi;
-using Volo.Abp.Localization;
-using Volo.Abp.Localization.Resources.AbpValidation;
-
-namespace Volo.Abp.PermissionManagement.Web.Localization.Resources.AbpPermissionManagement
-{
- [InheritResource(
- typeof(AbpValidationResource),
- typeof(AbpUiResource))]
- [LocalizationResourceName("AbpPermissionManagement")]
- public class AbpPermissionManagementResource
- {
-
- }
-}
diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.Web/Pages/AbpPermissionManagement/PermissionManagementModal.cshtml b/modules/permission-management/src/Volo.Abp.PermissionManagement.Web/Pages/AbpPermissionManagement/PermissionManagementModal.cshtml
index 010676bdf8..a2bc020495 100644
--- a/modules/permission-management/src/Volo.Abp.PermissionManagement.Web/Pages/AbpPermissionManagement/PermissionManagementModal.cshtml
+++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.Web/Pages/AbpPermissionManagement/PermissionManagementModal.cshtml
@@ -1,7 +1,7 @@
@page
@using Microsoft.AspNetCore.Mvc.Localization
@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal
-@using Volo.Abp.PermissionManagement.Web.Localization.Resources.AbpPermissionManagement
+@using Volo.Abp.PermissionManagement.Localization
@using Volo.Abp.PermissionManagement.Web.Pages.AbpPermissionManagement
@model PermissionManagementModal
@inject IHtmlLocalizer L
diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/AbpSettingManagementDomainModule.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/AbpSettingManagementDomainModule.cs
index 0ddc49b076..237b226b07 100644
--- a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/AbpSettingManagementDomainModule.cs
+++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/AbpSettingManagementDomainModule.cs
@@ -13,6 +13,15 @@ namespace Volo.Abp.SettingManagement
)]
public class AbpSettingManagementDomainModule : AbpModule
{
-
+ public override void ConfigureServices(ServiceConfigurationContext context)
+ {
+ Configure(options =>
+ {
+ options.Providers.Add();
+ options.Providers.Add();
+ options.Providers.Add();
+ options.Providers.Add();
+ });
+ }
}
}
diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/DefaultValueSettingManagementProvider.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/DefaultValueSettingManagementProvider.cs
new file mode 100644
index 0000000000..3bb4ae2655
--- /dev/null
+++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/DefaultValueSettingManagementProvider.cs
@@ -0,0 +1,26 @@
+using System.Threading.Tasks;
+using Volo.Abp.DependencyInjection;
+using Volo.Abp.Settings;
+
+namespace Volo.Abp.SettingManagement
+{
+ public class DefaultValueSettingManagementProvider : ISettingManagementProvider, ISingletonDependency
+ {
+ public string Name => DefaultValueSettingValueProvider.ProviderName;
+
+ public Task GetOrNullAsync(SettingDefinition setting, string providerKey)
+ {
+ return Task.FromResult(setting.DefaultValue);
+ }
+
+ public 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.");
+ }
+
+ public 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.");
+ }
+ }
+}
\ No newline at end of file
diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/DefaultValueSettingManagerExtensions.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/DefaultValueSettingManagerExtensions.cs
new file mode 100644
index 0000000000..20ad176ecc
--- /dev/null
+++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/DefaultValueSettingManagerExtensions.cs
@@ -0,0 +1,20 @@
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using JetBrains.Annotations;
+using Volo.Abp.Settings;
+
+namespace Volo.Abp.SettingManagement
+{
+ public static class DefaultValueSettingManagerExtensions
+ {
+ public static Task GetOrNullDefaultAsync(this ISettingManager settingManager, [NotNull] string name, bool fallback = true)
+ {
+ return settingManager.GetOrNullAsync(name, DefaultValueSettingValueProvider.ProviderName, null, fallback);
+ }
+
+ public static Task> GetAllDefaultAsync(this ISettingManager settingManager, bool fallback = true)
+ {
+ return settingManager.GetAllAsync(DefaultValueSettingValueProvider.ProviderName, null, fallback);
+ }
+ }
+}
\ No newline at end of file
diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/GlobalSettingManagementProvider.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/GlobalSettingManagementProvider.cs
new file mode 100644
index 0000000000..85201eb39a
--- /dev/null
+++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/GlobalSettingManagementProvider.cs
@@ -0,0 +1,21 @@
+using Volo.Abp.DependencyInjection;
+using Volo.Abp.Settings;
+
+namespace Volo.Abp.SettingManagement
+{
+ public class GlobalSettingManagementProvider : SettingManagementProvider, ITransientDependency
+ {
+ public override string Name => GlobalSettingValueProvider.ProviderName;
+
+ public GlobalSettingManagementProvider(ISettingManagementStore settingManagementStore)
+ : base(settingManagementStore)
+ {
+
+ }
+
+ protected override string NormalizeProviderKey(string providerKey)
+ {
+ return null;
+ }
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/GlobalSettingManagerExtensions.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/GlobalSettingManagerExtensions.cs
similarity index 93%
rename from framework/src/Volo.Abp.Settings/Volo/Abp/Settings/GlobalSettingManagerExtensions.cs
rename to modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/GlobalSettingManagerExtensions.cs
index d5dabccfe8..e403eb41a3 100644
--- a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/GlobalSettingManagerExtensions.cs
+++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/GlobalSettingManagerExtensions.cs
@@ -1,8 +1,9 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using JetBrains.Annotations;
+using Volo.Abp.Settings;
-namespace Volo.Abp.Settings
+namespace Volo.Abp.SettingManagement
{
public static class GlobalSettingManagerExtensions
{
diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/ISettingManagementProvider.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/ISettingManagementProvider.cs
new file mode 100644
index 0000000000..827b0ff851
--- /dev/null
+++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/ISettingManagementProvider.cs
@@ -0,0 +1,17 @@
+using System.Threading.Tasks;
+using JetBrains.Annotations;
+using Volo.Abp.Settings;
+
+namespace Volo.Abp.SettingManagement
+{
+ public interface ISettingManagementProvider
+ {
+ string Name { get; }
+
+ Task GetOrNullAsync([NotNull] SettingDefinition setting, [CanBeNull] string providerKey);
+
+ Task SetAsync([NotNull] SettingDefinition setting, [NotNull] string value, [CanBeNull] string providerKey);
+
+ Task ClearAsync([NotNull] SettingDefinition setting, [CanBeNull] string providerKey);
+ }
+}
diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/ISettingManagementStore.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/ISettingManagementStore.cs
new file mode 100644
index 0000000000..eebdc69357
--- /dev/null
+++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/ISettingManagementStore.cs
@@ -0,0 +1,17 @@
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using Volo.Abp.Settings;
+
+namespace Volo.Abp.SettingManagement
+{
+ public interface ISettingManagementStore
+ {
+ Task GetOrNullAsync(string name, string providerName, string providerKey);
+
+ Task> GetListAsync(string providerName, string providerKey);
+
+ Task SetAsync(string name, string value, string providerName, string providerKey);
+
+ Task DeleteAsync(string name, string providerName, string providerKey);
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/ISettingManager.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/ISettingManager.cs
similarity index 80%
rename from framework/src/Volo.Abp.Settings/Volo/Abp/Settings/ISettingManager.cs
rename to modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/ISettingManager.cs
index 9c794a2c9b..77ae59e664 100644
--- a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/ISettingManager.cs
+++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/ISettingManager.cs
@@ -1,17 +1,14 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using JetBrains.Annotations;
+using Volo.Abp.Settings;
-namespace Volo.Abp.Settings
+namespace Volo.Abp.SettingManagement
{
public interface ISettingManager
{
- Task GetOrNullAsync([NotNull]string name);
-
Task GetOrNullAsync([NotNull]string name, [NotNull] string providerName, [CanBeNull] string providerKey, bool fallback = true);
- Task> GetAllAsync();
-
Task> 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);
diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/SettingManagementOptions.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/SettingManagementOptions.cs
new file mode 100644
index 0000000000..06ced8e8a8
--- /dev/null
+++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/SettingManagementOptions.cs
@@ -0,0 +1,14 @@
+using Volo.Abp.Collections;
+
+namespace Volo.Abp.SettingManagement
+{
+ public class SettingManagementOptions
+ {
+ public ITypeList Providers { get; }
+
+ public SettingManagementOptions()
+ {
+ Providers = new TypeList();
+ }
+ }
+}
diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/SettingManagementProvider.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/SettingManagementProvider.cs
new file mode 100644
index 0000000000..d350cc28d7
--- /dev/null
+++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/SettingManagementProvider.cs
@@ -0,0 +1,37 @@
+using System.Threading.Tasks;
+using Volo.Abp.Settings;
+
+namespace Volo.Abp.SettingManagement
+{
+ public abstract class SettingManagementProvider : ISettingManagementProvider
+ {
+ public abstract string Name { get; }
+
+ protected ISettingManagementStore SettingManagementStore { get; }
+
+ protected SettingManagementProvider(ISettingManagementStore settingManagementStore)
+ {
+ SettingManagementStore = settingManagementStore;
+ }
+
+ public async Task 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;
+ }
+ }
+}
\ No newline at end of file
diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/SettingManagementStore.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/SettingManagementStore.cs
new file mode 100644
index 0000000000..8c9cfc8684
--- /dev/null
+++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/SettingManagementStore.cs
@@ -0,0 +1,90 @@
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Volo.Abp.Caching;
+using Volo.Abp.DependencyInjection;
+using Volo.Abp.Guids;
+using Volo.Abp.Settings;
+
+namespace Volo.Abp.SettingManagement
+{
+ public class SettingManagementStore : ISettingManagementStore, ITransientDependency
+ {
+ protected IDistributedCache Cache { get; }
+ protected ISettingRepository SettingRepository { get; }
+ protected IGuidGenerator GuidGenerator { get; }
+
+ public SettingManagementStore(
+ ISettingRepository settingRepository,
+ IGuidGenerator guidGenerator,
+ IDistributedCache cache)
+ {
+ SettingRepository = settingRepository;
+ GuidGenerator = guidGenerator;
+ Cache = cache;
+ }
+
+ public async Task GetOrNullAsync(string name, string providerName, string providerKey)
+ {
+ var cacheItem = await GetCacheItemAsync(name, providerName, providerKey);
+ return cacheItem.Value;
+ }
+
+ public 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);
+ }
+ }
+
+ public async Task> GetListAsync(string providerName, string providerKey)
+ {
+ var settings = await SettingRepository.GetListAsync(providerName, providerKey);
+ return settings.Select(s => new SettingValue(s.Name, s.Value)).ToList();
+ }
+
+ public async Task DeleteAsync(string name, string providerName, string providerKey)
+ {
+ var setting = await SettingRepository.FindAsync(name, providerName, providerKey);
+ if (setting != null)
+ {
+ await SettingRepository.DeleteAsync(setting);
+ }
+ }
+
+ protected virtual async Task GetCacheItemAsync(string name, string providerName, string providerKey)
+ {
+ var cacheKey = CalculateCacheKey(name, providerName, providerKey);
+ var cacheItem = await Cache.GetAsync(cacheKey);
+
+ if (cacheItem != null)
+ {
+ return cacheItem;
+ }
+
+ var setting = await SettingRepository.FindAsync(name, providerName, providerKey);
+
+ cacheItem = new SettingCacheItem(setting?.Value);
+
+ await Cache.SetAsync(
+ cacheKey,
+ cacheItem
+ );
+
+ return cacheItem;
+ }
+
+ protected virtual string CalculateCacheKey(string name, string providerName, string providerKey)
+ {
+ return SettingCacheItem.CalculateCacheKey(name, providerName, providerKey);
+ }
+ }
+}
diff --git a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingManager.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/SettingManager.cs
similarity index 71%
rename from framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingManager.cs
rename to modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/SettingManager.cs
index 33087bab77..cfb4cccbe3 100644
--- a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingManager.cs
+++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/SettingManager.cs
@@ -5,18 +5,20 @@ using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Volo.Abp.DependencyInjection;
+using Volo.Abp.Settings;
-namespace Volo.Abp.Settings
+namespace Volo.Abp.SettingManagement
{
public class SettingManager : ISettingManager, ISingletonDependency
{
protected ISettingDefinitionManager SettingDefinitionManager { get; }
protected ISettingEncryptionService SettingEncryptionService { get; }
- protected Lazy> Providers { get; }
- protected SettingOptions Options { get; }
+ protected List Providers => _lazyProviders.Value;
+ protected SettingManagementOptions Options { get; }
+ private readonly Lazy> _lazyProviders;
public SettingManager(
- IOptions options,
+ IOptions options,
IServiceProvider serviceProvider,
ISettingDefinitionManager settingDefinitionManager,
ISettingEncryptionService settingEncryptionService)
@@ -25,22 +27,17 @@ namespace Volo.Abp.Settings
SettingEncryptionService = settingEncryptionService;
Options = options.Value;
- Providers = new Lazy>(
+ //TODO: Instead, use IHybridServiceScopeFactory and create a scope..?
+
+ _lazyProviders = new Lazy>(
() => Options
- .ValueProviders
- .Select(c => serviceProvider.GetRequiredService(c) as ISettingValueProvider)
+ .Providers
+ .Select(c => serviceProvider.GetRequiredService(c) as ISettingManagementProvider)
.ToList(),
true
);
}
-
- public virtual Task GetOrNullAsync(string name)
- {
- Check.NotNull(name, nameof(name));
-
- return GetOrNullInternalAsync(name, null, null);
- }
-
+
public virtual Task GetOrNullAsync(string name, string providerName, string providerKey, bool fallback = true)
{
Check.NotNull(name, nameof(name));
@@ -49,37 +46,12 @@ namespace Volo.Abp.Settings
return GetOrNullInternalAsync(name, providerName, providerKey, fallback);
}
- public virtual async Task> GetAllAsync()
- {
- var settingValues = new Dictionary();
- var settingDefinitions = SettingDefinitionManager.GetAll();
-
- foreach (var provider in Providers.Value)
- {
- foreach (var setting in settingDefinitions)
- {
- var value = await provider.GetOrNullAsync(setting, null);
- if (value != null)
- {
- if (setting.IsEncrypted)
- {
- value = SettingEncryptionService.Decrypt(setting, value);
- }
-
- settingValues[setting.Name] = new SettingValue(setting.Name, value);
- }
- }
- }
-
- return settingValues.Values.ToList();
- }
-
public virtual async Task> GetAllAsync(string providerName, string providerKey, bool fallback = true)
{
Check.NotNull(providerName, nameof(providerName));
var settingDefinitions = SettingDefinitionManager.GetAll();
- var providers = Enumerable.Reverse(Providers.Value)
+ var providers = Enumerable.Reverse(Providers)
.SkipWhile(c => c.Name != providerName);
if (!fallback)
@@ -104,7 +76,10 @@ namespace Volo.Abp.Settings
{
foreach (var provider in providerList)
{
- var providerValue = await provider.GetOrNullAsync(setting, providerKey);
+ var providerValue = await provider.GetOrNullAsync(
+ setting,
+ provider.Name == providerName ? providerKey : null
+ );
if (providerValue != null)
{
value = providerValue;
@@ -113,7 +88,10 @@ namespace Volo.Abp.Settings
}
else
{
- value = await providerList[0].GetOrNullAsync(setting, providerKey);
+ value = await providerList[0].GetOrNullAsync(
+ setting,
+ providerKey
+ );
}
if (setting.IsEncrypted)
@@ -138,7 +116,7 @@ namespace Volo.Abp.Settings
var setting = SettingDefinitionManager.Get(name);
var providers = Enumerable
- .Reverse(Providers.Value)
+ .Reverse(Providers)
.SkipWhile(p => p.Name != providerName)
.ToList();
@@ -154,10 +132,10 @@ namespace Volo.Abp.Settings
if (providers.Count > 1 && !forceToSet && setting.IsInherited && value != null)
{
- //Clear the value if it's same as it's fallback value
- var fallbackValue = await GetOrNullInternalAsync(name, providers[1].Name, providerKey);
+ var fallbackValue = await GetOrNullInternalAsync(name, providers[1].Name, null);
if (fallbackValue == value)
{
+ //Clear the value if it's same as it's fallback value
value = null;
}
}
@@ -186,7 +164,7 @@ namespace Volo.Abp.Settings
{
var setting = SettingDefinitionManager.Get(name);
var providers = Enumerable
- .Reverse(Providers.Value);
+ .Reverse(Providers);
if (providerName != null)
{
@@ -198,30 +176,26 @@ namespace Volo.Abp.Settings
providers = providers.TakeWhile(c => c.Name == providerName);
}
- var value = await GetOrNullValueFromProvidersAsync(providerKey, providers, setting);
- if (setting.IsEncrypted)
- {
- value = SettingEncryptionService.Decrypt(setting, value);
- }
-
- return value;
- }
-
- protected virtual async Task GetOrNullValueFromProvidersAsync(
- string providerKey,
- IEnumerable providers,
- SettingDefinition setting)
- {
+ string value = null;
foreach (var provider in providers)
{
- var value = await provider.GetOrNullAsync(setting, providerKey);
+ value = await provider.GetOrNullAsync(
+ setting,
+ provider.Name == providerName ? providerKey : null
+ );
+
if (value != null)
{
- return value;
+ break;
}
}
- return null;
+ if (setting.IsEncrypted)
+ {
+ value = SettingEncryptionService.Decrypt(setting, value);
+ }
+
+ return value;
}
}
}
\ No newline at end of file
diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/TenantSettingManagementProvider.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/TenantSettingManagementProvider.cs
new file mode 100644
index 0000000000..947e2d8799
--- /dev/null
+++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/TenantSettingManagementProvider.cs
@@ -0,0 +1,31 @@
+using Volo.Abp.DependencyInjection;
+using Volo.Abp.MultiTenancy;
+using Volo.Abp.Settings;
+
+namespace Volo.Abp.SettingManagement
+{
+ public class TenantSettingManagementProvider : SettingManagementProvider, ITransientDependency
+ {
+ public override string Name => TenantSettingValueProvider.ProviderName;
+
+ protected ICurrentTenant CurrentTenant { get; }
+
+ public TenantSettingManagementProvider(
+ ISettingManagementStore settingManagementStore,
+ ICurrentTenant currentTenant)
+ : base(settingManagementStore)
+ {
+ CurrentTenant = currentTenant;
+ }
+
+ protected override string NormalizeProviderKey(string providerKey)
+ {
+ if (providerKey != null)
+ {
+ return providerKey;
+ }
+
+ return CurrentTenant.Id?.ToString();
+ }
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.MultiTenancy.Abstractions/Volo/Abp/Settings/TenantSettingManagerExtensions.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/TenantSettingManagerExtensions.cs
similarity index 96%
rename from framework/src/Volo.Abp.MultiTenancy.Abstractions/Volo/Abp/Settings/TenantSettingManagerExtensions.cs
rename to modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/TenantSettingManagerExtensions.cs
index f3500bf80a..f5cc345931 100644
--- a/framework/src/Volo.Abp.MultiTenancy.Abstractions/Volo/Abp/Settings/TenantSettingManagerExtensions.cs
+++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/TenantSettingManagerExtensions.cs
@@ -2,9 +2,9 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using JetBrains.Annotations;
-using Volo.Abp.MultiTenancy;
+using Volo.Abp.Settings;
-namespace Volo.Abp.Settings
+namespace Volo.Abp.SettingManagement
{
public static class TenantSettingManagerExtensions
{
diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/UserSettingManagementProvider.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/UserSettingManagementProvider.cs
new file mode 100644
index 0000000000..790e0eaa0c
--- /dev/null
+++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/UserSettingManagementProvider.cs
@@ -0,0 +1,31 @@
+using Volo.Abp.DependencyInjection;
+using Volo.Abp.Settings;
+using Volo.Abp.Users;
+
+namespace Volo.Abp.SettingManagement
+{
+ public class UserSettingManagementProvider : SettingManagementProvider, ITransientDependency
+ {
+ public override string Name => UserSettingValueProvider.ProviderName;
+
+ protected ICurrentUser CurrentUser { get; }
+
+ public UserSettingManagementProvider(
+ ISettingManagementStore settingManagementStore,
+ ICurrentUser currentUser)
+ : base(settingManagementStore)
+ {
+ CurrentUser = currentUser;
+ }
+
+ protected override string NormalizeProviderKey(string providerKey)
+ {
+ if (providerKey != null)
+ {
+ return providerKey;
+ }
+
+ return CurrentUser.Id?.ToString();
+ }
+ }
+}
\ No newline at end of file
diff --git a/modules/users/src/Volo.Abp.Users.Abstractions/Volo/Abp/Settings/UserSettingManagerExtensions.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/UserSettingManagerExtensions.cs
similarity index 96%
rename from modules/users/src/Volo.Abp.Users.Abstractions/Volo/Abp/Settings/UserSettingManagerExtensions.cs
rename to modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/UserSettingManagerExtensions.cs
index 4e3a1dd574..2b58382463 100644
--- a/modules/users/src/Volo.Abp.Users.Abstractions/Volo/Abp/Settings/UserSettingManagerExtensions.cs
+++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/UserSettingManagerExtensions.cs
@@ -2,9 +2,10 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using JetBrains.Annotations;
+using Volo.Abp.Settings;
using Volo.Abp.Users;
-namespace Volo.Abp.Settings
+namespace Volo.Abp.SettingManagement
{
//TODO: Consider to move to another package?
diff --git a/modules/setting-management/test/Volo.Abp.SettingManagement.TestBase/Volo/Abp/SettingManagement/SettingTestDataBuilder.cs b/modules/setting-management/test/Volo.Abp.SettingManagement.TestBase/Volo/Abp/SettingManagement/SettingTestDataBuilder.cs
index ce0a71b6db..79ae4702c8 100644
--- a/modules/setting-management/test/Volo.Abp.SettingManagement.TestBase/Volo/Abp/SettingManagement/SettingTestDataBuilder.cs
+++ b/modules/setting-management/test/Volo.Abp.SettingManagement.TestBase/Volo/Abp/SettingManagement/SettingTestDataBuilder.cs
@@ -22,7 +22,7 @@ namespace Volo.Abp.SettingManagement
public void Build()
{
- _settingRepository.InsertAsync(
+ _settingRepository.Insert(
new Setting(
_guidGenerator.Create(),
"MySetting1",
@@ -31,7 +31,7 @@ namespace Volo.Abp.SettingManagement
)
);
- _settingRepository.InsertAsync(
+ _settingRepository.Insert(
new Setting(
_guidGenerator.Create(),
"MySetting2",
@@ -40,7 +40,7 @@ namespace Volo.Abp.SettingManagement
)
);
- _settingRepository.InsertAsync(
+ _settingRepository.Insert(
new Setting(
_guidGenerator.Create(),
"MySetting2",
@@ -50,7 +50,7 @@ namespace Volo.Abp.SettingManagement
)
);
- _settingRepository.InsertAsync(
+ _settingRepository.Insert(
new Setting(
_guidGenerator.Create(),
"MySetting2",
@@ -60,7 +60,7 @@ namespace Volo.Abp.SettingManagement
)
);
- _settingRepository.InsertAsync(
+ _settingRepository.Insert(
new Setting(
_guidGenerator.Create(),
"MySettingWithoutInherit",
@@ -69,7 +69,7 @@ namespace Volo.Abp.SettingManagement
)
);
- _settingRepository.InsertAsync(
+ _settingRepository.Insert(
new Setting(
_guidGenerator.Create(),
"MySettingWithoutInherit",
diff --git a/modules/setting-management/test/Volo.Abp.SettingManagement.Tests/Volo/Abp/SettingManagement/SettingManager_Basic_Tests.cs b/modules/setting-management/test/Volo.Abp.SettingManagement.Tests/Volo/Abp/SettingManagement/SettingManager_Basic_Tests.cs
index 0e9543cc96..1dafc31570 100644
--- a/modules/setting-management/test/Volo.Abp.SettingManagement.Tests/Volo/Abp/SettingManagement/SettingManager_Basic_Tests.cs
+++ b/modules/setting-management/test/Volo.Abp.SettingManagement.Tests/Volo/Abp/SettingManagement/SettingManager_Basic_Tests.cs
@@ -8,37 +8,39 @@ namespace Volo.Abp.SettingManagement
public class SettingManager_Basic_Tests : SettingsTestBase
{
private readonly ISettingManager _settingManager;
+ private readonly ISettingProvider _settingProvider;
public SettingManager_Basic_Tests()
{
_settingManager = GetRequiredService();
+ _settingProvider = GetRequiredService();
}
[Fact]
public async Task Should_Throw_Exception_When_Try_To_Get_An_Undefined_Setting()
{
await Assert.ThrowsAsync(
- async () => await _settingManager.GetOrNullAsync("UndefinedSetting")
+ async () => await _settingProvider.GetOrNullAsync("UndefinedSetting")
);
}
[Fact]
public async Task Should_Get_Default_Value_If_Not_Set_In_Store()
{
- var value = await _settingManager.GetOrNullAsync("SettingNotSetInStore");
+ var value = await _settingProvider.GetOrNullAsync("SettingNotSetInStore");
value.ShouldBe("default-value");
}
[Fact]
public async Task Should_Get_Base_Store_Value()
{
- (await _settingManager.GetOrNullAsync("MySetting1")).ShouldBe("42");
+ (await _settingProvider.GetOrNullAsync("MySetting1")).ShouldBe("42");
}
[Fact]
public async Task Should_Get_All_Base_Store_Values()
{
- var settingValues = await _settingManager.GetAllAsync();
+ var settingValues = await _settingProvider.GetAllAsync();
settingValues.ShouldContain(sv => sv.Name == "MySetting1" && sv.Value == "42");
settingValues.ShouldContain(sv => sv.Name == "MySetting2" && sv.Value == "default-store-value");
settingValues.ShouldContain(sv => sv.Name == "SettingNotSetInStore" && sv.Value == "default-value");
@@ -50,7 +52,7 @@ namespace Volo.Abp.SettingManagement
await _settingManager.SetGlobalAsync("MySetting1", "43");
(await _settingManager.GetOrNullGlobalAsync("MySetting1")).ShouldBe("43");
- (await _settingManager.GetOrNullAsync("MySetting1")).ShouldBe("43");
+ (await _settingProvider.GetOrNullAsync("MySetting1")).ShouldBe("43");
}
}
}
diff --git a/modules/setting-management/test/Volo.Abp.SettingManagement.Tests/Volo/Abp/SettingManagement/SettingManager_User_Tests.cs b/modules/setting-management/test/Volo.Abp.SettingManagement.Tests/Volo/Abp/SettingManagement/SettingManager_User_Tests.cs
index 90fff7e640..4b42572f0a 100644
--- a/modules/setting-management/test/Volo.Abp.SettingManagement.Tests/Volo/Abp/SettingManagement/SettingManager_User_Tests.cs
+++ b/modules/setting-management/test/Volo.Abp.SettingManagement.Tests/Volo/Abp/SettingManagement/SettingManager_User_Tests.cs
@@ -1,25 +1,27 @@
-using System;
-using System.Linq;
-using System.Threading.Tasks;
-using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.DependencyInjection;
using NSubstitute;
using Shouldly;
+using System;
+using System.Linq;
+using System.Threading.Tasks;
using Volo.Abp.Settings;
using Volo.Abp.Users;
using Xunit;
namespace Volo.Abp.SettingManagement
{
- public class SettingManager_User_Tests: SettingsTestBase
+ public class SettingManager_User_Tests : SettingsTestBase
{
private Guid? _currentUserId;
private readonly ISettingManager _settingManager;
+ private readonly ISettingProvider _settingProvider;
private readonly SettingTestData _testData;
public SettingManager_User_Tests()
{
_settingManager = GetRequiredService();
+ _settingProvider = GetRequiredService();
_testData = GetRequiredService();
}
@@ -53,17 +55,17 @@ namespace Volo.Abp.SettingManagement
public async Task Should_Get_From_Store_For_Current_User()
{
_currentUserId = _testData.User1Id;
- (await _settingManager.GetOrNullAsync("MySetting2")).ShouldBe("user1-store-value");
+ (await _settingProvider.GetOrNullAsync("MySetting2")).ShouldBe("user1-store-value");
_currentUserId = _testData.User2Id;
- (await _settingManager.GetOrNullAsync("MySetting2")).ShouldBe("user2-store-value");
+ (await _settingProvider.GetOrNullAsync("MySetting2")).ShouldBe("user2-store-value");
}
[Fact]
public async Task Should_Fallback_To_Default_Store_Value_When_No_Value_For_Current_User()
{
_currentUserId = Guid.NewGuid();
- (await _settingManager.GetOrNullAsync("MySetting2")).ShouldBe("default-store-value");
+ (await _settingProvider.GetOrNullAsync("MySetting2")).ShouldBe("default-store-value");
}
[Fact]
@@ -80,7 +82,7 @@ namespace Volo.Abp.SettingManagement
public async Task Should_Fallback_To_Default_Store_Value_When_No_Value_For_Current_User_With_GetOrNullForCurrentUserAsync()
{
_currentUserId = Guid.NewGuid();
- (await _settingManager.GetOrNullAsync("MySetting2")).ShouldBe("default-store-value");
+ (await _settingProvider.GetOrNullAsync("MySetting2")).ShouldBe("default-store-value");
}
[Fact]
diff --git a/modules/users/src/Volo.Abp.Users.Abstractions/Volo/Abp/Users/AbpUsersAbstractionModule.cs b/modules/users/src/Volo.Abp.Users.Abstractions/Volo/Abp/Users/AbpUsersAbstractionModule.cs
index f27813e04b..eac254b2a9 100644
--- a/modules/users/src/Volo.Abp.Users.Abstractions/Volo/Abp/Users/AbpUsersAbstractionModule.cs
+++ b/modules/users/src/Volo.Abp.Users.Abstractions/Volo/Abp/Users/AbpUsersAbstractionModule.cs
@@ -1,8 +1,6 @@
-using Microsoft.Extensions.DependencyInjection;
-using Volo.Abp.EventBus;
+using Volo.Abp.EventBus;
using Volo.Abp.Modularity;
using Volo.Abp.MultiTenancy;
-using Volo.Abp.Settings;
namespace Volo.Abp.Users
{
@@ -14,12 +12,6 @@ namespace Volo.Abp.Users
)]
public class AbpUsersAbstractionModule : AbpModule
{
- public override void ConfigureServices(ServiceConfigurationContext context)
- {
- Configure(options =>
- {
- options.ValueProviders.Add();
- });
- }
+
}
}
diff --git a/modules/users/src/Volo.Abp.Users.Abstractions/Volo/Abp/Users/UserSettingValueProvider.cs b/modules/users/src/Volo.Abp.Users.Abstractions/Volo/Abp/Users/UserSettingValueProvider.cs
deleted file mode 100644
index 345b0e6929..0000000000
--- a/modules/users/src/Volo.Abp.Users.Abstractions/Volo/Abp/Users/UserSettingValueProvider.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-using System.Threading.Tasks;
-using Volo.Abp.Settings;
-
-namespace Volo.Abp.Users
-{
- //TODO: Optimization: Get all settings and cache it!
- //TODO: Think if it's true to have this provider in this project?
-
- public class UserSettingValueProvider : SettingValueProvider
- {
- public const string ProviderName = "User";
-
- public override string Name => ProviderName;
-
- protected ICurrentUser CurrentUser { get; }
-
- public UserSettingValueProvider(ISettingStore settingStore, ICurrentUser currentUser)
- : base(settingStore)
- {
- CurrentUser = currentUser;
- }
-
- public override async Task GetOrNullAsync(SettingDefinition setting, string providerKey)
- {
- return await SettingStore.GetOrNullAsync(setting.Name, Name, NormalizeProviderKey(providerKey));
- }
-
- public override Task SetAsync(SettingDefinition setting, string value, string providerKey)
- {
- return SettingStore.SetAsync(setting.Name, value, Name, NormalizeProviderKey(providerKey));
- }
-
- public override Task ClearAsync(SettingDefinition setting, string providerKey)
- {
- return SettingStore.DeleteAsync(setting.Name, Name, NormalizeProviderKey(providerKey));
- }
-
- private string NormalizeProviderKey(string providerKey)
- {
- if (providerKey == null && CurrentUser.Id.HasValue)
- {
- return CurrentUser.Id.Value.ToString();
- }
-
- return providerKey;
- }
- }
-}
\ No newline at end of file
diff --git a/modules/users/src/Volo.Abp.Users.Domain/Volo/Abp/Users/AbpUsersDomainModule.cs b/modules/users/src/Volo.Abp.Users.Domain/Volo/Abp/Users/AbpUsersDomainModule.cs
index fe3979df02..d3d6a01185 100644
--- a/modules/users/src/Volo.Abp.Users.Domain/Volo/Abp/Users/AbpUsersDomainModule.cs
+++ b/modules/users/src/Volo.Abp.Users.Domain/Volo/Abp/Users/AbpUsersDomainModule.cs
@@ -1,14 +1,12 @@
using Volo.Abp.Modularity;
using Volo.Abp.Security;
-using Volo.Abp.Settings;
namespace Volo.Abp.Users
{
[DependsOn(
typeof(AbpUsersDomainSharedModule),
typeof(AbpUsersAbstractionModule),
- typeof(AbpSecurityModule),
- typeof(AbpSettingsModule)
+ typeof(AbpSecurityModule)
)]
public class AbpUsersDomainModule : AbpModule
{
diff --git a/npm/packs/core/src/abp.js b/npm/packs/core/src/abp.js
index 4c87489e22..7e44e6256e 100644
--- a/npm/packs/core/src/abp.js
+++ b/npm/packs/core/src/abp.js
@@ -161,6 +161,25 @@ var abp = abp || {};
abp.auth.setToken();
}
+ /* SETTINGS *************************************************/
+
+ abp.setting = abp.setting || {};
+
+ abp.setting.values = abp.setting.values || {};
+
+ abp.setting.get = function (name) {
+ return abp.setting.values[name];
+ };
+
+ abp.setting.getBoolean = function (name) {
+ var value = abp.setting.get(name);
+ return value == 'true' || value == 'True';
+ };
+
+ abp.setting.getInt = function (name) {
+ return parseInt(abp.setting.values[name]);
+ };
+
/* NOTIFICATION *********************************************/
//Defines Notification API, not implements it
diff --git a/samples/MicroserviceDemo/applications/PublicWebSite.Host/Pages/Products.cshtml b/samples/MicroserviceDemo/applications/PublicWebSite.Host/Pages/Products.cshtml
index a89f786992..4165781b58 100644
--- a/samples/MicroserviceDemo/applications/PublicWebSite.Host/Pages/Products.cshtml
+++ b/samples/MicroserviceDemo/applications/PublicWebSite.Host/Pages/Products.cshtml
@@ -1,5 +1,8 @@
@page
+@using ProductManagement
+@using Volo.Abp.Settings
@model PublicWebSite.Host.Pages.ProductsModel
+@inject ISettingProvider SettingProvider
Our Products
@foreach (var product in Model.Products.Items)
@@ -9,4 +12,7 @@
Stock count: @product.StockCount
}
-
\ No newline at end of file
+
+
+@* An example to show how to read settings from the client side / UI *@
+Maximum allowed page size: @await SettingProvider.GetOrNullAsync(ProductManagementSettings.MaxPageSize)
\ No newline at end of file
diff --git a/samples/MicroserviceDemo/applications/PublicWebSite.Host/Pages/Products.cshtml.cs b/samples/MicroserviceDemo/applications/PublicWebSite.Host/Pages/Products.cshtml.cs
index d82aa68175..e67ebff531 100644
--- a/samples/MicroserviceDemo/applications/PublicWebSite.Host/Pages/Products.cshtml.cs
+++ b/samples/MicroserviceDemo/applications/PublicWebSite.Host/Pages/Products.cshtml.cs
@@ -1,5 +1,4 @@
using System.Threading.Tasks;
-using MyCompanyName.ProductManagement;
using ProductManagement;
using Volo.Abp.Application.Dtos;
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages;
diff --git a/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application.Contracts/ProductManagement/IPublicProductAppService.cs b/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application.Contracts/ProductManagement/IPublicProductAppService.cs
index 00934075e9..b47e61fb02 100644
--- a/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application.Contracts/ProductManagement/IPublicProductAppService.cs
+++ b/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application.Contracts/ProductManagement/IPublicProductAppService.cs
@@ -1,9 +1,8 @@
using System.Threading.Tasks;
-using ProductManagement;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
-namespace MyCompanyName.ProductManagement
+namespace ProductManagement
{
public interface IPublicProductAppService : IApplicationService
{
diff --git a/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application.Contracts/ProductManagement/ProductManagementApplicationContractsModule.cs b/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application.Contracts/ProductManagement/ProductManagementApplicationContractsModule.cs
index d8697022b8..53fe58cbe0 100644
--- a/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application.Contracts/ProductManagement/ProductManagementApplicationContractsModule.cs
+++ b/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application.Contracts/ProductManagement/ProductManagementApplicationContractsModule.cs
@@ -3,6 +3,7 @@ using Volo.Abp.Application;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Localization;
using Volo.Abp.Modularity;
+using Volo.Abp.Settings;
using Volo.Abp.VirtualFileSystem;
namespace ProductManagement
@@ -31,6 +32,11 @@ namespace ProductManagement
.Get()
.AddVirtualJson("/ProductManagement/Localization/ApplicationContracts");
});
+
+ Configure(options =>
+ {
+ options.DefinitionProviders.Add();
+ });
}
}
}
diff --git a/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application.Contracts/ProductManagement/ProductManagementSettingDefinitionProvider.cs b/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application.Contracts/ProductManagement/ProductManagementSettingDefinitionProvider.cs
new file mode 100644
index 0000000000..98842127e1
--- /dev/null
+++ b/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application.Contracts/ProductManagement/ProductManagementSettingDefinitionProvider.cs
@@ -0,0 +1,22 @@
+using Volo.Abp.Settings;
+
+namespace ProductManagement
+{
+ /* These setting definitions will be visible to clients that has a ProductManagement.Application.Contracts
+ * reference. Settings those should be hidden from clients should be defined in the ProductManagement.Application
+ * package.
+ */
+ public class ProductManagementSettingDefinitionProvider : SettingDefinitionProvider
+ {
+ public override void Define(ISettingDefinitionContext context)
+ {
+ context.Add(
+ new SettingDefinition(
+ ProductManagementSettings.MaxPageSize,
+ "100",
+ isVisibleToClients: true
+ )
+ );
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application.Contracts/ProductManagement/ProductManagementSettings.cs b/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application.Contracts/ProductManagement/ProductManagementSettings.cs
new file mode 100644
index 0000000000..da420547d0
--- /dev/null
+++ b/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application.Contracts/ProductManagement/ProductManagementSettings.cs
@@ -0,0 +1,12 @@
+namespace ProductManagement
+{
+ public static class ProductManagementSettings
+ {
+ public const string GroupName = "ProductManagement";
+
+ ///
+ /// Maximum allowed page size for paged list requests.
+ ///
+ public const string MaxPageSize = GroupName + ".MaxPageSize";
+ }
+}
\ No newline at end of file
diff --git a/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application/ProductManagement/ProductAppService.cs b/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application/ProductManagement/ProductAppService.cs
index e11eac435f..90d16ec7b5 100644
--- a/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application/ProductManagement/ProductAppService.cs
+++ b/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application/ProductManagement/ProductAppService.cs
@@ -2,10 +2,8 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
-using ProductManagement;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
-using Volo.Abp.Domain.Repositories;
namespace ProductManagement
{
@@ -23,6 +21,8 @@ namespace ProductManagement
public async Task> GetListPagedAsync(PagedAndSortedResultRequestDto input)
{
+ await NormalizeMaxResultCountAsync(input);
+
var products = await _productRepository.GetListAsync(input.Sorting, input.MaxResultCount, input.SkipCount);
var totalCount = await _productRepository.GetCountAsync();
@@ -32,7 +32,7 @@ namespace ProductManagement
return new PagedResultDto(totalCount, dtos);
}
- public async Task> GetListAsync()
+ public async Task> GetListAsync() //TODO: Why there are two GetList. GetListPagedAsync would be enough (rename it to GetList)!
{
var products = await _productRepository.GetListAsync();
@@ -73,5 +73,14 @@ namespace ProductManagement
{
await _productRepository.DeleteAsync(id);
}
+
+ private async Task NormalizeMaxResultCountAsync(PagedAndSortedResultRequestDto input)
+ {
+ var maxPageSize = (await SettingProvider.GetOrNullAsync(ProductManagementSettings.MaxPageSize))?.To();
+ if (maxPageSize.HasValue && input.MaxResultCount > maxPageSize.Value)
+ {
+ input.MaxResultCount = maxPageSize.Value;
+ }
+ }
}
}
\ No newline at end of file
diff --git a/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application/ProductManagement/ProductManagementApplicationModule.cs b/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application/ProductManagement/ProductManagementApplicationModule.cs
index 999f6385ca..4816844d93 100644
--- a/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application/ProductManagement/ProductManagementApplicationModule.cs
+++ b/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application/ProductManagement/ProductManagementApplicationModule.cs
@@ -1,6 +1,5 @@
using Volo.Abp.AutoMapper;
using Volo.Abp.Modularity;
-using Volo.Abp.Settings;
namespace ProductManagement
{
@@ -17,11 +16,6 @@ namespace ProductManagement
{
options.AddProfile(validate: true);
});
-
- Configure(options =>
- {
- options.DefinitionProviders.Add();
- });
}
}
}
diff --git a/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application/ProductManagement/ProductManagementSettingDefinitionProvider.cs b/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application/ProductManagement/ProductManagementSettingDefinitionProvider.cs
deleted file mode 100644
index 168e441945..0000000000
--- a/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application/ProductManagement/ProductManagementSettingDefinitionProvider.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using Volo.Abp.Settings;
-
-namespace ProductManagement
-{
- public class ProductManagementSettingDefinitionProvider : SettingDefinitionProvider
- {
- public override void Define(ISettingDefinitionContext context)
- {
- /* Define module settings here.
- * Use names from ProductManagementSettings class.
- */
- }
- }
-}
\ No newline at end of file
diff --git a/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application/ProductManagement/ProductManagementSettings.cs b/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application/ProductManagement/ProductManagementSettings.cs
deleted file mode 100644
index 19ca732df8..0000000000
--- a/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application/ProductManagement/ProductManagementSettings.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-namespace ProductManagement
-{
- public static class ProductManagementSettings
- {
- public const string GroupName = "ProductManagement";
-
- /* Add constants for setting names. Example:
- * public const string MySettingName = GroupName + ".MySettingName";
- */
- }
-}
\ No newline at end of file
diff --git a/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application/ProductManagement/PublicProductAppService.cs b/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application/ProductManagement/PublicProductAppService.cs
index 3305704ff9..866cc31b34 100644
--- a/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application/ProductManagement/PublicProductAppService.cs
+++ b/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application/ProductManagement/PublicProductAppService.cs
@@ -1,10 +1,9 @@
using System.Collections.Generic;
using System.Threading.Tasks;
-using ProductManagement;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
-namespace MyCompanyName.ProductManagement
+namespace ProductManagement
{
public class PublicProductAppService : ApplicationService, IPublicProductAppService
{
diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20190107113038_Initial.Designer.cs b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20190211104804_Initial.Designer.cs
similarity index 97%
rename from templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20190107113038_Initial.Designer.cs
rename to templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20190211104804_Initial.Designer.cs
index f39ddf1cc7..2002970aad 100644
--- a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20190107113038_Initial.Designer.cs
+++ b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20190211104804_Initial.Designer.cs
@@ -10,14 +10,14 @@ using MyCompanyName.MyProjectName.EntityFrameworkCore;
namespace MyCompanyName.MyProjectName.Migrations
{
[DbContext(typeof(MyProjectNameDbContext))]
- [Migration("20190107113038_Initial")]
+ [Migration("20190211104804_Initial")]
partial class Initial
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
- .HasAnnotation("ProductVersion", "2.2.0-rtm-35687")
+ .HasAnnotation("ProductVersion", "2.2.1-servicing-10028")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
@@ -26,10 +26,18 @@ namespace MyCompanyName.MyProjectName.Migrations
b.Property("Id")
.ValueGeneratedOnAdd();
+ b.Property("ApplicationName")
+ .HasColumnName("ApplicationName")
+ .HasMaxLength(96);
+
b.Property("BrowserInfo")
.HasColumnName("BrowserInfo")
.HasMaxLength(512);
+ b.Property("ClientId")
+ .HasColumnName("ClientId")
+ .HasMaxLength(64);
+
b.Property("ClientIpAddress")
.HasColumnName("ClientIpAddress")
.HasMaxLength(64);
@@ -44,6 +52,10 @@ namespace MyCompanyName.MyProjectName.Migrations
b.Property("ConcurrencyStamp");
+ b.Property("CorrelationId")
+ .HasColumnName("CorrelationId")
+ .HasMaxLength(64);
+
b.Property("Exceptions")
.HasColumnName("Exceptions")
.HasMaxLength(4000);
@@ -178,8 +190,6 @@ namespace MyCompanyName.MyProjectName.Migrations
b.Property("EntityChangeId");
- b.Property("EntityChangeId1");
-
b.Property("NewValue")
.HasColumnName("NewValue")
.HasMaxLength(512);
@@ -204,8 +214,6 @@ namespace MyCompanyName.MyProjectName.Migrations
b.HasIndex("EntityChangeId");
- b.HasIndex("EntityChangeId1");
-
b.ToTable("AbpEntityPropertyChanges");
});
@@ -622,13 +630,9 @@ namespace MyCompanyName.MyProjectName.Migrations
modelBuilder.Entity("Volo.Abp.AuditLogging.EntityPropertyChange", b =>
{
b.HasOne("Volo.Abp.AuditLogging.EntityChange")
- .WithMany()
+ .WithMany("PropertyChanges")
.HasForeignKey("EntityChangeId")
.OnDelete(DeleteBehavior.Cascade);
-
- b.HasOne("Volo.Abp.AuditLogging.EntityChange")
- .WithMany("PropertyChanges")
- .HasForeignKey("EntityChangeId1");
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityRoleClaim", b =>
diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20190107113038_Initial.cs b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20190211104804_Initial.cs
similarity index 97%
rename from templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20190107113038_Initial.cs
rename to templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20190211104804_Initial.cs
index 72aba4d129..8f177b29fb 100644
--- a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20190107113038_Initial.cs
+++ b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20190211104804_Initial.cs
@@ -14,6 +14,7 @@ namespace MyCompanyName.MyProjectName.Migrations
Id = table.Column(nullable: false),
ExtraProperties = table.Column(nullable: true),
ConcurrencyStamp = table.Column(nullable: true),
+ ApplicationName = table.Column(maxLength: 96, nullable: true),
UserId = table.Column(nullable: true),
UserName = table.Column(maxLength: 256, nullable: true),
TenantId = table.Column(nullable: true),
@@ -23,6 +24,8 @@ namespace MyCompanyName.MyProjectName.Migrations
ExecutionDuration = table.Column(nullable: false),
ClientIpAddress = table.Column(maxLength: 64, nullable: true),
ClientName = table.Column(maxLength: 128, nullable: true),
+ ClientId = table.Column(maxLength: 64, nullable: true),
+ CorrelationId = table.Column(maxLength: 64, nullable: true),
BrowserInfo = table.Column(maxLength: 512, nullable: true),
HttpMethod = table.Column(maxLength: 16, nullable: true),
Url = table.Column(maxLength: 256, nullable: true),
@@ -329,8 +332,7 @@ namespace MyCompanyName.MyProjectName.Migrations
NewValue = table.Column(maxLength: 512, nullable: true),
OriginalValue = table.Column(maxLength: 512, nullable: true),
PropertyName = table.Column(maxLength: 128, nullable: false),
- PropertyTypeFullName = table.Column(maxLength: 64, nullable: false),
- EntityChangeId1 = table.Column(nullable: true)
+ PropertyTypeFullName = table.Column(maxLength: 64, nullable: false)
},
constraints: table =>
{
@@ -341,12 +343,6 @@ namespace MyCompanyName.MyProjectName.Migrations
principalTable: "AbpEntityChanges",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
- table.ForeignKey(
- name: "FK_AbpEntityPropertyChanges_AbpEntityChanges_EntityChangeId1",
- column: x => x.EntityChangeId1,
- principalTable: "AbpEntityChanges",
- principalColumn: "Id",
- onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
@@ -389,11 +385,6 @@ namespace MyCompanyName.MyProjectName.Migrations
table: "AbpEntityPropertyChanges",
column: "EntityChangeId");
- migrationBuilder.CreateIndex(
- name: "IX_AbpEntityPropertyChanges_EntityChangeId1",
- table: "AbpEntityPropertyChanges",
- column: "EntityChangeId1");
-
migrationBuilder.CreateIndex(
name: "IX_AbpPermissionGrants_Name_ProviderName_ProviderKey",
table: "AbpPermissionGrants",
diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/MyProjectNameDbContextModelSnapshot.cs b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/MyProjectNameDbContextModelSnapshot.cs
index a1e702f708..1d2a225f38 100644
--- a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/MyProjectNameDbContextModelSnapshot.cs
+++ b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/MyProjectNameDbContextModelSnapshot.cs
@@ -15,7 +15,7 @@ namespace MyCompanyName.MyProjectName.Migrations
{
#pragma warning disable 612, 618
modelBuilder
- .HasAnnotation("ProductVersion", "2.2.0-rtm-35687")
+ .HasAnnotation("ProductVersion", "2.2.1-servicing-10028")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
@@ -24,10 +24,18 @@ namespace MyCompanyName.MyProjectName.Migrations
b.Property("Id")
.ValueGeneratedOnAdd();
+ b.Property("ApplicationName")
+ .HasColumnName("ApplicationName")
+ .HasMaxLength(96);
+
b.Property("BrowserInfo")
.HasColumnName("BrowserInfo")
.HasMaxLength(512);
+ b.Property("ClientId")
+ .HasColumnName("ClientId")
+ .HasMaxLength(64);
+
b.Property("ClientIpAddress")
.HasColumnName("ClientIpAddress")
.HasMaxLength(64);
@@ -42,6 +50,10 @@ namespace MyCompanyName.MyProjectName.Migrations
b.Property("ConcurrencyStamp");
+ b.Property("CorrelationId")
+ .HasColumnName("CorrelationId")
+ .HasMaxLength(64);
+
b.Property("Exceptions")
.HasColumnName("Exceptions")
.HasMaxLength(4000);
@@ -176,8 +188,6 @@ namespace MyCompanyName.MyProjectName.Migrations
b.Property("EntityChangeId");
- b.Property("EntityChangeId1");
-
b.Property("NewValue")
.HasColumnName("NewValue")
.HasMaxLength(512);
@@ -202,8 +212,6 @@ namespace MyCompanyName.MyProjectName.Migrations
b.HasIndex("EntityChangeId");
- b.HasIndex("EntityChangeId1");
-
b.ToTable("AbpEntityPropertyChanges");
});
@@ -620,13 +628,9 @@ namespace MyCompanyName.MyProjectName.Migrations
modelBuilder.Entity("Volo.Abp.AuditLogging.EntityPropertyChange", b =>
{
b.HasOne("Volo.Abp.AuditLogging.EntityChange")
- .WithMany()
+ .WithMany("PropertyChanges")
.HasForeignKey("EntityChangeId")
.OnDelete(DeleteBehavior.Cascade);
-
- b.HasOne("Volo.Abp.AuditLogging.EntityChange")
- .WithMany("PropertyChanges")
- .HasForeignKey("EntityChangeId1");
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityRoleClaim", b =>
diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/MyCompanyName.MyProjectName.EntityFrameworkCore.csproj b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/MyCompanyName.MyProjectName.EntityFrameworkCore.csproj
index 7788dcfdea..f84de6cd67 100644
--- a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/MyCompanyName.MyProjectName.EntityFrameworkCore.csproj
+++ b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/MyCompanyName.MyProjectName.EntityFrameworkCore.csproj
@@ -6,11 +6,7 @@
-
-
-
-
-
+
diff --git a/templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/20190107114531_Initial.Designer.cs b/templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/20190211105121_Initial.Designer.cs
similarity index 94%
rename from templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/20190107114531_Initial.Designer.cs
rename to templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/20190211105121_Initial.Designer.cs
index 600c904f2b..61c15431db 100644
--- a/templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/20190107114531_Initial.Designer.cs
+++ b/templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/20190211105121_Initial.Designer.cs
@@ -10,14 +10,14 @@ using MyCompanyName.MyProjectName.Host;
namespace MyCompanyName.MyProjectName.Host.Migrations
{
[DbContext(typeof(DemoAppDbContext))]
- [Migration("20190107114531_Initial")]
+ [Migration("20190211105121_Initial")]
partial class Initial
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
- .HasAnnotation("ProductVersion", "2.2.0-rtm-35687")
+ .HasAnnotation("ProductVersion", "2.2.1-servicing-10028")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
@@ -26,10 +26,18 @@ namespace MyCompanyName.MyProjectName.Host.Migrations
b.Property("Id")
.ValueGeneratedOnAdd();
+ b.Property("ApplicationName")
+ .HasColumnName("ApplicationName")
+ .HasMaxLength(96);
+
b.Property("BrowserInfo")
.HasColumnName("BrowserInfo")
.HasMaxLength(512);
+ b.Property("ClientId")
+ .HasColumnName("ClientId")
+ .HasMaxLength(64);
+
b.Property("ClientIpAddress")
.HasColumnName("ClientIpAddress")
.HasMaxLength(64);
@@ -44,6 +52,10 @@ namespace MyCompanyName.MyProjectName.Host.Migrations
b.Property("ConcurrencyStamp");
+ b.Property("CorrelationId")
+ .HasColumnName("CorrelationId")
+ .HasMaxLength(64);
+
b.Property("Exceptions")
.HasColumnName("Exceptions")
.HasMaxLength(4000);
@@ -178,8 +190,6 @@ namespace MyCompanyName.MyProjectName.Host.Migrations
b.Property("EntityChangeId");
- b.Property("EntityChangeId1");
-
b.Property("NewValue")
.HasColumnName("NewValue")
.HasMaxLength(512);
@@ -204,8 +214,6 @@ namespace MyCompanyName.MyProjectName.Host.Migrations
b.HasIndex("EntityChangeId");
- b.HasIndex("EntityChangeId1");
-
b.ToTable("AbpEntityPropertyChanges");
});
@@ -280,13 +288,9 @@ namespace MyCompanyName.MyProjectName.Host.Migrations
modelBuilder.Entity("Volo.Abp.AuditLogging.EntityPropertyChange", b =>
{
b.HasOne("Volo.Abp.AuditLogging.EntityChange")
- .WithMany()
+ .WithMany("PropertyChanges")
.HasForeignKey("EntityChangeId")
.OnDelete(DeleteBehavior.Cascade);
-
- b.HasOne("Volo.Abp.AuditLogging.EntityChange")
- .WithMany("PropertyChanges")
- .HasForeignKey("EntityChangeId1");
});
#pragma warning restore 612, 618
}
diff --git a/templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/20190107114531_Initial.cs b/templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/20190211105121_Initial.cs
similarity index 93%
rename from templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/20190107114531_Initial.cs
rename to templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/20190211105121_Initial.cs
index fd1c985c5d..b2074c3513 100644
--- a/templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/20190107114531_Initial.cs
+++ b/templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/20190211105121_Initial.cs
@@ -14,6 +14,7 @@ namespace MyCompanyName.MyProjectName.Host.Migrations
Id = table.Column(nullable: false),
ExtraProperties = table.Column(nullable: true),
ConcurrencyStamp = table.Column(nullable: true),
+ ApplicationName = table.Column(maxLength: 96, nullable: true),
UserId = table.Column(nullable: true),
UserName = table.Column(maxLength: 256, nullable: true),
TenantId = table.Column(nullable: true),
@@ -23,6 +24,8 @@ namespace MyCompanyName.MyProjectName.Host.Migrations
ExecutionDuration = table.Column(nullable: false),
ClientIpAddress = table.Column(maxLength: 64, nullable: true),
ClientName = table.Column(maxLength: 128, nullable: true),
+ ClientId = table.Column(maxLength: 64, nullable: true),
+ CorrelationId = table.Column(maxLength: 64, nullable: true),
BrowserInfo = table.Column(maxLength: 512, nullable: true),
HttpMethod = table.Column(maxLength: 16, nullable: true),
Url = table.Column(maxLength: 256, nullable: true),
@@ -124,8 +127,7 @@ namespace MyCompanyName.MyProjectName.Host.Migrations
NewValue = table.Column(maxLength: 512, nullable: true),
OriginalValue = table.Column(maxLength: 512, nullable: true),
PropertyName = table.Column(maxLength: 128, nullable: false),
- PropertyTypeFullName = table.Column(maxLength: 64, nullable: false),
- EntityChangeId1 = table.Column(nullable: true)
+ PropertyTypeFullName = table.Column(maxLength: 64, nullable: false)
},
constraints: table =>
{
@@ -136,12 +138,6 @@ namespace MyCompanyName.MyProjectName.Host.Migrations
principalTable: "AbpEntityChanges",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
- table.ForeignKey(
- name: "FK_AbpEntityPropertyChanges_AbpEntityChanges_EntityChangeId1",
- column: x => x.EntityChangeId1,
- principalTable: "AbpEntityChanges",
- principalColumn: "Id",
- onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
@@ -179,11 +175,6 @@ namespace MyCompanyName.MyProjectName.Host.Migrations
table: "AbpEntityPropertyChanges",
column: "EntityChangeId");
- migrationBuilder.CreateIndex(
- name: "IX_AbpEntityPropertyChanges_EntityChangeId1",
- table: "AbpEntityPropertyChanges",
- column: "EntityChangeId1");
-
migrationBuilder.CreateIndex(
name: "IX_AbpPermissionGrants_Name_ProviderName_ProviderKey",
table: "AbpPermissionGrants",
diff --git a/templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/DemoAppDbContextModelSnapshot.cs b/templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/DemoAppDbContextModelSnapshot.cs
index 70e88b9973..5261599df5 100644
--- a/templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/DemoAppDbContextModelSnapshot.cs
+++ b/templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/DemoAppDbContextModelSnapshot.cs
@@ -15,7 +15,7 @@ namespace MyCompanyName.MyProjectName.Host.Migrations
{
#pragma warning disable 612, 618
modelBuilder
- .HasAnnotation("ProductVersion", "2.2.0-rtm-35687")
+ .HasAnnotation("ProductVersion", "2.2.1-servicing-10028")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
@@ -24,10 +24,18 @@ namespace MyCompanyName.MyProjectName.Host.Migrations
b.Property("Id")
.ValueGeneratedOnAdd();
+ b.Property("ApplicationName")
+ .HasColumnName("ApplicationName")
+ .HasMaxLength(96);
+
b.Property("BrowserInfo")
.HasColumnName("BrowserInfo")
.HasMaxLength(512);
+ b.Property("ClientId")
+ .HasColumnName("ClientId")
+ .HasMaxLength(64);
+
b.Property("ClientIpAddress")
.HasColumnName("ClientIpAddress")
.HasMaxLength(64);
@@ -42,6 +50,10 @@ namespace MyCompanyName.MyProjectName.Host.Migrations
b.Property("ConcurrencyStamp");
+ b.Property("CorrelationId")
+ .HasColumnName("CorrelationId")
+ .HasMaxLength(64);
+
b.Property("Exceptions")
.HasColumnName("Exceptions")
.HasMaxLength(4000);
@@ -176,8 +188,6 @@ namespace MyCompanyName.MyProjectName.Host.Migrations
b.Property("EntityChangeId");
- b.Property("EntityChangeId1");
-
b.Property("NewValue")
.HasColumnName("NewValue")
.HasMaxLength(512);
@@ -202,8 +212,6 @@ namespace MyCompanyName.MyProjectName.Host.Migrations
b.HasIndex("EntityChangeId");
- b.HasIndex("EntityChangeId1");
-
b.ToTable("AbpEntityPropertyChanges");
});
@@ -278,13 +286,9 @@ namespace MyCompanyName.MyProjectName.Host.Migrations
modelBuilder.Entity("Volo.Abp.AuditLogging.EntityPropertyChange", b =>
{
b.HasOne("Volo.Abp.AuditLogging.EntityChange")
- .WithMany()
+ .WithMany("PropertyChanges")
.HasForeignKey("EntityChangeId")
.OnDelete(DeleteBehavior.Cascade);
-
- b.HasOne("Volo.Abp.AuditLogging.EntityChange")
- .WithMany("PropertyChanges")
- .HasForeignKey("EntityChangeId1");
});
#pragma warning restore 612, 618
}
diff --git a/templates/service/host/MyCompanyName.MyProjectName.Host/MyCompanyName.MyProjectName.Host.csproj b/templates/service/host/MyCompanyName.MyProjectName.Host/MyCompanyName.MyProjectName.Host.csproj
index b034148995..ca352a43b3 100644
--- a/templates/service/host/MyCompanyName.MyProjectName.Host/MyCompanyName.MyProjectName.Host.csproj
+++ b/templates/service/host/MyCompanyName.MyProjectName.Host/MyCompanyName.MyProjectName.Host.csproj
@@ -31,8 +31,7 @@
-
-
+