mirror of
https://github.com/nsnail/NetAdmin.git
synced 2025-12-29 00:55:48 +08:00
@@ -0,0 +1,42 @@
|
||||
using Furion.Schedule;
|
||||
using NetAdmin.Host.BackgroundRunning;
|
||||
using NetAdmin.SysComponent.Application.Services.Sys.Dependency;
|
||||
|
||||
namespace NetAdmin.SysComponent.Host.Jobs;
|
||||
|
||||
/// <summary>
|
||||
/// 释放计划作业
|
||||
/// </summary>
|
||||
public sealed class FreeScheduledJob : WorkBase<FreeScheduledJob>, IJob
|
||||
{
|
||||
private readonly IJobService _jobService;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FreeScheduledJob" /> class.
|
||||
/// </summary>
|
||||
public FreeScheduledJob()
|
||||
{
|
||||
_jobService = ServiceProvider.GetService<IJobService>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 具体处理逻辑
|
||||
/// </summary>
|
||||
/// <param name="context">作业执行前上下文</param>
|
||||
/// <param name="stoppingToken">取消任务 Token</param>
|
||||
/// <exception cref="NetAdminGetLockerException">加锁失败异常</exception>
|
||||
public async Task ExecuteAsync(JobExecutingContext context, CancellationToken stoppingToken)
|
||||
{
|
||||
await WorkflowAsync(true, stoppingToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通用工作流
|
||||
/// </summary>
|
||||
/// <exception cref="NotImplementedException">NotImplementedException</exception>
|
||||
/// <exception cref="ArgumentOutOfRangeException">ArgumentOutOfRangeException</exception>
|
||||
protected override async ValueTask WorkflowAsync(CancellationToken cancelToken)
|
||||
{
|
||||
_ = await _jobService.ReleaseStuckTaskAsync().ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
@@ -87,7 +87,7 @@ public sealed class ScheduledJob : WorkBase<ScheduledJob>, IJob
|
||||
{
|
||||
Duration = sw.ElapsedMilliseconds
|
||||
, HttpMethod = job.HttpMethod
|
||||
, HttpStatusCode = rsp.StatusCode
|
||||
, HttpStatusCode = (int)rsp.StatusCode
|
||||
, JobId = job.Id
|
||||
, RequestBody = job.RequestBody
|
||||
, RequestHeader = _requestHeader
|
||||
|
||||
Reference in New Issue
Block a user