Open Closed

LASTMODIFIERID IS UPDATING NULL VALUE #5005


User avatar
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)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Please use using for _currentTenant and ICurrentPrincipalAccessor

    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);
        }
      }
    }
    
    
  • User Avatar
    0
    shijo created

    Thanks. Its working.

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11