我尝试了这些动作作业过滤方法,但实际上我需要的是,我想在Job id成功执行后调用一个方法,或者在它给出Job ID后内部失败。
public void OnStateElection(ElectStateContext context)
{
//Log event
}
public void OnCreating(CreatingContext filterContext)
{
//Log event
}
public void OnCreated(CreatedContext filterContext)
{
//Log event
}
public void OnPerforming(PerformingContext context)
{
//Log event
}
public void OnPerformed(PerformedContext context)
{
//Log event
}
public void OnStateApplied(ApplyStateContext context, IWriteOnlyTransaction transaction)
{
//Log event
}
public void OnStateUnapplied(ApplyStateContext context, IWriteOnlyTransaction transaction)
{
//Log event
}
答案 0 :(得分:3)
Hangfire可以构建执行链。如果您想在第一个作业成功后安排下一个作业,则需要将ContinueWith(string parentId, Expression<Action> methodCall, JobContinuationOptions options);
与JobContinuationOptions.OnlyOnSucceededState
一起使用。
您可以在此处找到更详细的信息:https://indexoutofrange.com/Don%27t-do-it-now!-Part-5.-Hangfire-job-continuation,-ContinueWith/