fix hangfire แยก job ออกจากกัน และแก้เรื่องการส่ง token
Some checks failed
release-dev / release-dev (push) Failing after 11s

This commit is contained in:
Suphonchai Phoonsawat 2025-11-11 10:40:49 +07:00
parent 998ca38da8
commit f081034e36
4 changed files with 21 additions and 7 deletions

View file

@ -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");

View file

@ -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;
}

View file

@ -290,7 +290,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
[AllowAnonymous]
public async Task<ActionResult<ResponseObject>> Test()
{
await _insigniaReportRepository.CalInsigniaRequestBkkByType("officer");
await _insigniaReportRepository.CalInsigniaRequestBkkByType("employee");
return Success();
}

View file

@ -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<InsigniaReportRepository>(
@ -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