Open Closed

background Job can't get userid #5381


User avatar
0
shingolin created

I try to use background job to excute some domain service about create / update And data is succeed to create / update to database But, I found that the record without CreatorId / LastModifiierId After debug I'm understand it because without currentuser via backgroud job So I try to manually set to entity It work for create ,but fail in update It will be set to null when currentuser id have no value

Is these any other solution for me?

  • ABP Framework version: v7.1.1
  • 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:"
public class AttendEmployeeRoteScheduleBackgroundJob : AsyncBackgroundJob<AttendEmployeeRoteScheduleGenerateConditionDto>, ITransientDependency
{
    private readonly AttendEmployeeRoteScheduleDomainService attendEmployeeRoteSchedulesAppService;
    
    public AttendEmployeeRoteScheduleBackgroundJob(AttendEmployeeRoteScheduleDomainService attendEmployeeRoteSchedulesAppService)
    {
    this.attendEmployeeRoteSchedulesAppService = attendEmployeeRoteSchedulesAppService;
    }
    
    public override Task ExecuteAsync(AttendEmployeeRoteScheduleGenerateConditionDto args)
    {
    return attendEmployeeRoteSchedulesAppService.GenerateAsync(args);
    }
}

1 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You can change the current user id by https://docs.abp.io/en/abp/latest/CurrentUser#changing-the-current-principal

Made with ❤️ on ABP v9.1.0-preview. Updated on December 26, 2024, 06:07