-
In AppService, i made an API call to the Identity module to add a new user to the AbpUsers table. After successfully adding the new user, I retrieved the user information to create a new record in the employee table (which is in the Hrms module), but I received the error message 'A task was canceled. Can you tell me the cause and how to fix this error? Thanks! public async Task<MResult<EmployeeDto>> CreateAsync(EmployeeInputUpdateDto employee)
{
try
{
var userName = TextUtil.GenerateUserName(employee.Name);
employee.UserName = userName;
employee.Password = TextUtil.GeneratePassword(8);
var resultUser = await _internalGatewayService.Post<MResult<IdentityUserDto>>("api/internal/administration/user", employee);
if(resultUser != null && resultUser.Success && resultUser.Data != null)
{
var obj = ObjectMapper.Map<EmployeeInputUpdateDto, Employee>(employee);
obj.UserId = resultUser.Data.Id;
obj.UserName =resultUser.Data.UserName;
obj.IsDeleted = false;
obj.CreatorName = CurrentUser.UserName;
obj.CreationTime = Clock.Now;
obj.CreatorId = CurrentUser.Id;
var res = await _employeeRepository.InsertAsync(obj, true); //A task was canceled here
await RemoveCache();
return new MResult<EmployeeDto>()
{
Success = true,
Data = ObjectMapper.Map<Employee, EmployeeDto>(res),
Message = "Success"
};
}
return new MResult<EmployeeDto>()
{
Success = false,
Message = "Create failed"
};
}
catch(Exception e)
{
_sentry.CaptureException(e);
return new MResult<EmployeeDto>()
{
Success = false,
Message = e.Message
};
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
ynkdqe
Jun 21, 2024
Replies: 1 comment 3 replies
-
hi
Can you share the error logs? |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
After reviewing, I found that this error usually occurs in debug mode. If I turn off debug mode, the error doesn't happen anymore. I will investigate the cause further myself. Thanks