Automatically update the website? Windows system services help you busy

  
Windows AutoUpdate is a feature of the Windows operating system that prompts you to download and install when important updates for your computer are released. By using automatic updates, you can update your operating system in the first place, fix system vulnerabilities, and protect your computer. These are the functions that everyone is familiar with, but using the Windows system service to automatically update the website, do you know this? The answer should be no, today we will explain how to use the Windows system service to automatically update the website.
Detailed principle: < Br>1) Windows server:
Windows service uses .Net Framework 2.0 framework, so you should first install .Net Framework2.0,
use an xml file to store configuration information, which needs to be accessed. The URL, example structure is as follows:
<?xml version=1.0 encoding=utf-8 ?>
<root>
<Urls>
<item url=http://Www.***.com time=3:59/>
<item url=http://www.***..com time=11:59/>
<item url =http://www.***..com time=13:59/>
<item url=http://www.***.com time=15:59/>
<item url=http://www.***..com time=16:59/>
</Urls>
</root>
One item represents a visit , url is a specific URL, set to the url address of the website automatically updated, you can set the number of updates with the query string, time indicates the daily access Room, time can only be accurate to 1 minute, and must ensure that each item has only one task at the same url minutes.
The program uses a timer to scan the configuration item for the URL to be accessed every 20 seconds. If there is one, visit the URL once. The relevant code is as follows:
public Job()
{
System.Timers.Timer myTimer = new System.Timers.Timer(20000);
myTimer.Elapsed += new ElapsedEventHandler(myTimer_Elapsed);< Br>myTimer.Enabled = true;
myTimer.AutoReset = true;
XmlDocument xml = new XmlDocument();
xml.Load(AppDomain.CurrentDomain.BaseDirectory + ConfigurationManager.AppSettings[xmlfile]); Br>xmllist = xml.SelectNodes(//root/Urls/item);
}
void myTimer_Elapsed(object source, ElapsedEventArgs e)
{
try
{
Log. SaveNote(DateTime.Now.ToString(yyyy-MM-dd HH:mm:ss) + Heart Work!)
Copyright © Windows knowledge All Rights Reserved