diff --git a/BMA.EHR.Application/Repositories/GenericRepository.cs b/BMA.EHR.Application/Repositories/GenericRepository.cs index 1f10ca37..b5519c15 100644 --- a/BMA.EHR.Application/Repositories/GenericRepository.cs +++ b/BMA.EHR.Application/Repositories/GenericRepository.cs @@ -113,6 +113,7 @@ namespace BMA.EHR.Application.Repositories { try { + var json = JsonConvert.SerializeObject(body); var stringContent = new StringContent(json, Encoding.UTF8, "application/json"); //stringContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); diff --git a/BMA.EHR.Application/Repositories/UserProfileRepository.cs b/BMA.EHR.Application/Repositories/UserProfileRepository.cs index df2fe6b0..2b420e5d 100644 --- a/BMA.EHR.Application/Repositories/UserProfileRepository.cs +++ b/BMA.EHR.Application/Repositories/UserProfileRepository.cs @@ -146,7 +146,7 @@ namespace BMA.EHR.Application.Repositories // สร้าง HTTP content //var body = new StringContent(bodyJson, Encoding.UTF8, "application/json"); - var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey); + var apiResult = await PostExternalAPIAsync(apiPath, accessToken ?? "", body, apiKey); if (apiResult != null) { @@ -157,7 +157,7 @@ namespace BMA.EHR.Application.Repositories return null; } - catch + catch(Exception ex) { throw; } diff --git a/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs b/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs index 211a651a..005f9882 100644 --- a/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs +++ b/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs @@ -290,7 +290,7 @@ namespace BMA.EHR.Insignia.Service.Controllers [AllowAnonymous] public async Task> Test() { - await _insigniaReportRepository.CalInsigniaRequestBkkByType("officer"); + await _insigniaReportRepository.CalInsigniaRequestBkkByType("employee"); return Success(); } diff --git a/BMA.EHR.Insignia/Program.cs b/BMA.EHR.Insignia/Program.cs index 5352e7b3..a4dd716a 100644 --- a/BMA.EHR.Insignia/Program.cs +++ b/BMA.EHR.Insignia/Program.cs @@ -125,9 +125,14 @@ var builder = WebApplication.CreateBuilder(args); DashboardJobListLimit = 50000, TransactionTimeout = TimeSpan.FromMinutes(1), InvisibilityTimeout = TimeSpan.FromHours(3), - TablesPrefix = "Hangfire" + TablesPrefix = "Hangfire_Insignia" }))); - builder.Services.AddHangfireServer(); + builder.Services.AddHangfireServer(options => + { + options.ServerName = "Insignia-Server"; // ← ระบุชื่อ server + options.WorkerCount = 5; // ← + options.Queues = new[] { "insignia" }; // ← worker จะรันเฉพาะ queue "insignia" + }); // RabbitMQ @@ -193,7 +198,11 @@ var app = builder.Build(); x => x.CalculateInsigniaRequestBkkByType("officer"), Cron.Daily(Int32.Parse(builder.Configuration["KeycloakCron:Hour"]) - 5, Int32.Parse(builder.Configuration["KeycloakCron:Minute"])), - TimeZoneInfo.Local + new RecurringJobOptions + { + TimeZone = TimeZoneInfo.Local, + QueueName = "insignia" // ← กำหนด queue + } ); RecurringJob.AddOrUpdate( @@ -201,7 +210,11 @@ var app = builder.Build(); x => x.CalculateInsigniaRequestBkkByType("employee"), Cron.Daily(Int32.Parse(builder.Configuration["KeycloakCron:Hour"]) - 4, Int32.Parse(builder.Configuration["KeycloakCron:Minute"])), - TimeZoneInfo.Local + new RecurringJobOptions + { + TimeZone = TimeZoneInfo.Local, + QueueName = "insignia" // ← กำหนด queue + } ); // apply migrations