You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
575 B
21 lines
575 B
namespace MyCompanyName.MyProjectName.Extensions.Hangfire;
|
|
|
|
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)
|
|
{
|
|
|
|
}
|
|
}
|