2025-05-27 14:27:50 +08:00
|
|
|
namespace JiShe.IoT.Extensions.Hangfire;
|
2025-03-11 10:24:11 +08:00
|
|
|
|
|
|
|
|
public class AutoDeleteAfterSuccessAttributer : JobFilterAttribute, IApplyStateFilter
|
|
|
|
|
{
|
|
|
|
|
private readonly TimeSpan _deleteAfter;
|
|
|
|
|
|
|
|
|
|
public AutoDeleteAfterSuccessAttributer(TimeSpan timeSpan)
|
|
|
|
|
{
|
|
|
|
|
_deleteAfter = timeSpan;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnStateApplied(ApplyStateContext context, IWriteOnlyTransaction transaction)
|
|
|
|
|
{
|
|
|
|
|
context.JobExpirationTimeout = _deleteAfter;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnStateUnapplied(ApplyStateContext context, IWriteOnlyTransaction transaction)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|