This commit is contained in:
parent
cba16f25b9
commit
9c353f40c6
1 changed files with 11 additions and 1 deletions
|
|
@ -602,7 +602,9 @@ public class ImportBackgroundService : BackgroundService
|
||||||
|
|
||||||
// get doc from minio (MinIOService already saves Document to its own context)
|
// get doc from minio (MinIOService already saves Document to its own context)
|
||||||
var doc = await _minioService.UploadFileAsync(new DummyFormFile(job.ImportFile));
|
var doc = await _minioService.UploadFileAsync(new DummyFormFile(job.ImportFile));
|
||||||
|
var scoreImport_id = Guid.NewGuid(); // Pre-generate Id to use as FK
|
||||||
var imported = new ScoreImport();
|
var imported = new ScoreImport();
|
||||||
|
imported.Id = scoreImport_id;
|
||||||
imported.Year = rec_import_year;
|
imported.Year = rec_import_year;
|
||||||
imported.RecruitImportId = rec_import_id;
|
imported.RecruitImportId = rec_import_id;
|
||||||
imported.CreatedAt = DateTime.Now;
|
imported.CreatedAt = DateTime.Now;
|
||||||
|
|
@ -699,7 +701,6 @@ public class ImportBackgroundService : BackgroundService
|
||||||
r.LastUpdatedAt = DateTime.Now;
|
r.LastUpdatedAt = DateTime.Now;
|
||||||
r.LastUpdateUserId = job.UserId ?? "";
|
r.LastUpdateUserId = job.UserId ?? "";
|
||||||
r.LastUpdateFullName = job.FullName ?? "System Administrator";
|
r.LastUpdateFullName = job.FullName ?? "System Administrator";
|
||||||
r.ScoreImport = imported;
|
|
||||||
|
|
||||||
batchScores.Add(r);
|
batchScores.Add(r);
|
||||||
}
|
}
|
||||||
|
|
@ -709,6 +710,11 @@ public class ImportBackgroundService : BackgroundService
|
||||||
|
|
||||||
if (batchCount >= batchSize)
|
if (batchCount >= batchSize)
|
||||||
{
|
{
|
||||||
|
// Set ScoreImportId FK for all scores in batch
|
||||||
|
foreach (var score in batchScores)
|
||||||
|
{
|
||||||
|
_context.Entry(score).Property("ScoreImportId").CurrentValue = scoreImport_id;
|
||||||
|
}
|
||||||
await _context.BulkInsertAsync(batchScores);
|
await _context.BulkInsertAsync(batchScores);
|
||||||
batchScores.Clear();
|
batchScores.Clear();
|
||||||
batchCount = 0;
|
batchCount = 0;
|
||||||
|
|
@ -719,6 +725,10 @@ public class ImportBackgroundService : BackgroundService
|
||||||
// Process remaining records
|
// Process remaining records
|
||||||
if (batchScores.Count > 0)
|
if (batchScores.Count > 0)
|
||||||
{
|
{
|
||||||
|
foreach (var score in batchScores)
|
||||||
|
{
|
||||||
|
_context.Entry(score).Property("ScoreImportId").CurrentValue = scoreImport_id;
|
||||||
|
}
|
||||||
await _context.BulkInsertAsync(batchScores);
|
await _context.BulkInsertAsync(batchScores);
|
||||||
}
|
}
|
||||||
} while (reader.NextResult());
|
} while (reader.NextResult());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue