Automatically update the website? Windows system service helps you

  

Windows automatic update is a feature of the Windows operating system, when the important update for your computer is released, it will prompt you to download and install. 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 you can use 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.

Principle:

1) Windows Server:

Windows Services uses the .Net Framework 2.0 framework, so you should first install .Net Framework 2.0 when using it,

An xml file stores configuration information, which stores the URLs that need to be accessed. The example structure is as follows:

<?xml version=1.0 encoding=utf-8 ?>

<root>< Br>

<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>

An item representative The second visit, url is the 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 time of daily access, time can only be accurate to 1 minute, and each item must be guaranteed There is only one url task in the same minute.

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);

myTimer.Enabled = true;

myTimer.AutoReset = true;

XmlDocument xml = new XmlDocument();< Br>

xml.Load(AppDomain.CurrentDomain.BaseDirectory + ConfigurationManager.AppSettings[xmlfile]);

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!); Previous12Next Total 2 Pages

Copyright © Windows knowledge All Rights Reserved