fix
This commit is contained in:
parent
4dc8849b31
commit
cc251f7129
146 changed files with 2465 additions and 4785 deletions
71
Services/ImportJobTracker.cs
Normal file
71
Services/ImportJobTracker.cs
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
using System.Collections.Concurrent;
|
||||
using BMA.EHR.Recruit.Requests.Recruits;
|
||||
|
||||
namespace BMA.EHR.Recruit.Services;
|
||||
|
||||
public enum ImportJobType
|
||||
{
|
||||
CandidateFile,
|
||||
CandidateFileById,
|
||||
ScoreFile,
|
||||
ResultFile
|
||||
}
|
||||
|
||||
public enum ImportJobStatus
|
||||
{
|
||||
Pending,
|
||||
Running,
|
||||
Completed,
|
||||
Failed
|
||||
}
|
||||
|
||||
public class ImportJobInfo
|
||||
{
|
||||
public string JobId { get; set; } = Guid.NewGuid().ToString("D");
|
||||
public ImportJobType JobType { get; set; }
|
||||
public ImportJobStatus Status { get; set; } = ImportJobStatus.Pending;
|
||||
public int ProcessedCount { get; set; }
|
||||
public int TotalCount { get; set; }
|
||||
public string? ErrorMessage { get; set; }
|
||||
public DateTime CreatedAt { get; set; } = DateTime.Now;
|
||||
public DateTime? CompletedAt { get; set; }
|
||||
|
||||
// Request data
|
||||
public string ImportFile { get; set; } = "";
|
||||
public Guid RecruitImportId { get; set; }
|
||||
public string ImportDocId { get; set; } = "";
|
||||
public string? UserId { get; set; }
|
||||
public string? FullName { get; set; }
|
||||
|
||||
// For CandidateFile
|
||||
public PostRecruitImportRequest? Request { get; set; }
|
||||
}
|
||||
|
||||
public class ImportJobTracker
|
||||
{
|
||||
private readonly ConcurrentDictionary<string, ImportJobInfo> _jobs = new();
|
||||
|
||||
public ImportJobInfo CreateJob(ImportJobInfo job)
|
||||
{
|
||||
_jobs[job.JobId] = job;
|
||||
return job;
|
||||
}
|
||||
|
||||
public ImportJobInfo? GetJob(string jobId)
|
||||
{
|
||||
return _jobs.TryGetValue(jobId, out var job) ? job : null;
|
||||
}
|
||||
|
||||
public void UpdateStatus(string jobId, ImportJobStatus status, int processedCount = 0, string? errorMessage = null)
|
||||
{
|
||||
if (_jobs.TryGetValue(jobId, out var job))
|
||||
{
|
||||
job.Status = status;
|
||||
job.ProcessedCount = processedCount;
|
||||
if (errorMessage != null)
|
||||
job.ErrorMessage = errorMessage;
|
||||
if (status == ImportJobStatus.Completed || status == ImportJobStatus.Failed)
|
||||
job.CompletedAt = DateTime.Now;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue