gacanepa
gacanepa

Reputation: 343

Configure web service and method to run on a periodic basis

I would like to automate a web method inside a web service that should run on a periodic basis. I also need to pass some arguments to it at runtime.

Some details:

  1. My development machine has Visual Studio 2012 Professional and IIS Express installed.
  2. The production server has IIS 7.
  3. SQL Server Express 2008 as RDBMS.
  4. The arguments should be taken from a table in the local DB and are subject to change.
  5. Two of the fields in the table (execution_periodic_basis and execution_day) are used to indicate when the web method is supposed to run, i.e., the day can be MONDAY through SUNDAY for WEEKLY runs, or 1 through 28 for MONTHLY runs.

What would be the best approach to accomplish this? If you, based on your experience, have any suggestions on a better way to perform this process, they will be greatly appreciated.

Any tips or links will be more than welcome.

Upvotes: 0

Views: 481

Answers (3)

Kieren Johnstone
Kieren Johnstone

Reputation: 42003

Use a Windows Service. Web Services are not designed for this task!

Upvotes: 0

Noctis
Noctis

Reputation: 11763

Sounds like you'll need to either set timers (so look ahead for the next checkup, and set them), or once every x amount of time, see if it needs to be done.

I'd probably use a background thread with a timer and sleep in between.

Having said that, I'm not sure this question will get much love, as it's not the best "fit wise".

Upvotes: 1

PhillipH
PhillipH

Reputation: 6222

I'd recommend using IIS7.5 AutoStart http://msdn.microsoft.com/en-us/library/ee677260(v=azure.10).aspx site which you then use to Poll the SQL Server database. This AutoStart app (the web equivalent of a Windows Service) can then call your designated URL when the schedule matches its log and the current time.

Upvotes: 1

Related Questions