แก้ปัญหา token ถูกล้างไปก่อนที่จะส่ง notification

This commit is contained in:
Suphonchai Phoonsawat 2026-05-15 21:53:40 +07:00
parent 2b000cbd69
commit c77035dbb2
2 changed files with 2 additions and 1 deletions

View file

@ -72,6 +72,7 @@ public class ImportBackgroundService : BackgroundService
_tracker.UpdateStatus(job.JobId, ImportJobStatus.Completed, job.TotalCount); _tracker.UpdateStatus(job.JobId, ImportJobStatus.Completed, job.TotalCount);
await notificationService.SendImportNotificationAsync(job.Token, false, "ระบบนำเข้าข้อมูลสำเร็จ"); await notificationService.SendImportNotificationAsync(job.Token, false, "ระบบนำเข้าข้อมูลสำเร็จ");
job.Token = null; // Clear token after notification sent
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -79,6 +80,7 @@ public class ImportBackgroundService : BackgroundService
_tracker.UpdateStatus(job.JobId, ImportJobStatus.Failed, 0, ex.Message); _tracker.UpdateStatus(job.JobId, ImportJobStatus.Failed, 0, ex.Message);
try { await notificationService.SendImportNotificationAsync(job.Token, true, ex.Message); } catch { } try { await notificationService.SendImportNotificationAsync(job.Token, true, ex.Message); } catch { }
job.Token = null; // Clear token after notification sent
// cleanup minio file on failure // cleanup minio file on failure
if (!string.IsNullOrEmpty(job.ImportDocId)) if (!string.IsNullOrEmpty(job.ImportDocId))

View file

@ -72,7 +72,6 @@ public class ImportJobTracker
job.CompletedAt = DateTime.Now; job.CompletedAt = DateTime.Now;
// Clear request data to free memory for completed/failed jobs // Clear request data to free memory for completed/failed jobs
job.Request = null; job.Request = null;
job.Token = null;
} }
} }
} }