开发者

MVC .NET Web app that does something every week

I am building a Web application using MVC3 .NET

The app should somehow keep a weekly todo list for each开发者_运维技巧 user. On Fridays, all todo lists must be reset.

Can someone help with that.

thanks


You may take a look at Quartz.NET. This being said, the culprit of handling scheduled jobs by a web application is that the web server could unload this ASP.NET application under some circumstances (memory or CPU threshold is hit, the application is not used for a long time, ...). For this reason it is recommended to develop a separate process that will perform those tasks. This process could be hosted for example in a Windows Service which is guaranteed to run all the time.

Another possibility is to simply use the Windows Scheduler in order to launch some custom made executable on a weekly basis which will take care of performing the necessary tasks.


If this is some database-level task, then perhaps a scheduled-task (or crontab on nix). There is no need for MVC to do that. If you really want, the scheduled-task could just hit a route on the web-site.

However, personally I'd simply partition the data with a week-number (or a start date), so that when I get the data, I'm getting the data for the week starting (your date). Then:

  1. there is nothing to do
  2. you have access to history as needed

i.e. add StartDate (or similar) as a column on your existing storage, and use that to select the most timely data. You will get calls about "I need the data from last week" - you might as well built it in from the outset. Besides... if something isn't done on Friday, that doesn't mean it ceases to exist...


do you expect the application to always be up and running? what if nobody is using it on midnight between Thursday and Friday? How can you then execute those jobs?

in general since a web application is not surely running at any given time, you cannot rely on timers inside the web application.

I think best solutions in this case would be to either create a windows service which will be installed on the server and will be always running by definition... a bit like reinventing same things again and again...

or you could also set a scheduled task in windows to call your web application, creating a request to a specific page every Friday, then the web application gets invoked with some parameters and you can do what you need.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜