I. Origins
Has previously written two articles on the design and implementation of the automatic Upgrade system Oaus (first, second), adding the ability to automatically detect file changes for the Oaus server (so that you can save a lot of time each time you deploy a version upgrade, and you can avoid the errors caused by manual modifications), Some users have also put forward a very good suggestion: to increase the breakpoint Oaus function. Because if the network status is not very good, often in the upgrade to half time, because the Oaus client dropped the upgrade failed, this time, you must restart the entire upgrade process. Even if the upgrade is interrupted, the 99% has been completed and must be re-started. Therefore, it is very necessary to increase the breakpoint continuation function for Oaus.
Now, the latest version of the Oaus has added this important feature, when the upgrade due to fall off, when the Oaus client does not quit, but always try to connect the disconnection, after the successful re-connection, the last interruption from the place to continue the upgrade. As shown in the following:
When the network status is very poor, may be in the process of an upgrade, there will be multiple disconnection of the situation, it does not matter, Oaus client will continue to work until the entire upgrade process is complete.
Two. Source code implementation
The following is a brief description of the code implementation of the specific process, Oaus breakpoint continuation function is implemented at the client, the server does not need to make any changes.
1. Scheduled network connection Disconnect event, get off the line notification. At this point, it is necessary to record that the upgrade is interrupted when the first few files are upgraded.
2. Scheduled to re-connect the success time, get the network link recovery notification. At this point, you start to re-download the next file that needs to be upgraded.
voidrapidpassiveengine_relogoncompleted (logonresponse res) {if(Res. Logonresult = = Logonresult. SUCCEED) { This. Downloadnextfile (); This. Logger. Logwithtime ("re-connect success, start to continue! "); if( This. Updatecontinued! =NULL) { This. Updatecontinued (); } return; } }
Private voidDownloadnextfile () {if( This. Haveupgradecount >= This. FileCount) { return; } downloadfilecontract downloadfilecontract=New downloadfilecontract(); Downloadfilecontract.filename= This. downloadfilerelativelist[ This. Haveupgradecount]; //request to download the next file This. RapidPassiveEngine.CustomizeOutter.Send (Informationtypes. Downloadfiles,Compactpropertyserializer. Default.serialize(downloadfilecontract)); }
With the above logic processing, the Oaus already has the function of the continuation of the breakpoint. The code looks very simple, because the internal core of the file transfer function, the breakpoint continuation function is encapsulated by the esframework. When adding the breakpoint continuation function for Oaus, it is not necessary to implement the tedious business logic associated with the continuation of the breakpoint again.
3. Instructions on how to use the Oaus upgrade mechanism
In general, if the latest client program is compatible with older versions and does not have a significant impact, it can be left to the user to decide whether to upgrade, or if the latest client program is incompatible with the old version, or if there is a major update, a forced upgrade will be initiated. If the process is going to start the upgrade, just start the Autoupdater folder under AutoUpdater.exe . Note that after starting the AutoUpdater.exe process, to exit the current client process, some files may fail because they cannot be overwritten. The code is roughly as follows:
if (versionhelper. Hasnewversion (Oausserverip,oausserverport)) { AppDomain. Currentdomain.basedirectory + "autoupdater\\autoupdater.exe"; System.Diagnostics. Process myprocess = system.diagnostics. Process. Start (Updateexepath); ...//exiting the current process
Three. Related Downloads
1. Automatic Upgrade system Oaus-source code
2. Automatic Upgrade System Oaus (can be deployed directly)
3. Automatic Upgrade system Oaus-User manual
If you have any suggestions or questions, please leave a message to me.
Design and implementation of automatic upgrade System (cont. 2)--Increase the breakpoint continuation function (with the latest source code)