Is it possible to reproduce the problem using the brand new template project?
user "user1" has role "role1" User "user1" belongs to orgnization unit "org1" after login for a entity how we can filter data based on user "role" or "organization unit"
hi
where
to filter based on the 1 and 2 results.sorry,
var defaultLanguage = await _settingProvider.GetOrNullAsync(LocalizationSettingNames.DefaultLanguage);
var (cultureName, uiCultureName) = LocalizationSettingHelper.ParseLanguageSetting(defaultLanguage);
using (CultureHelper.Use(CultureInfo.GetCultureInfo(cultureName)))
{
GenerateViolationReport()
}
hi
Add the below code to your web project.
This may cause issues, because by design the key name in the dictionary is not camelCase
Configure<JsonOptions>(options =>
{
options.JsonSerializerOptions.Converters.Add(new MyJsonConverter());
});
public class MyJsonConverter : JsonConverter<IdentityUserDto>
{
private JsonSerializerOptions _readJsonSerializerOptions;
private JsonSerializerOptions _writeJsonSerializerOptions;
public override IdentityUserDto Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
_readJsonSerializerOptions ??= new JsonSerializerOptions(options)
{
DictionaryKeyPolicy = JsonNamingPolicy.CamelCase
};
_readJsonSerializerOptions.Converters.RemoveAll(x => x.GetType() == typeof(MyJsonConverter));
return JsonSerializer.Deserialize(ref reader, typeToConvert, _readJsonSerializerOptions).As<IdentityUserDto>();
}
public override void Write(Utf8JsonWriter writer, IdentityUserDto value, JsonSerializerOptions options)
{
_writeJsonSerializerOptions ??= new JsonSerializerOptions(options)
{
DictionaryKeyPolicy = JsonNamingPolicy.CamelCase
};
_writeJsonSerializerOptions.Converters.RemoveAll(x => x.GetType() == typeof(MyJsonConverter));
JsonSerializer.Serialize(writer, value, _writeJsonSerializerOptions);
}
}
: )
hi
I guess can i access subfields with a '.' after ExtraProperties?
I think you can do that. https://docs.abp.io/en/abp/latest/Object-Extensions#getproperty
hi
Please share the logs of this request. Thanks
hi
Could you please let me know why this does not work anymore? Maybe it has something to do with the ABP version upgrade? If I remember it right, it was done for 4.x.
Does everything work fine if you don't upgrade?
hi
here I want to set defaultLanguage to use it in GenerateViolationReport() method
hi
You can switch the current culture
// get defaultLanguage for this tenant
var defaultLanguage = await _settingProvider.GetOrNullAsync(LocalizationSettingNames.DefaultLanguage);
// here I want to set defaultLanguage to use it in GenerateViolationReport() method
using (CultureHelper.Use(CultureInfo.GetCultureInfo(defaultLanguage)))
{
GenerateViolationReport()
}
hi
I will contact you by WeChat.