Exemplo n.º 1
0
 public static void RunUpdateProcByTimeSpan()
 {
     while (true)
     {
         Logger.Info("Start check update server version");
         BarControl.InitAllParam();
         if (CheckUpdate())
         {
             if (Utils.ExtractFile(downloadPackagePath, basePath))
             {
                 Logger.Info("ExtractFile success");
                 RunUpateProc();
             }
             else
             {
                 Logger.Info("Extract file failed");
                 ClearAllPackage();
                 //解压文件失败
                 BarControl.IsEndFail = true;
             }
         }
         else
         {
             BarControl.IsEndFail = true;
         }
         BarControl.SetAllARE();
         Thread.Sleep(timeSpan * 60 * 1000);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 处理上次可能失败的升级流程
        /// </summary>
        /// <returns>是否执行异常处理</returns>
        private static bool HandleProcException()
        {
            bool res = false;

            try
            {
                BarControl.InitAllParam();
                if (Utils.SetServerUrl())
                {
                    BarControl.IsHandleEx = true;
                    if (File.Exists(updateZipPath))
                    {
                        config = Utils.GetUpdateConfig();
                        Logger.Info("Has UpdatePackage.zip,continue operate");
                        string zipMD5 = Utils.GetMD5Value(updateZipPath);
                        if (zipMD5 == config.MD5)
                        {
                            res = true;
                            Task.Factory.StartNew(() =>
                            {
                                Application.Run(new Form1());
                            });
                            if (Utils.ExtractFile(updateZipPath, basePath))
                            {
                                Logger.Info("ExtractFile success");
                                RunUpateProc();
                            }
                            else
                            {
                                Logger.Info("Extract file failed");
                                ClearAllPackage();
                                //解压文件失败
                                BarControl.IsEndFail = true;
                            }
                        }
                        else
                        {
                            Logger.Warn("MD5 is defferent,delete zip file");
                            Utils.DeleteFile(updateZipPath);
                            ClearAllPackage();
                        }
                    }
                }
                else
                {
                    Logger.Info("UpdateUrl is null");
                }
            }
            catch (Exception ex)
            {
                Logger.Error("HandleProcException err:" + ex);
            }
            finally
            {
                BarControl.SetAllARE();
            }
            return(res);
        }