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.
if you could just point us in the direction of an example that does what we're trying to achieve
ok, Please create a new brand project and send it to me, I will update it and get back to you. liming.ma@volosoft.com