Add scheduled job to process pending jobs in LeaveProcessJobStatusRepository
This commit is contained in:
parent
91e6b1b35b
commit
8732c34564
2 changed files with 5 additions and 5 deletions
|
|
@ -128,11 +128,9 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task ProcessPendingJobsAsync(CancellationToken cancellationToken = default)
|
public async Task ProcessPendingJobsAsync()
|
||||||
{
|
{
|
||||||
// กำหนด timeout เป็น 60 นาที
|
|
||||||
using var timeoutCts = new CancellationTokenSource(TimeSpan.FromMinutes(60));
|
|
||||||
using var combinedCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, timeoutCts.Token);
|
|
||||||
|
|
||||||
|
|
||||||
var pendingJobs = await GetPendingOrProcessingJobsAsync();
|
var pendingJobs = await GetPendingOrProcessingJobsAsync();
|
||||||
|
|
@ -145,7 +143,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
|
||||||
await UpdateToProcessingAsync(job.Id);
|
await UpdateToProcessingAsync(job.Id);
|
||||||
|
|
||||||
// ทำงานที่ต้องการที่นี่ (เช่น เรียก API, ประมวลผลข้อมูล ฯลฯ)
|
// ทำงานที่ต้องการที่นี่ (เช่น เรียก API, ประมวลผลข้อมูล ฯลฯ)
|
||||||
await ProcessTaskAsync(job.RootDnaId, combinedCts.Token);
|
await ProcessTaskAsync(job.RootDnaId);
|
||||||
|
|
||||||
// อัปเดตสถานะเป็น Completed
|
// อัปเดตสถานะเป็น Completed
|
||||||
await UpdateToCompletedAsync(job.Id);
|
await UpdateToCompletedAsync(job.Id);
|
||||||
|
|
|
||||||
|
|
@ -190,6 +190,8 @@ if (manager != null)
|
||||||
manager.AddOrUpdate("ปรับปรุงรอบการลงเวลาทำงาน", Job.FromExpression<UserDutyTimeRepository>(x => x.UpdateUserDutyTime()), "0 1 * * *", bangkokTimeZone);
|
manager.AddOrUpdate("ปรับปรุงรอบการลงเวลาทำงาน", Job.FromExpression<UserDutyTimeRepository>(x => x.UpdateUserDutyTime()), "0 1 * * *", bangkokTimeZone);
|
||||||
// ทำความสะอาดข้อมูล CheckIn Job Status ที่เก่ากว่า 30 วัน - รันทุกวันเวลา 02:00 น.
|
// ทำความสะอาดข้อมูล CheckIn Job Status ที่เก่ากว่า 30 วัน - รันทุกวันเวลา 02:00 น.
|
||||||
manager.AddOrUpdate("ทำความสะอาดข้อมูล CheckIn Job Status", Job.FromExpression<CheckInJobStatusRepository>(x => x.CleanupOldJobsAsync(30)), "0 2 * * *", bangkokTimeZone);
|
manager.AddOrUpdate("ทำความสะอาดข้อมูล CheckIn Job Status", Job.FromExpression<CheckInJobStatusRepository>(x => x.CleanupOldJobsAsync(30)), "0 2 * * *", bangkokTimeZone);
|
||||||
|
|
||||||
|
manager.AddOrUpdate("ประมวลผลงานที่ค้างอยู่ในสถานะ Pending หรือ Processing", Job.FromExpression<LeaveProcessJobStatusRepository>(x => x.ProcessPendingJobsAsync()), "0 3 * * *", bangkokTimeZone);
|
||||||
}
|
}
|
||||||
|
|
||||||
// apply migrations
|
// apply migrations
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue