gpt4 book ai didi

mysql - 使用 Hangfire 进行自动付款处理

转载 作者:行者123 更新时间:2023-11-29 21:04:14 25 4
gpt4 key购买 nike

我刚刚发现了hangfire。我已经成功安装了mysql存储版本。我想在以下场景中使用它:每天中午 12:01,它应该触发带有 OWIN 和 EF 应用程序 Controller 操作的 ASP.NET MVC5,该操作检查数据库并选择要在相关日期处理的付款引用。此操作以向支付处理提供商提供 API URL 结束。我的问题是,如果我的操作称为“ProcessPayments”,我如何设置hangfire 每天重复此过程。感谢您的帮助。

最佳答案

以防万一有人像我一样需要启动插入,当我问这个问题时。使用 Hangfire Mysql Storage、Identity 2、ASP.NET、MVC5、EF、C#,您可以在 Controller 中创建一个操作,如下所示,为流程添加循环作业。

public ActionResult PDPayment(int id)
{
string cronExp = "1 12 * * *";
using (ApplicationDbContext db = new ApplicationDbContext())
{
var a = db.DDs.SingleOrDefault(a => a.DDId==id);
RecurringJob.AddOrUpdate(a.id+"-"+a.DDId+"_job", () => ProcessPayments(id), cronExp);
return new EmptyResult();
}
}

然后您创建付款方法或逻辑。

 public static void ProcessPayments(int id)
{
eg fetch records with id
create invoice
process invoice- payment
update records of payment
send email
redirect to success or failed page
}

关于mysql - 使用 Hangfire 进行自动付款处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36960771/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com