Updater Application Block 2.1 usage and extension

Source: Internet
Author: User
Updater Application Block 2.1 usage and extension
Overview

Updater Application Block (UAB) is an automatically updated component developed in the early stage of Microsoft patterns & Practices (Mode & Practice Group (.. NET 2.0), so the latest version will stop updating when it reaches 2.0.

UAB uses automatic updates in "Push mode" to release new versions without user intervention;

Application scenarios

Keep the application in the latest version.

You can use multiple plug-ins

Keep the latest data files

Add a self-update function for the Application

Smooth upgrade of applications to clickonce (. NET 2.0) to smooth upgrade of applications to clickonce (. NET 2.0)

Effective Bandwidth utilization

Perform complex upgrades

Main functions

Simpler public APIs

Client update method 4 lines of code handle client update

// Get the Updater Manager

Applicationupdatermanager
Updater = applicationupdatermanager. getupdater ();

// Check version

Manifests = Updater. checkforupdates ();

// Update the application as per manifest details.

Updater. Download (manifests, timespan. maxvalue );

// Activate process.

Updater. Activate (manifests );


 

The newly added event mechanism allows applications to add custom actions to each update stage.

Updater. downloadstarted + = new
Downloadstartedeventhandler (updater_downloadstarted );

Updater. downloadprogress + = new
Downloadprogresseventhandler (updater_downloadprogress );

Updater. downloadcompleted + = new
Downloadcompletedeventhandler (updater_downloadcompleted );

Updater. downloaderror + = new
Downloaderroreventhandler (updater_downloaderror );

Updater. activationinitializing + = new
Activationinitializingeventhandler (updater_activationinitializing );

Updater. activationstarted + = new
Activationstartedeventhandler (updater_activationstarted );

Updater. activationinitializationaborted + = new
Activationinitializationabortedeventhandler (updater_activationinitializationaborted );

Updater. activationerror + = new
Activationerroreventhandler (updater_activationerror );

Updater. activationcompleted + = new
Activationcompletedeventhandler (updater_activationcompleted );

Partial update supported

Select the file you want to update

 

Use event monitoring to download

Supports Windows Installer

List, downloader, and activation Module

Graphical management tools

Function module

Updater Management Subsystem

-Applicationupdatermanger

-Registrymanager

-Updatertask

Manifest Management Subsystem

Downloader Subsystem

Activation Subsystem

The update process is very simple:

1. The application detects updates through applicationupdatermanager.

2. applicationupdatermanager uses manifestmanager to download the XML list

3. downloadmanager transfers files using bitsdownloader

4. activationmanger uses activationprocessor to activate the file version

 

Function Expansion

Because the built-in update does not support updating the file directory tree, I guess it is not supported because the file directory is downloaded via HTTP on the server side through IIS; the directory structure is relatively simple to update Windows form applications. However, if a web application is updated, the directory structure is relatively complex and contains several layers of directories, therefore, using its own update function is almost impossible.

To solve this problem, I think of the following ideas:

1. Rewrite the idownloader method and create an ftpdownloader. You can use the ftp get command to get the download of the directory. For the rewrite class, refer to bitsdownloader. CS or someone on the Internet to develop an httpdownloader;

2. Use MSI to download and install the update, but you need to participate in the update point next

3. Use WinZip to package and compress the package, download it to the local device, and decompress it to the target path. In this way, you can make good use of network loans and solve the problem of overwriting and updating multiple file directories.

 

Decompressing files Activation Process

To adopt the third scheme, you must develop a custom decompress files activationprocessor to decompress the downloaded file to the specified directory;

. Net WinZip. gzip files use the open-source icsharpcode. sharpziplib. dll version 8.5 to easily decompress/compress files and file directories.

 

Source code analysis

UAB itself provides a lot of activationprocessor

You can know the functions of these classes by using the class name.

Open a class library and you will find that iactivationprocessor is implemented.

Create an unzipprocessor

 

Decompress the code

 

Extended unzipprocessor editing UI

The decompressed ZIP file contains two parameters:

Create extension parameter class unzipprocessitem

The Code is as follows:

Extended UI editing page unzipprocessoreditor. CS

The Code is as follows:

 

Register newly developed components

 

 

Test

OK

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.