fix ยืมคืนเครื่องราชย?มาใช้่ RootDnaId แทน rootId
This commit is contained in:
parent
65e85b7194
commit
14fd93ae95
9 changed files with 21340 additions and 22 deletions
|
|
@ -330,7 +330,10 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
var total = insigniaManage.InsigniaManageOrganiations.Where(x => x.OrganizationId != req.OrganizationOrganizationId).Sum(x => x.Total);
|
||||
if (req.Total + total > insigniaManage.Total)
|
||||
return Error(GlobalMessages.InsigniaManageOrgLimit);
|
||||
var root = _userProfileRepository.GetOc(req.OrganizationOrganizationId, 0, AccessToken)?.Root ?? null;
|
||||
|
||||
var ocData = _userProfileRepository.GetOc(req.OrganizationOrganizationId, 0, AccessToken);
|
||||
var root = ocData?.Root ?? null;
|
||||
var rootDnaId = ocData?.RootDnaId ?? null;
|
||||
await _context.InsigniaManageOrganiations.AddAsync(
|
||||
new InsigniaManageOrganiation
|
||||
{
|
||||
|
|
@ -344,6 +347,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
LastUpdateFullName = FullName ?? "System Administrator",
|
||||
LastUpdateUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
RootDnaId = rootDnaId
|
||||
});
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
|
|
@ -791,7 +795,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
|
||||
var insigniaManageOrganiation = await _context.InsigniaManageOrganiations.AsQueryable()
|
||||
.Include(x => x.InsigniaManageProfiles)
|
||||
.FirstOrDefaultAsync(x => x.OrganizationId == insigniaNoteProfile.RootId && x.InsigniaManage.Id == insigniaManage.Id); // แก้เป็นหาจากหน่วยงานยืมเพิม manage id
|
||||
.FirstOrDefaultAsync(x => x.RootDnaId == insigniaNoteProfile.RootDnaId && x.InsigniaManage.Id == insigniaManage.Id); // แก้เป็นหาจากหน่วยงานยืมเพิม manage id
|
||||
if (insigniaManageOrganiation == null)
|
||||
return Error(GlobalMessages.InsigniaManageOrgNotFound);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using BMA.EHR.Insignia.Service.Configuration;
|
||||
using BMA.EHR.Application.Repositories;
|
||||
using BMA.EHR.Insignia.Service.Configuration;
|
||||
using SocketIOClient;
|
||||
using System.Security.Claims;
|
||||
|
||||
|
|
@ -9,16 +10,17 @@ public class InsigniaRequestProcessService : BackgroundService
|
|||
{
|
||||
private readonly IBackgroundTaskQueue _queue;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly IServiceScopeFactory _serviceScopeFactory;
|
||||
|
||||
|
||||
public InsigniaRequestProcessService(
|
||||
IBackgroundTaskQueue queue,
|
||||
IHttpContextAccessor httpContextAccessor)
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
IServiceScopeFactory serviceScopeFactory)
|
||||
{
|
||||
_queue = queue;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
|
||||
|
||||
_serviceScopeFactory = serviceScopeFactory;
|
||||
}
|
||||
|
||||
#region " Properties "
|
||||
|
|
@ -73,6 +75,14 @@ public class InsigniaRequestProcessService : BackgroundService
|
|||
var endTime = DateTime.Now;
|
||||
var duration = endTime - startTime;
|
||||
|
||||
// Resolve repository from a scope because DbContext is scoped/transient.
|
||||
using var scope = _serviceScopeFactory.CreateScope();
|
||||
var userProfileRepository = (UserProfileRepository)scope.ServiceProvider.GetService(typeof(UserProfileRepository));
|
||||
if (userProfileRepository != null)
|
||||
{
|
||||
await userProfileRepository.PostInsigniaMessageToSocket("Task completed", UserId ?? "", AccessToken);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue