Scheduler for Web application ASP.NET MVC [closed]

不羁的心 提交于 2019-12-14 01:21:11

问题


I've built a website application by ASP.NET MVC that helps user get RSS news. Of course, it works perfectly. However, I want to expand the function that the website will automatic send hot news to user's email at 6.00 am daily, for example.

I've found solutions on internet but I still confused among using Quartz.NET, Windows Service, and Schedule in windows.

Please tell me where I should begin !

Thanks so much !


回答1:


First of all you will need to create a windows service: http://msdn.microsoft.com/en-us/library/zt39148a.aspx

Quartz.NET has a useful tutorial here: http://quartznet.sourceforge.net/tutorial/lesson_1.html

What I would do would be to initialize your scheduler in the OnStart() override and eventually stop it in the OnStop().

Basically you can define triggers using the Trigger class and Jobs by creating an implementation of the IJob interface, then use the scheduler to attach triggers to jobs. Everytime a trigger fires, the Execute method of the Job is run.

Putting the entire explanation here would be way too long, but following the tutorials should get you where you want to be in matter of minutes. Good luck!

Of the other end, there is a much simpler solution than writing a windows service. Just write a console app and then, through the Task Scheduler interface (Control Panel -> Administrative Tools in Win 7), create a task that runs your app at the time you want. For a simple task that needs to run once a day this is probably a better solution rather than keeping a service up 24/7.



来源:https://stackoverflow.com/questions/17296183/scheduler-for-web-application-asp-net-mvc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!