Starts in:
2 DAYS
3 HRS
51 MIN
36 SEC
Starts in:
2 D
3 H
51 M
36 S
Open Closed

can not use UserLookupService to obtain user information in tenant #3176


User avatar
0
chenxm created
  • ABP Framework version: v5.3.0-rc.2
  • 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:"

I have a microservice solution that is generated from a template. I want to synchronize redundant user information in one of the services. I refer to this information:

https://github.com/abpframework/abp/tree/dev/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Users

When the host creates a new user, the user information can be obtained synchronously. When I was in tenant, I couldn't get it.

`public class WorkUserSynchronizer : IDistributedEventHandler<EntityUpdatedEto

private readonly IWorkUserRepository _workUserRepo;
private readonly IWorkUserLookupService _workUserLookupService;

private readonly ILogger<WorkUserSynchronizer> _logger;

public WorkUserSynchronizer(
    ICurrentTenant currentTenant,
    IWorkUserRepository workUserRepo, 
    IWorkUserLookupService workUserLookupService,
    ILogger<WorkUserSynchronizer> logger)
{
    _currentTenant = currentTenant;
    _workUserRepo = workUserRepo;
    _workUserLookupService = workUserLookupService;

    _logger = logger;
}

public async Task HandleEventAsync(EntityUpdatedEto<UserEto> eventData)
{
    _logger.LogInformation("user updated: {0}", eventData.Entity.Id);

    using (_currentTenant.Change(eventData.Entity.TenantId))
    {
        var user = await _workUserRepo.FindAsync(eventData.Entity.Id);

        if (null == user)
        {
            user = await _workUserLookupService.FindByIdAsync(eventData.Entity.Id);

            if (null == user)
            {
                return;
            }
        }

        if (user.Update(eventData.Entity))
        {
            await _workUserRepo.UpdateAsync(user);
        }
    }
}

}`


1 Answer(s)
  • User Avatar
    0
    chenxm created

    This is not a problem

Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06