using Hangfire.Common; using Hangfire.States; namespace Strata.Stratasphere.Biz.Configuration.Hangfire { public class DeleteOnSuccessAttribute : JobFilterAttribute, IElectStateFilter { public void OnStateElection(ElectStateContext context) { if (context.CandidateState.Name == SucceededState.StateName) { context.CandidateState = new DeletedState { Reason = "This job is deleted on success." }; } } } }