add Background Task
This commit is contained in:
parent
75ddebba37
commit
3ae9be5869
6 changed files with 211 additions and 2 deletions
|
|
@ -13,6 +13,8 @@ using BMA.EHR.Domain.ModelsExam.Candidate;
|
|||
using BMA.EHR.Domain.Shared;
|
||||
using BMA.EHR.Infrastructure.Persistence;
|
||||
using BMA.EHR.Insignia.Service.Requests;
|
||||
using BMA.EHR.Insignia.Service.Services;
|
||||
using Hangfire.Processing;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
|
@ -51,6 +53,8 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
private readonly IConfiguration _configuration;
|
||||
private readonly PermissionRepository _permission;
|
||||
|
||||
private readonly IBackgroundTaskQueue _queue;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
|
|
@ -73,7 +77,8 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
InsigniaPeriodsRepository insigniaPeriodRepository,
|
||||
InsigniaReportRepository insigniaReportRepository,
|
||||
IConfiguration configuration,
|
||||
PermissionRepository permission)
|
||||
PermissionRepository permission,
|
||||
IBackgroundTaskQueue queue)
|
||||
{
|
||||
_context = context;
|
||||
_documentService = documentService;
|
||||
|
|
@ -86,6 +91,8 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
_configuration = configuration;
|
||||
_permission = permission;
|
||||
_insigniaReportRepository = insigniaReportRepository;
|
||||
|
||||
_queue = queue;
|
||||
}
|
||||
|
||||
#region " Properties "
|
||||
|
|
@ -626,6 +633,17 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
return Success();
|
||||
}
|
||||
|
||||
[HttpGet("bg/{type}/{insigniaPeriodId:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> BackgroundCalculateInsigniaRequestByTypeAsync(string type, Guid insigniaPeriodId)
|
||||
{
|
||||
await _queue.QueueBackgroundWorkItemAsync(async token =>
|
||||
{
|
||||
// Logic งาน background จริงเช่น:
|
||||
//await LongRunningProcess(jobInfo, token);
|
||||
});
|
||||
return Success("Background job started.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// คำนวณราชชื่อผู้ได้รับเครื่องราช (แยกตาม officer, employee)
|
||||
/// </summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue