用于发送摘要电子邮件的 Windows Scheduler 或 SQL Server 作业

发布于 2024-08-16 17:53:20 字数 199 浏览 10 评论 0原文

将定期从应用程序发送电子邮件。

我的 ASP.NET MVC 应用程序中有一个 EmailController,它具有操作方法,每种通知/电子邮件都有一个,需要在一周的不同时间调用。

问题:Windows Scheduler(在 Server 2008 机器上运行)比通过 SQL Server 作业进行调度更好还是更差?为什么?

谢谢

Will be sending out e-mails from an application on a scheduled basis.

I have an EmailController in my ASP.NET MVC application with action methods, one for each kind of notification/e-mail, that will need to be called at different times during the week.

Question: Is Windows Scheduler (running on a Server 2008 box) any better or worse than scheduling this via a SQL Server job? And why?

Thanks

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

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

发布评论

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

评论(2

╭⌒浅淡时光〆 2024-08-23 17:53:20

恕我直言,让调度程序调用控制器并执行操作方法来触发通知效果最好。我的流程(无论好坏)是这样的:

  1. 将调用控制器/操作的代码放入 .vbs 文件中。操作方法需要一个“安全代码”,该代码必须与 web.config 中的值匹配,否则它将不会执行(我的想法是,这将减少某些人使用浏览器点击操作方法并运行发送通知的机会代码不应运行)。

  2. 在计划程序中创建计划任务以定期调用该文件。

  3. 在我的数据库中,记录所有通知执行并包含一个属性,该属性定义不同通知类型应发出的频率。这又是为了减少某人在不应该发送通知的情况下发送通知的机会。

无论如何,这有效。我遇到的唯一问题是访问 https。这不起作用,因为我相信该任务面临提供一些凭据的挑战(它不能,因为它是以编程方式运行的)。将其更改为 http 有效,并且 imo 不会造成任何类型的安全风险。

想法?更好的方法来实现这个?我很想听听任何人提供的任何信息。

谢谢

IMHO having scheduler call into the controller and execute the action methods to fire off notifications worked out best. My process (for better of for worst) is as such:

  1. Put the code to call the controller/action in a .vbs file. The action method requires a "security code" that must match a value in the web.config or else it will not execute (my thinking is that this will lessen the chance of some folk hitting the action method with there browser and running the send notification code when it shouldn't be run).

  2. Create a scheduled task in Scheduler to call that file on a regular basis.

  3. In my database, log all notification executions and include an attribute that defines the frequency in which different notification types should go out. This, again, is to lessen the chance of someone sending out notifications when they shouldn't.

Anyhow, this works. The only problem I had was hitting vis https. That didn't work as I believe the task was being challenged to provide some credentials (which it couldn't as it was being run programmatically). Changing it to http worked and imo doesn't create any kind of security risk.

Thoughts? Better way to implement this? I'd love to hear anything anyone has to offer.

Thanks

无戏配角 2024-08-23 17:53:20

我更喜欢使用 SQL Server 作业发送电子邮件。由于我们已经在 SQL 服务器上运行了多个作业,因此坚持使用这种方法是有意义的。如果我们沿着计划任务路线走下去,我们就会有两个不同的任务计划系统,这会增加不必要的复杂性。由于所有计划任务都通过一个系统进行,因此可以轻松跟踪和维护它们。

I prefer sending emails with a SQL server job. As we already had several jobs running on our SQL server it made sense to stick with this one approach. If we had gone down the scheduled task route we would then of had 2 different task scheduling systems which adds needless complexity. With all scheduled tasks occurring through one system its easy to track and maintain them.

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