Abstract: software maintenance and upgrade is the most important part in the software life cycle. In order to solve the problem of low efficiency of client software upgrade in C/S (Client/Server) mode, the C/S application system automatic upgrade processing program is designed. The program uses Web Services technology, C #, and XML language to automatically upgrade the C/S application system through the network. Compared with the original manual upgrade, FTP file server upgrade, and third-party control upgrade, the upgrade is more efficient. This solution has good reference value.
Keywords: C #; web services; XML; automatic software upgrade
Method classification: Document flag code:
1 Introduction
With the continuous development of computer network application technology, most MIS systems are developed based on the C/S (Client/Server) mode or B/S (Browser/Server) mode. At present, the B/S model is dominant in its true advantage of the thin client/fat server model. However, because the Client/Server mode features low data traffic, short response time, and high security, it is able to address the LAN of dozens of to hundreds of users, it is still a good choice [1-3]. In C/S mode, every upgrade of an application requires you to reinstall the application on each client. This is a very tedious task. In the face of this practical problem, we have designed a technical solution for automatic upgrade through software, which makes up for this defect and has good reference value.
2. Design Concept
To determine whether a file is to be updated, You Can [3-5] by determining the file size, modification date, and version number. If the latest version is found, the system prompts the user whether to upgrade.
Implement a getver webmethod in web services to obtain the latest version. Compare the current version with the latest version. If a new version is available, upgrade the version.
3. Technical Implementation of Automatic Upgrade
(1) Compile the update. XML template file.
Prepare an XML file (update. XML) as a template for upgrade.
......
<Description> Upgrade history </description>
<Filelist COUNT = "4" sourcepath = "./update/">
......
<Item name = "customerapplication.exe" size = "">
<Value/>
</Item>
<Item name = "InterOP. shdocvw. dll" size = "">
<Value/>
</Item>
......
Shdocvw. dll is a component of Internet Explorer that controls the processing of URLs and information returned from Web sites.
(2) Compile the getver Method for Web Services
The getver method is used to obtain the updated version of the software.
[Webmethod (description = "get updated")]
Public String getver ()
{
Xmldocument Doc = new xmldocument ();
Doc. Load (server. mappath ("Update. xml "));
Xmlelement root = Doc. documentelement;
Return root. selectsinglenode ("version"). inertest;
}
(3) Compile the getupdatedata method of Web Services
The getupdatedata method is used to update software online.
[Webmethod (description = "online update software")]
[Soapheader ("sheader")]
Public System. xml. xmldocument getupdatedata ()
{
// Verify whether the user logs in
If (sheader = NULL)
Return NULL;
If (! Dataprovider. getinstance. checklogin (sheader. username, sheader. Password ))
Return NULL;
// Obtain the updated XML template content
Xmldocument Doc = new xmldocument ();
Doc. Load (server. mappath ("Update. xml"); C xmlelement root = Doc. documentelement;
// Check whether several files need to be updated.
Xmlnode updatenode = root. selectsinglenode ("filelist ");
String Path = updatenode. attributes ["sourcepath"]. value;
Int COUNT = int. parse (updatenode. attributes ["count"]. value );
// Replace the value in XML with the actual content
For (INT I = 0; I = updatenode. childnodes [I];
String filename = path itemnode. attributes ["name"]. value;
Filestream FS = file. openread (server. mappath (filename ));
Itemnode. attributes ["size"]. value = FS. length. tostring ();
Binaryreader BR = new binaryreader (FS );
// The actual content of the file, which is base64string encoded
Itemnode. selectsinglenode ("value"). innertext = convert. tobase64string (Br. readbytes (INT) fs. length), 0, (INT) fs. Length );
BR. Close ();
FS. Close ();
}
Return Doc;
}
(4) Compile the update method of the Client
Reference this web service first, for example, websvs,
String nver = start. getservice. getver ();
If (application. productversion. compareto (nver) <= 0)
Update ();
In this Code, start. getservice is a static instance of websvs. Function: first check the version and compare the result with the current version. If it is a new version, run the update method.
Update downloads the upgraded XML file and saves it as an update. xml file under the execution file directory. After the task is completed, exit the program and wait for update. EXE to upgrade.
Void Update ()
{
This. statusbarpanel1.text = "downloading ...";
System. xml. xmldocument Doc = (system. xml. xmldocument) Start. getservice. getupdatedata ());
Doc. Save (application. startuppath @ "\ update. xml ");
System. Diagnostics. process. Start (application. startuppath @ "\ update.exe ");
Close ();
Application. Exit ();
}
(5) Compile the client's update. exe
Update.exe provides the following functions: first, find the main process. If it is not disabled, use process. Kill () to close the main program. Then, an xmldocument is used to load the update. xml file generated by the program. Use the specified path and file name in the XML file to generate the specified file, and delete the previously existing file. After the update, restart the main application. This completes the update.
Private void form1_load (Object sender, system. eventargs E)
{
System. Diagnostics. Process [] PS = system. Diagnostics. process. getprocesses ();
Foreach (system. Diagnostics. Process P in PS)
{
// MessageBox. Show (P. processname );
If (P. processname. tolower () = "customerapplication ")
{
P. Kill ();
Break;
}
}
Xmldocument Doc = new xmldocument ();
Doc. Load (application. startuppath @ "\ update. xml ");
Xmlelement root = Doc. documentelement;
Xmlnode updatenode = root. selectsinglenode ("filelist ");
String Path = updatenode. attributes ["sourcepath"]. value;
Int COUNT = int. parse (updatenode. attributes ["count"]. value );
For (INT I = 0; I = updatenode. childnodes [I];
String filename = itemnode. attributes ["name"]. value;
Fileinfo Fi = new fileinfo (filename );
Fi. Delete ();
// File. Delete (application. startuppath @ "\" FILENAME );
This. label1.text = "updating:" FILENAME "(" itemnode. attributes ["size"]. Value ")...";
Filestream FS = file. open (filename, filemode. create, fileaccess. write); FS. write (system. convert. frombase64string (itemnode. selectsinglenode ("value "). innertext), 0, Int. parse (itemnode. attributes ["size"]. value ));
FS. Close ();
}
Label1.text = "updated ";
File. Delete (application. startuppath @ "\ update. xml ");
Label1.text = "Restarting the application ...";
System. Diagnostics. process. Start ("customerapplication.exe ");
Close ();
Application. Exit ();
}
For the sake of simplicity, the asynchronous method is not used. Of course, the asynchronous method can better avoid conflicts arising from concurrent calls. This requires the reader to add it by himself.
4 Conclusion
With the help of Web Services, automatic software upgrade is not only easy to design, but also easy to implement. It has achieved good effects and greatly reduced the maintenance workload. This solution has good reference value.
References
[1] Implementation of Automatic Upgrade of client software in C/S mode [J]. Microcomputer Applications, 2005 (5), 290-293
Yang Ji-Jia, Zhang Li-jing, Zhang Xiao-lei.An realization of automatically updating orienting to C/S application system [J]. Microcomputer Applications, 2005 (5), 290-293
[2] He aviation school, Jiang Zhaoyuan. an improved general client automatic upgrade model and implementation [J]. journal of Lanzhou Jiaotong University (Natural Science Edition), 2005 (8), 110-113
He hang-Xiao, Jiang Zhao-yuan.An improved universal auto upgrade model of client and its realization. Journal of Lanzhou Jiaotong University (Natural Sciences), 2005 (8), 110-113
[3] wooyun gaowa. Implementation and Application of Dynamic upgrade in MIS [J]. Computer engineering and design, 2005 (10), 2854-2856
Wuyun Gao-wa.Implementation and application of dynamic upgrade technique in MIS [J]. Computer engineering and design, 2005 (10), 2854-2856
[4] ye Lihua, Tao Hongcai, Liang Tian. online software upgrade technology based on COM [J]. Journal of Chengdu Institute of Information Engineering, 2005 (2), 73-75
Ye Li-hua, Tao hong-Cai, Liang Tian. Software live Updating Technology Based on COM [J]. Journal of Chengdu University of Information Technology, 2005 (2), 73-75
[5] Yu Ying, Dong xuyuan, Gao Hong. how to manage the information system in C/S Mode for automatic upgrade and maintenance [J]. journal of Jiamusi University (Natural Science Edition), 2005 (4), 200-202
Implementation of Software auto-update by Web Services
Abstract: The software maintaining and updating is an important section in the software life cycle. this paper makes use of the technology of Web Services, C # and XML language, to resolve the poor efficiency of client's updating in old c/s application system. the automatically updating program can detect the new version, download the Updating file, automatically backup and rollback. it makes the Software updating by the client automatically, and it is practical.
Keywords: C #; web services; XML; Software auto-update