fix #2483
All checks were successful
Build & Deploy on Dev / build (push) Successful in 47s

This commit is contained in:
Suphonchai Phoonsawat 2026-05-12 13:20:38 +07:00
parent 3b70246e9d
commit 5384a5893b
16 changed files with 98 additions and 41 deletions

13
.idea/.idea.BMA.EHR.Recruit.Service/.idea/.gitignore generated vendored Normal file
View file

@ -0,0 +1,13 @@
# Default ignored files
/shelf/
/workspace.xml
# Rider ignored files
/contentModel.xml
/projectSettingsUpdater.xml
/modules.xml
/.idea.BMA.EHR.Recruit.Service.iml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View file

@ -0,0 +1 @@
BMA.EHR.Recruit.Service

After

Width:  |  Height:  |  Size: 23 B

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
</project>

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View file

@ -752,6 +752,8 @@ namespace BMA.EHR.Recruit.Service.Controllers
var cols = workSheet.GetHeaderColumns();
int row = 2;
int batchCount = 0;
const int batchSize = 500;
while (row <= totalRows)
{
@ -860,13 +862,23 @@ namespace BMA.EHR.Recruit.Service.Controllers
//imported.Recruits.Add(r);
row++;
batchCount++;
// Batch save to prevent OutOfMemoryException on large imports
if (batchCount >= batchSize)
{
_context.SaveChanges();
_context.ChangeTracker.Clear();
// Re-attach the import entity after clearing the tracker
_context.RecruitImports.Attach(imported);
batchCount = 0;
}
}
}
}
// finally save to database
// Save remaining records in the last batch
_context.SaveChanges();
return Success();
@ -1371,6 +1383,8 @@ namespace BMA.EHR.Recruit.Service.Controllers
var cols = workSheet.GetHeaderColumns();
int row = 8;
int batchCount = 0;
const int batchSize = 500;
var endRow = workSheet.Dimension.End.Row; // แถวสุดท้ายที่มีข้อมูล
while (row <= endRow)
{
@ -1461,14 +1475,31 @@ namespace BMA.EHR.Recruit.Service.Controllers
}
row++;
batchCount++;
// Batch save to prevent OutOfMemoryException on large imports
if (batchCount >= batchSize)
{
rec_import.ScoreImport = imported;
await _context.SaveChangesAsync();
_context.ChangeTracker.Clear();
// Re-attach entities after clearing the tracker
_context.Attach(rec_import);
_context.Attach(imported);
imported.Scores.Clear();
batchCount = 0;
}
} // end of sheet loop
} // end of all file loop
}
// finally save to database
rec_import.ScoreImport = imported;
await _context.SaveChangesAsync();
// Save remaining records in the last batch
if (imported.Scores.Count > 0)
{
rec_import.ScoreImport = imported;
await _context.SaveChangesAsync();
}
return Success();

View file

@ -39,7 +39,7 @@
"auditLevel": "low",
"auditMode": "direct"
},
"SdkAnalysisLevel": "9.0.300"
"SdkAnalysisLevel": "10.0.200"
},
"frameworks": {
"net7.0": {
@ -203,7 +203,7 @@
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "/usr/local/share/dotnet/sdk/9.0.305/RuntimeIdentifierGraph.json"
"runtimeIdentifierGraphPath": "/usr/local/share/dotnet/sdk/10.0.203/RuntimeIdentifierGraph.json"
}
}
}

View file

@ -7,7 +7,7 @@
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/Users/suphonchaip/.nuget/packages/</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/Users/suphonchaip/.nuget/packages/</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.14.0</NuGetToolVersion>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">7.0.0</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="/Users/suphonchaip/.nuget/packages/" />

View file

@ -1,4 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v7.0", FrameworkDisplayName = ".NET 7.0")]
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v7.0", FrameworkDisplayName = ".NET 7.0")]

View file

@ -14,11 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("BMA.EHR.Recruit.Service")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
<<<<<<< HEAD
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+82e6bcc95bc1a1582fcc9513f288ef318f5adb72")]
=======
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+d245236a144a9ba61661418db9ef1a8a2225d063")]
>>>>>>> develop
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+3b70246e9d6b2564a4d9b34daf5f4837c4116a91")]
[assembly: System.Reflection.AssemblyProductAttribute("BMA.EHR.Recruit.Service")]
[assembly: System.Reflection.AssemblyTitleAttribute("BMA.EHR.Recruit.Service")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View file

@ -1,5 +1 @@
<<<<<<< HEAD
e6710ad194b71c423e48e4496ccfad9f61fd14ce3d380484fc72866c29b8ac89
=======
157a45ee45981ce605f03881ba3934018f157203e24d6fc6a8c2d7a6fcd5987d
>>>>>>> develop
41b5cec2055d8189cb57cbe339bf4738c10bcf621221538d3a3cce6fb5666e55

View file

@ -1,5 +1,7 @@
is_global = true
build_property.TargetFramework = net7.0
build_property.TargetFrameworkIdentifier = .NETCoreApp
build_property.TargetFrameworkVersion = v7.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb = true
build_property.ProjectTypeGuids =

View file

@ -1,17 +1,17 @@
// <auto-generated/>
global using global::Microsoft.AspNetCore.Builder;
global using global::Microsoft.AspNetCore.Hosting;
global using global::Microsoft.AspNetCore.Http;
global using global::Microsoft.AspNetCore.Routing;
global using global::Microsoft.Extensions.Configuration;
global using global::Microsoft.Extensions.DependencyInjection;
global using global::Microsoft.Extensions.Hosting;
global using global::Microsoft.Extensions.Logging;
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Net.Http.Json;
global using global::System.Threading;
global using global::System.Threading.Tasks;
global using Microsoft.AspNetCore.Builder;
global using Microsoft.AspNetCore.Hosting;
global using Microsoft.AspNetCore.Http;
global using Microsoft.AspNetCore.Routing;
global using Microsoft.Extensions.Configuration;
global using Microsoft.Extensions.DependencyInjection;
global using Microsoft.Extensions.Hosting;
global using Microsoft.Extensions.Logging;
global using System;
global using System.Collections.Generic;
global using System.IO;
global using System.Linq;
global using System.Net.Http;
global using System.Net.Http.Json;
global using System.Threading;
global using System.Threading.Tasks;

View file

@ -13782,7 +13782,7 @@
"auditLevel": "low",
"auditMode": "direct"
},
"SdkAnalysisLevel": "9.0.300"
"SdkAnalysisLevel": "10.0.200"
},
"frameworks": {
"net7.0": {
@ -13946,7 +13946,7 @@
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "/usr/local/share/dotnet/sdk/9.0.305/RuntimeIdentifierGraph.json"
"runtimeIdentifierGraphPath": "/usr/local/share/dotnet/sdk/10.0.203/RuntimeIdentifierGraph.json"
}
}
}

View file

@ -1,6 +1,6 @@
{
"version": 2,
"dgSpecHash": "z4TN+iW9Ey8=",
"dgSpecHash": "6/jNsBvJ3SY=",
"success": true,
"projectFilePath": "/Users/suphonchaip/Develop/hrms/hrms-api-recruit/BMA.EHR.Recruit.Service.csproj",
"expectedPackageFiles": [