As long as the distribution is in the form of download ClientProgram, Most of them require automatic upgrade. Currently, the mainstream automatic program upgrade policy is to re-download the latest installation package and then reinstall the entire client. This method is simple and intuitive, but its defects are also obvious. For example, even if the entire client has 100 MB, and this update only modifies a 1 k dll, it also means to download all the content of MB. This is a great waste of bandwidth, and it has extended the upgrade time, and correspondingly increased the waiting time of the customer.
In the above scenario, can we update only the modified 1 k dll during automatic upgrade? Of course, it is easy to use the automatic upgrade System of us. The automatic upgrade System of us can manage versions of each file in the distributed client program. The basic unit for each upgrade is not the entire client program, but a single file. Update a single file in three forms:
(1) The file is modified.
(2) The file is deleted.
(3) Add a new file.
Oaus supports these three forms of file updates. Each automatic upgrade can change n files, delete M files, and add new L files.
1. oaus Structure
Oaus provides directly executable server programs and client programs: autoupdatersystem.server.exe and autoupdater.exe. The directory structure of the oaus server is as follows:
Through tcpcommunication between the client and the server, you can configure the TCP port through which the server provides the automatic upgrade service in the autoupdatersystem.server.exe. config configuration file.
The filefolder folder is initially empty and is used to deploy the latest versions of each file of the program to be distributed.Note that the file structure under it must be exactly the same as that of the program to be distributed after normal deployment-that is, it is equivalent to deploying a program to be distributed under the filefolder folder.
The directory structure of the oaus client is as follows:
You can configure the IP address and port of the US us server in the autoupdater.exe. config configuration file, as shown in the following figure:
< Configuration >
< Appsettings >
<! -- Server IP Address -->
< Add Key = "Serverip" Value = "127.0.0.1" />
<! -- Server Port -->
< Add Key = "SERVERPORT" Value = "4530" />
<! -- The name of the executable program to be called back after the upgrade. -->
< Add Key ="Callbackexename" Value = "Demo.exe" />
<! -- Title of the main form -->
< Add Key = "Title" Value = "File update" />
</ Appsettings >
</ Configuration >
Pay attention to the configured callbackexename, which indicates the name of the EXE of the dispatching program to be started after the upgrade is complete. Why is the callbackexename configured by name instead of path? This is because there are requirements for using and deploying the oaus client:
(1) the executable file EXE of the program to be distributed must be located in the root directory of the deployment directory.
(2) The client of oaus (that is, the entire autoupdater folder) must also be located in this root directory.
In this way, autoupdater knows the relative path of the distribution program's exe, so that it can determine the absolute path of the distribution program's exe, so you can start the target EXE after the upgrade is complete. In addition, according to the above two conventions, combined with the structure conventions of the filefolder folder of the server mentioned above, when the server updates a file, autoupdater can determine the absolute path of the file on the client machine.
Ii. Automatic Upgrade process for us
Next we will explain in detail how to use oaus to build an automatic upgrade system,The procedure is as follows.
1. Run the oaus server.
The main interface of the server displays information about all the OA clients that are being automatically upgraded.
2. Place all the content of the client program to the filefolder folder of the oaus server. The structure of the client program should be exactly the same as that of the client program after normal deployment. We deploy videochatsystem as an example.
3. Use the oaus server to generate a default version number for each file of the client program to be distributed, and create the updateconfiguration. XML version configuration file. This configuration file will also be used by the client.
Click the version management sub-menu under tools on the server. The file version information form for managing each file version is displayed.
Double-click any row in the list to modify the version value of the corresponding file (float type value ). Note: The version information in this list and the actual version attributes of the file (for example, the dll version attribute X. x. x. x) It can be unrelated. The version value in the list is only used to mark whether the file is modified. Therefore, each time the file is modified, the value of the corresponding version in the list should be increased.
When the [file version information] form is closed, the value (INT type) of the "Last integrated version" increases by 1 as long as a file version changes. Compare the value of the "final integrated version" Saved by the client of oaus with the value of the latest "final integrated version" of the oaus server, you can quickly identify whether the client is the latest version.
In addition, when this window is opened for the first time, a version configuration file updateconfiguration. XML is automatically generated under the directory of the oaus server. In addition, every time you use this form to set a new version of a file, updateconfiguration. XML is automatically updated at the same time.
4. Add updateconfiguration. XML to the Client Program (that is, the folder of the autoupdater mentioned above) of oaus.
5. when creating the installation program of the client to be distributed, package the client of oaus (that is, the folder of autoupdater) and, as mentioned above, you need to deploy it directly under the running directory (basedirectory) (the same directory as the distribution exe ).
In this way, the preparation is complete. After the client installs videochatsystem through the installation package, its directory structure is as follows:
6. When we want to release a new version, such as updating a file (because the file is modified), we can do this:
(1) copy the modified file to the correct location (or overwrite the old file) in the filefolder folder on the us server ).
(2) Open the [file version information] form on the oaus server, double-click the row corresponding to the modified file, modify the version number of the corresponding file on the pop-up form, and increase the value of the version number. (If you want to delete an old file or add a new file, you can also perform operations here)
7.for example, when the client starts autoupdater.exe again, it will automatically upgrade and update the files that have changed. In the following example, autoupdater.exe is run.
8. After the upgrade is complete, the callback EXE configured in the preceding oaus client configuration file will be started. (Videochatsystem.exe in this example)
9.oaus the client will log on to the log file updatelog.txt (located in the autoupdater folder and automatically generate the file when the oaus client is running for the first time), recording the status of each automatic upgrade.
Iii. When will automatic client upgrade be started?
If a system downloads a client, how does the client know whether a new version is available? Then why should I start autoupdater.exe?
Our experience is as follows: after successfully logging on to the client, obtain the value of "final comprehensive version" from the server and compare it with the value of the local "final comprehensive version, if the local value is small, the client needs to be updated. This process can be achieved as follows:
(1)When a new file is placed in the filefolder folder of the oaus server, and the version number is correctly updated through the [file version information] form, when the [file version information] form is closed, the value of the latest integrated version is displayed. Record this value and pass it to the memory of the system's own server (for example, the server provides an input box to input this value ).
(2) The System Client can obtain the local "final comprehensive version" value by referencing autoupdatersystem. Core. dll and calling the static method getcurrentversion of versionhelper.
(3) After successfully logging on to the system client, you can obtain the latest "final integrated version" value from the server and compare it with the local value.
After comparison, if the client needs to be upgraded, there are usually two modes: the user selects whether to upgrade or force upgrade.
Generally, if the latest client program is compatible with the old version and does not affect the upgrade, you can decide whether to upgrade it. If the latest client program is not compatible with the old version or has a major update, the Force upgrade will be started. If the process is to be imported into the startup upgrade, you only need to start autoupdater.exe in the file folder of autoupdater. To disable the current client process, after the autoupdater.exe process is started, some files may fail to be overwritten.CodeIt is roughly as follows:
IntVersion =...//Get from server
If(Versionhelper. Getcurrentversion () <version)
{
StringUpdateexepath = appdomain.Currentdomain. Basedirectory +"Autoupdater \ autoupdater.exe";
System. Diagnostics. Process myprocess = system. diagnostics.Process. Start (updateexepath );
......//Exit the current process
}
4. Download oaus
Oaus-free
Certificate -----------------------------------------------------------------------------------------------------------------------------------------------
For any questions about esframework, please contact us:
Tel: 027-87638960
Q: 168757008
Email:Master@oraycn.com