views:

238

answers:

3

Hi

I have xml data I access through a web service. I need to read the data and copy it locally. The below code works fine. I need now to run this code at least twice or three times a day wihout manual intervention. How do I do that? Thanks!

using System;
using System.Collections;
using System.Data;
using System.Xml;


 class MainClass{
public static void Main(){
XmlDocument doc = new XmlDocument();
// read
doc.Load(new System.IO.StringReader(GetContracts()));

// write
XmlTextWriter tw = new XmlTextWriter( "testOut.xml", null );
tw.Formatting = Formatting.Indented;
tw.Indentation = 4;
doc.Save( tw );
tw.Close();
}
}
+1  A: 

It really depends on how you want the scheduling to be done. If it is only a few times a day, I would just schedule the application to be executed on a regular basis using the Task Scheduler within Windows.

Mitchel Sellers
Hi, thanks for your help. If I want this update to be done hourly, for example, how should it be done?
netNewbi3
Even hourly, you can setup via Task Scheduler.
Mitchel Sellers
A: 

Quartz is a good scheduler for java, of course you will either need to setup the jar to start with windows or install on an application server like Tomcat or Jetty.

http://www.quartz-scheduler.org/

Andy Trujillo
+2  A: 

Use Task Scheduler. There's a GUI and a Command Line interface to set up tasks.
If you use the GUI, find it in Start....Control Panel....Administrative Tools... on Vista. You'll be able to figure out how to run your think hourly, pretty easily.

alt text

if you use the command line, check the doc: http://msdn.microsoft.com/en-us/library/bb736357(VS.85).aspx

schtasks.exe /create /tn "My Task" 
            /tr "C:\path\to\the\app.EXE arg1 arg2" 
            /sc DAILY /RI HOURLY  
            /st 12:00:00 /ru username /rp password

(The above should be all-on-one-line)

Cheeso