asp.net mvc2 任务调度程序

发布于 2024-11-09 13:52:12 字数 208 浏览 0 评论 0原文

我有一个 asp.net mvc 2 应用程序,我需要每天运行一次任务(调用 WS,保存到数据库中)。建议的方法是什么?有一件事,我有一种感觉,我想从网络应用程序中执行此任务。

有没有人有任何建议: 我正在考虑使用 .netquartz 还是常规 System.Timers.Timer? 有人看到任何问题吗?

还有其他更好的解决方案吗?

多谢 --MB

I have an asp.net mvc 2 app, and I need to run a task (call WS, save into db) once a day. What is the suggested way for this? One thing, I have a feeling I would like to execute this task from within the webapp.

Does anyone have any suggestions:
I was considering .net quartz or regular System.Timers.Timer?
Does anyone see any problems?

Any other better solutions?

Thanks a lot
--MB

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

Oo萌小芽oO 2024-11-16 13:52:12

为什么要从网络应用程序运行它?您甚至无法知道 Web 应用程序是否会在要求的时间运行。我建议您查看Windows 服务

Why do you want to run this from the webapp? You have no way of even knowing if the webapp will be running at the required time. I would recommend you look at Windows Services

剪不断理还乱 2024-11-16 13:52:12

Web 应用程序并不是计划任务的最佳宿主。除非您实现一个系统来保持进程处于唤醒状态,否则就没有机会确保您的计划将被执行。
Quartz.net 对此很有帮助。
它由一个核心模块和一个服务器(Windows 服务)模块组成,您可以在 Web 应用程序中使用该核心模块来保存任务,该服务器(Windows 服务)模块可以执行您的计划作业。

我最近实现了自己的 Windows 服务,并使用 Sql Server 作为预定作业的存储。一切都运行得很好,即使我必须费点力气才能将它们组合在一起。
文档并不总是那么清楚。

web apps are not the best host for a scheduled task. Unless you implement a system to keep the process awake, there's no chance to be sure your schedule will be executed.
Quartz.net is good for that.
It consists in a core module which you can use in your web app to save tasks and a server (windows service) module which executes your scheduled jobs.

I've recently implemented my own windows services and used Sql Server as storage for my scheduled jobs. Everything works pretty well, even if, I had to struggle a little bit to put things together.
The documentations is not always so clear.

苹果你个爱泡泡 2024-11-16 13:52:12

查看 Quartz.Net,它可以作为 NuGet 包提供,也可以从他们的网站获得。

有很多关于如何设置这些的示例,它们非常灵活,您只需定义一个类,该类使用单个 Execute() 方法实现 IJob ,该方法获取由您选择的触发器触发。

您还可以考虑使用 Windows Workflow Foundation。

Have a look at Quartz.Net, which is available as a NuGet package or from their site.

There are lots of examples of how to set these up, they are very flexible, you just have to define a class which implements IJob with a single Execute() method which gets fired by your choice of triggers.

You could also consider using Windows Workflow Foundation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文