The AppLife Update Blog

  • Replicate Updates Locally

    In situations where there are many deployed systems located on the same local network combined with a need to minimize bandwidth utilized in retrieving application updates it is advantageous to provide a means to download update packages only once for everyone. With a new feature of AppLife Update 5.0, creating this ability is quite easy.

    After an Update Controller checks for and downloads available updates, you can now save the downloaded package(s) and Director.Xml file to a local folder by calling the Update Controllers SaveUpdatesToLocal method.

    As an example, let’s modify the C# Simple Quick Start project that ships with AppLife Update to first check a local folder for updates before checking the public location. Any updates downloaded from the public location will be copied locally for other local systems to find. To accomplish this, we’ll add a few Main form variables to hold the Public and Local update locations.

    public partial class Form1 : Form {
     
      private string mPublicUpdatePath = @"http://www.kin…/SaveToLocalExample";
      private string mLocalUpdatePath = @"P:\Updates\SaveToLocalExample";
     

    This Quick Start uses the UpdateDisplay control to manage the update process.  To integrate with that process, we will use the CheckForUpdateCompleted and the DownloadUpdateCompleted events of the Update Controller.

    Basically we are going to initially check the local update folder for updates.  If no updates are found locally, we’ll check the public update folder.  If we find any updates in the public location, we’ll save them locally with the new SaveUpdatesToLocal method.  So here goes. 

     

    Modify the Update Controller’s default Update Location to be the local update path, and then attach to the two events.

    image

    image

     

    First, lets handle the CheckForUpdateCompleted event.  This event fires whenever the Update Controller completes an update check.  If the private location was checked, we’ll just switch to the public location and check again.

     

    private void updateController1_CheckForUpdateCompleted
    	(object sender, CheckForUpdateCompletedEventArgs e) {
     
    	UpdateController c = sender as UpdateController;
     
    	if(c.UpdateLocation == mLocalUpdatePath) {
    		//we checked the local path.  If we didnt find any
    		//updates, lets check the public path
    		c.UpdateLocation = mPublicUpdatePath;
    		c.CheckForUpdateAsync();
    	}
    }

     

    And then finally, in the DownloadUpdateCompleted event, we’ll look to see if the update that was just downloaded came from the public location.  If so, we’ll save it to the local folder using the new method.

    private void updateController1_DownloadUpdateCompleted
    	(object sender, AsyncCompletedEventArgs e) {
     
    	UpdateController c = sender as UpdateController;
     
    	if(c.UpdateLocation == mPublicUpdatePath) {
    		//downloaded an update from the public path. Save it locally
    		c.SaveUpdatesToLocal(mLocalUpdatePath, false);
    	}
    }

     

    If multiple update packages were downloaded as a chain collection, all of the update packages will be saved by the SaveUpdatesToLocal method.

    Posted at 1 March, 2015 | By :Brian Haas | Categories : AppLife Update |