0
shijo created
- ABP Framework version: v7.0.0
- UI type: Angular
- DB provider: EF Core
- Tiered (MVC) or Identity Server Separated (Angular): yes
- Exception message and stack trace:
- Steps to reproduce the issue:" We are updating some records through distributed events, other than LastmofierID all values are updating perfectly. I tried to set ClaimsPrincipal also but not reflecting. Sample method added below,
[UnitOfWork]
public async Task HandleEventAsync(APIBulkOperationEto eventData)
{
_currentTenant.Change(eventData.TenantId);
var newPrincipal = new ClaimsPrincipal(
new ClaimsIdentity(
new Claim[]
{
new Claim(AbpClaimTypes.UserId, eventData.CreatorId.ToString()),
new Claim(AbpClaimTypes.TenantId, eventData.TenantId.ToString()),
new Claim(AbpClaimTypes.UserName, "admin")
}
)
);
var detail = await _bulkActionDetailRepository.GetAsync(x => x.BulkActionId == eventData.BulkActionId && x.FileDescriptorId == eventData.FileDescriptorId);
if (detail != null)
{
detail.Status = eventData.Status;
detail.StatusDetail = eventData.StatusMessage;
await _bulkActionDetailRepository.UpdateAsync(detail, true);
}
}
2 Answer(s)
-
0
hi
Please use
using
for_currentTenant
andICurrentPrincipalAccessor
using(_currentTenant.Change(eventData.TenantId)) { var newPrincipal = new ClaimsPrincipal( new ClaimsIdentity( new Claim[] { new Claim(AbpClaimTypes.UserId, eventData.CreatorId.ToString()), new Claim(AbpClaimTypes.TenantId, eventData.TenantId.ToString()), new Claim(AbpClaimTypes.UserName, "admin") } ) ); using(_currentPrincipalAccessor.Change(newPrincipal)) { var detail = await _bulkActionDetailRepository.GetAsync(x => x.BulkActionId == eventData.BulkActionId && x.FileDescriptorId == eventData.FileDescriptorId); if (detail != null) { detail.Status = eventData.Status; detail.StatusDetail = eventData.StatusMessage; await _bulkActionDetailRepository.UpdateAsync(detail, true); } } }
-
0
Thanks. Its working.