feat(web): add manual trigger action support for Hangfire recurring jobs
Validators (Pushes and Pull Requests) / validate-ui-and-storage (push) Successful in 22s
Validators (Pushes and Pull Requests) / validate-core (push) Has been cancelled
Prepare Release / Build & Create Release (push) Successful in 1m9s
Prepare Release / Release Notification (push) Successful in 2s
Validators (Pushes and Pull Requests) / validate-ui-and-storage (push) Successful in 22s
Validators (Pushes and Pull Requests) / validate-core (push) Has been cancelled
Prepare Release / Build & Create Release (push) Successful in 1m9s
Prepare Release / Release Notification (push) Successful in 2s
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using Hangfire;
|
||||
using Hangfire.Storage;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using QuantEngine.Web.Services;
|
||||
|
||||
@@ -32,6 +33,29 @@ public class IndexModel : PageModel
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostTriggerJobAsync(string jobId)
|
||||
{
|
||||
if (string.IsNullOrEmpty(jobId))
|
||||
{
|
||||
TempData["ErrorMessage"] = "올바르지 않은 작업 ID입니다.";
|
||||
return RedirectToPage();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
RecurringJob.TriggerJob(jobId);
|
||||
TempData["SuccessMessage"] = $"작업 '{DescribeJobId(jobId)}'이(가) 즉시 실행 큐에 등록되었습니다.";
|
||||
_logger.LogInformation("Manually triggered Hangfire recurring job: {JobId}", jobId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Failed to trigger Hangfire job: {JobId}", jobId);
|
||||
TempData["ErrorMessage"] = $"작업 실행 실패: {ex.Message}";
|
||||
}
|
||||
|
||||
return RedirectToPage();
|
||||
}
|
||||
|
||||
private void LoadOperationsData()
|
||||
{
|
||||
try
|
||||
@@ -51,6 +75,7 @@ public class IndexModel : PageModel
|
||||
var recurringJobs = connection.GetRecurringJobs();
|
||||
ScheduledJobs = recurringJobs
|
||||
.Select(j => new ScheduledJobInfo(
|
||||
j.Id,
|
||||
DescribeJobId(j.Id),
|
||||
DescribeCron(j.Cron),
|
||||
j.NextExecution,
|
||||
@@ -127,5 +152,5 @@ public class IndexModel : PageModel
|
||||
};
|
||||
}
|
||||
|
||||
public record ScheduledJobInfo(string JobName, string Schedule, DateTime? NextRun, bool IsEnabled);
|
||||
public record ScheduledJobInfo(string JobId, string JobName, string Schedule, DateTime? NextRun, bool IsEnabled);
|
||||
public record JobExecutionInfo(string JobName, DateTime StartedAt, DateTime? CompletedAt, bool IsSuccess);
|
||||
|
||||
Reference in New Issue
Block a user