Hello,
I am browsing the framework code and noticed this code:
public SettingManager(ISettingDefinitionManager settingDefinitionManager, ICacheManager cacheManager)
{
_settingDefinitionManager = settingDefinitionManager;
AbpSession = NullAbpSession.Instance;
SettingStore = DefaultConfigSettingStore.Instance;
As you can see it is using the DefaultconfigSettingStore.
Later on, in the Abp.Zero, it defines a new SettingStore.
Where in the solutions, you configure it to use the Abp.Zero.SettingStore and not the default?
Also, every module can have a SettingsProvider to return Settings. Where in the solutions, do you capture all those settings from each module and store them in db?
Many thanks, Bilal
12 Answer(s)
-
0
Any idea?
-
0
Hi,
When a new module adds the same implementation of a class, it is used by default. So module zero adds the implementation.
About registering setting definitions, it is done in SettingDefinitionManager's Initialize method.
-
0
Great, I can see it now.
In the DefinitionManager.Initialize() it saves all settings from all providers.
SetingsManager uses the SettingsStore to persist to DB.
I still have one missing link: SettingsManager, where is it called to persist whatever settings DefinitionManager has? I tried to look for that, but couldn't.
When searching for code how it works, is there like a guide or logical path to follow or starting point?
Thanks Ismail :)
-
0
Hi,
It is stored by SettingStore, see <a class="postlink" href="https://github.com/aspnetboilerplate/module-zero/blob/master/src/Abp.Zero/Configuration/SettingStore.cs">https://github.com/aspnetboilerplate/mo ... ngStore.cs</a>.
Actually you can use AbpKernelModule for tracking such cases, <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/master/src/Abp/AbpKernelModule.cs">https://github.com/aspnetboilerplate/as ... lModule.cs</a>.
-
0
Thanks Ismail.
SettingsManger calls SettingsStore to persist data into DB.
Who calls SettingsManager to persist? Where in time does this happen?
Thanks
-
0
It happens when you call it in your code.
-
0
An example maybe? Where does that show? Thanks
-
0
Hi,
TenantSettingsAppService and HostSettingsAppService are examples of it, you can take a look at them.
-
0
Great!
But still first time application loads, who asks the SettingsManager to save any settings in DB? I am sure there are some settings set by SettingsProviders in different modules.
There might be something missing for me, dunno.
Thanks again
-
0
Hi Ismail, I guess I was missing one thing, SettingsDefinitionManager is defined as "Singleton" in the IoC. Therefore, every time the application runs, the settings will be collected from all modules and will be available.
When a change occurs in Tenant Settings or Host Settings, then values are written on-demand to DB.
I am not sure though, if the values stored in memory are updated on the spot, or next time they are requested they are read from DB.
Thanks
-
0
Hi,
If value of a setting changes, it is updated both in database and setting manager, see <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/master/src/Abp/Configuration/SettingManager.cs#L261">https://github.com/aspnetboilerplate/as ... er.cs#L261</a>.
There is only one thing, settings are accesible on the client side via "abp.setting.values["NameOfSetting"]". If your setting change request is an ajax request, this client side value is not updated, you will need a page refresh in this case or you can update the client side value as well using regular javascript code like:
abp.setting.values["NameOfSetting"] = "new value for setting";
-
0
Thanks!