abp icon indicating copy to clipboard operation
abp copied to clipboard

Abp.Timing.Timezone - setting ignored

Open leonkosak opened this issue 3 years ago • 2 comments

We are experiencing problems with retrieval of Tenant Settings, specifically Abp.Timing.Timezone, from the database. Our application is running on v4.3. with Multitenancy and separate postgres databases for each Tenant. In the modules, where the timezone settings are needed, we have defined the ModuleSettingDefinitionProvider as the documentation instructs.

public class ModuleSettingDefinitionProvider : SettingDefinitionProvider
    {
        public override void Define(ISettingDefinitionContext context)
        {
            /* Define module settings here.
             * Use names from ModuleSettings class.
             */

            context.Add(
                    new SettingDefinition("Abp.Timing.Timezone", "UTC")
                );
        }
    }

In the AppServices we are using the _settingProvider.GetOrNullAsync("Abp.Timing.Timezone");

On our development enviroment we run into no problems and the correct database defined setting is retrieved and used without problems, whereas on our production we run into the issue, that the correct setting is not retrieved and the default »UTC« Timezone from the SettingDefinitionProvider is used in further operations. We have tried defining the settings:

  • In the host database (public/AbpSettings) where the Theme settings are also defined and are working fine (first row is an example of table entry working fine, other rows are the combinations we have tried to use) image

  • In the tenant database (public/AbpSettings) which initially was empty image

We are aware, that with the ProviderKey value »null« in the row with the ProviderName »T« (Tenant) is incorrect, but tried it anyway. We have also tried a combination of the above variants (Default, Global, Tenant).

leonkosak avatar Jul 08 '22 07:07 leonkosak

Can you provide steps or code to reproduce the problem?

maliming avatar Jul 08 '22 07:07 maliming

Can you provide steps or code to reproduce the problem?

  1. Define Abp.Timing.Timezone SettingDefinition in the SettingDefinitionProvider:
public class ExampleApplicationSettingDefinitionProvider : SettingDefinitionProvider
    {
        public override void Define(ISettingDefinitionContext context)
        {
            /* Define module settings here.
             * Use names from ModuleSettings class.
             */

            context.Add(
                    new SettingDefinition("Abp.Timing.Timezone", "UTC")
                );
        }
    }
  1. In the AppService, use the ISettingProvider to retrieve the setting
public ProductAppService : ExampleApplicationAppService, IProductAppService
{
     ...
     private readonly ISettingProvider _settingProvider;
     ...
     public ProductAppService(..., ISettingProvider settingProvider, ...)
     {
          ...
          _settingProvider = settingProvider;
          ...
     }

     public string GetTenantTimezone()
     {
          string timezone = await _settingProvider.GetOrNullAsync("Abp.Timing.Timezone");
          return timezone;
     }
}

This example works on development enviroment, but doesn't work on the production one. The different database entries, that we tried, are defined in the original post.

luks104 avatar Sep 12 '22 08:09 luks104

but doesn't work on the production one.

I can't reproduce the problem in this case.

maliming avatar Nov 11 '22 05:11 maliming

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jan 21 '23 10:01 stale[bot]