2

Let me give a back ground for everybody before I go to my problem. My company hosts website for many clients, my company also contracts some of the work to another company. So when we first set up a website with all the informations to our clients, we pass that information to the other company we contracted and three of us have the same data. Problem is once the site is up and running, our clients will change some data and when ever they do that we should be able to update our contracted company. The way we transfer data to the contracted company is by using a web service (httppost, xml data). Now my question is what it the best way to write a program which sends updated data to the contracted company everytime our clients change some data.

1) Write a windows service having a timer inside my code where every 30min or so connects to the database and find all changes and send it to the contracted company 2) Write the same code as #1 (with out the timer in it) but this time make it a simple program and let windows scheduler wake it every 30min 3) Any other suggestion you may have

Techenologies available for me are VS 2008, SQLServer 2005

Dene
  • 1,441
  • 2
  • 10
  • 3
  • 1
    Ask the third party how they want the data and in what frequency. – Oded Mar 24 '11 at 20:47
  • 2
    You question is basically windows services versus scheduled tasks. See http://stackoverflow.com/questions/390307/windows-service-vs-scheduled-task – Thomas Li Mar 24 '11 at 20:48

5 Answers5

2

Scheduled task is the way to go. Jon wrote up a good summary of why services are not well suited for this sort of thing: http://weblogs.asp.net/jgalloway/archive/2005/10/24/428303.aspx

Paul Kearney - pk
  • 5,435
  • 26
  • 28
  • valid points, however I've had a lot of issues working with Windows Task Scheduler, not saving credentials, tasks not running after reboot etc, all in all it can take some effort to get things running smooth. Not to mention it has different configuration options for different versions of Windows. I like that with a service I have full control over how my app acts, and can leverage something like Quartz.NET to do what I want. – Can Gencer Mar 24 '11 at 23:22
1

A service is easy to create and install and is more "professional" feeling so why not go that way? Using a non-service EXE would also work of course and would be slightly easier to get running (permissions, etc.) but I think the difference in setup between the two is nearly negligible.

Josh M.
  • 26,437
  • 24
  • 119
  • 200
0

One possible solution would be to add a timestamp column to your data tables.

Once this is done, you can have one entry in each table that has the last collected time by your contracted company. They can pull all records since that last time and update their records accordingly.

0

A Windows Service is more self contained, and you can easily configure it to start up automatically when the OS is starting up. You might also need to create additional configuration options, as well as some way to trigger the synchronization immediately. It will also give you more room to grow your functionality for the service in the future.

A standalone app should be easier to develop though, however you are reliant on the windows scheduler to execute the task always. My experience has been that it is easier to mess up things with the windows scheduler and have it not run, for example in cases where you reboot the OS but no user has logged in.

If you want a more professional approach go with the service, even though it might mean a little bit more work.

Can Gencer
  • 8,822
  • 5
  • 33
  • 52
0

A windows service makes more sense in this case. Think about what happens after your server is restarted:

With a Windows Application you need to have someone restart the application, or manually copy a shortcut to the startup folder to make sure the application gets launched

OR,

With a Windows Service you set it to start automatically and forget about it. When the machine reboots your service starts up and continues processing.

One more consideration, what happens when there is an error? A Windows application would likely show an error dialog and wait for input before continuing; whereas a service would log the error in the event log and carry on.

Winger
  • 676
  • 3
  • 7
  • With an app run as a scheduled task, the the first issue (restarting it) all but goes away -- and the second (death by error dialog) should never even exist in the first place, if the program was written to do the task. – cHao Mar 24 '11 at 21:04
  • You can make a normal app to write to event log as well, that should not be the deciding factor in that case. – Can Gencer Mar 24 '11 at 21:05
  • @cHao @Can Gencer I hear ya, apps written properly should not do this, but I have seen this before in my experience. I had to rewrite one of them as a service ;) – Winger Mar 24 '11 at 21:46