zoukankan      html  css  js  c++  java
  • Release a AutoUpdater tool

    Description

    Fixing bugs and adding new features is a part of developing software applications. From my experience, sending application updates to users is also a critical part of developing applications, especially when the user has no advanced knowledge of computers. In the Internet era today, the software developer must make application deployment and updating easier and often makes automatic application updates to do this.I already searched through the internet on this topic, but not much seems suited to my needs. So, I tried to create one myself. This sample application is developed in C# as a library with the project name “AutoUpdater”. The DLL “AutoUpdater” can be used in a C# Windows application(WinForm and WPF).

    About the features

    There are certain features about the AutoUpdater:

    1,Easy to implement and use.
    2,Application automatic re-run after checking update.
    3,Update process transparent to the user .
    4,To avoid blocking the main thread using multi-threaded download.
    5,Ability to upgrade the system and also the auto update program.
    6,A code that doesn't need change when used by different systems and could be compiled in a library.
    7,Easy for user to download the update files.

    The following UI

    There are two pages and very pretty simple,just as follows:

    2010-10-13 18-05-02

    Figure 1

    2010-10-13 18-05-41

    Figure 2

    How to use?

    In the program that you want to be auto updateable, you just need to call the AutoUpdate function in the Main procedure. The AutoUpdate  function will check the version with the one read from a file located in a Web Site/FTP. If the program version is lower than the one read the program downloads the auto update program and launches it and the function returns True, which means that an auto update will run and the current program should be closed. The auto update program receives several parameters from the program to be updated and performs the auto update necessary and after that launches the updated system.

          #region check and download new version program
          bool bHasError = false;
          IAutoUpdater autoUpdater = new AutoUpdater();
          try
          {
              autoUpdater.Update();
          }
          catch (WebException exp)
          {
              MessageBox.Show("Can not find the specified resource");
              bHasError = true;
          }
          catch (XmlException exp)
          {
              bHasError = true;
              MessageBox.Show("Download the upgrade file error");
          }
          catch (NotSupportedException exp)
          {
              bHasError = true;
              MessageBox.Show("Upgrade address configuration error");
          }
          catch (ArgumentException exp)
          {
              bHasError = true;
              MessageBox.Show("Download the upgrade file error");
          }
          catch (Exception exp)
          {
              bHasError = true;
              MessageBox.Show("An error occurred during the upgrade process");
          }
          finally
          {
              if (bHasError == true)
              {
                  try
                  {
                      autoUpdater.RollBack();
                  }
                  catch (Exception)
                  {
                     //Log the message to your file or database
                  }
              }
          }
          #endregion

    That’s all and just enjoy it!

    About the solutions

    The application is pretty simple,just contains two pages and some helper classes.

    autoupdatersolution

    Figure 3

    License

    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    About the Author

    you can download the tool via http://autoupdater.codeplex.com/,If in doubt please contact me,Thanks!


    作者:圣殿骑士
    出处:http://www.cnblogs.com/KnightsWarrior/
    关于作者:专注于微软平台项目架构、管理和企业解决方案。自认在面向对象, 面向服务以及微服务领域有一定的造诣,熟悉设计模式、TDD、极限编程、领域驱动、架构设计、敏捷开发和项目管理。现主要从事.NET/.NET Core, Go, JavaScript/TypeScript, Azure/AWS等云计算方面的项目开发、架构、管理和企业培训工作。如有问题或建议,请多多赐教!
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接。如有问题,可以邮件:KnightsWarrior(at)msn(dot)com  微博:圣殿骑士微博  联系我,非常感谢。

  • 相关阅读:
    如何选择开源许可证?(转)
    gdb的使用(转)
    git的使用
    2017-3-13 leetcode 4 11 15
    2017-3-12 leetcode 167 209 216
    2017-3-11 leetcode 217 219 228
    2017-3-10 leetcode 229 238 268
    1175: 零起点学算法82——find your present
    1174: 零起点学算法81——求整数绝对值
    1173: 零起点学算法80——求实数绝对值
  • 原文地址:https://www.cnblogs.com/KnightsWarrior/p/1854502.html
Copyright © 2011-2022 走看看