The AppLife Update Blog

  • Application Update Customization using Custom Data

    When publishing updates for applications, it is often helpful to implement rules that can be applied on an update-by-update basis. With AppLife Update, the custom data field provides this opportunity.

    clip_image001

    With each update, you can specify a custom data string to go with the update. This value is then available to your application after an update check has been performed. Your application can interrogate the value and control additional logic based on the information. As an example, when creating updates for AppLife Update, we use this field to know whether or not the update requires Visual Studio to be closed. If it does, we add a RequiresVSClosed property to the custom data field.

    Accessing the Custom Data in Your Application

    After an update check, the update controller has a CurrentUpdate property that holds an UpdateInformation object. This object has a CustomData property that holds, you guessed it, the Custom Data string that you specify when publishing the update.

     

    Code Snippet

    1.if(updateController1.CheckForUpdate()) {

    2.   string customData = updateController1.CurrentUpdate.CustomData;

    3.}

    Changing Custom Data after Publication

    Custom Data can be modified after an update has been published without having to re-build the update package itself. To modify custom data, you can Manage Published Updates…

    From the Manage Published Updates dialog the Custom Data string can be modified and then published.

    clip_image002

    A Class to Parse Name/Value Pairs

    A common approach to be able to provide multiple pieces of information through the custom data string is to use a name/value pair syntax, and then extract this information within your application code. To help with this, here is a class that will parse a custom data field using a name=value; syntax.

    AppUpdateCustomData.cs and AppUpdateCustomData.vb

    Using this class, you can easily extract and use multi-value custom data strings in your applications.

    clip_image003

    Using the AppUpdateCustomData class:

     

    Code Snippet

    1.  if(updateController1.CheckForUpdate()) {

    2.    Kjs.AppLife.Update.AppUpdateCustomData customData = new Kjs.AppLife.Update.AppUpdateCustomData(updateController1.CurrentUpdate.CustomData);

    3.   

    4.    string myValue1;

    5.    string myValue2;

    6.   

    7.    if(customData.DataTable.ContainsKey("MyName1")) {

    8.      myValue1 = customData.DataTable["MyName1"];

    9.    }

    10. 

    11.  if(customData.DataTable.ContainsKey("MyName2")) {

    12.    myValue2 = customData.DataTable["MyName2"];

    13.  }

    14.}

    In conclusion, the Custom Data field provides the means for update publishers to assign information to individual update packages that applications can use to control application update behavior.

    Posted at 18 September, 2012 | By :Brian Haas | Categories : AppLife Update | Software Updating |