Files
EmailBill/Service/Jobs/PeriodicBillJob.cs
孙诚 ef4ed9fd57
Some checks failed
Docker Build & Deploy / Build Docker Image (push) Failing after 6s
Docker Build & Deploy / Deploy to Production (push) Has been skipped
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 2s
Docker Build & Deploy / WeChat Notification (push) Successful in 2s
feat: Implement scheduled tasks management and budget archiving functionality
- Added BudgetArchiveJob for monthly budget archiving.
- Created BudgetArchive entity and BudgetArchiveRepository for managing archived budgets.
- Introduced JobController for handling job execution, pausing, and resuming.
- Developed ScheduledTasksView for displaying and managing scheduled tasks in the frontend.
- Updated PeriodicBillJob to improve scope handling.
- Enhanced OpenAiService with increased HTTP timeout.
- Added archiveBudgets API endpoint for archiving budgets by year and month.
- Refactored BudgetController to utilize new repository patterns and improved error handling.
- Introduced rich-content styles for better rendering of HTML content in Vue components.
- Updated various Vue components to support rich HTML content display.
2026-01-09 14:03:01 +08:00

33 lines
985 B
C#

using Quartz;
namespace Service.Jobs;
/// <summary>
/// 周期性账单定时任务
/// </summary>
[DisallowConcurrentExecution] // 防止并发执行
public class PeriodicBillJob(
IServiceProvider serviceProvider,
ILogger<PeriodicBillJob> logger) : IJob
{
public async Task Execute(IJobExecutionContext context)
{
try
{
logger.LogInformation("开始执行周期性账单检查任务");
// 执行周期性账单检查
using var scope = serviceProvider.CreateScope();
var periodicService = scope.ServiceProvider.GetRequiredService<ITransactionPeriodicService>();
await periodicService.ExecutePeriodicBillsAsync();
logger.LogInformation("周期性账单检查任务执行完成");
}
catch (Exception ex)
{
logger.LogError(ex, "周期性账单检查任务执行出错");
throw; // 让 Quartz 知道任务失败
}
}
}