예제 #1
0
 static Params()
 {
     Params.VersionStr              = ShareUtil.ConvertVersionToString(80000);
     Params.TestVersionDesc         = "";
     Params.TestParamDefault        = false;
     Params.AppSecret               = "asfda";
     Params.HelpRoot                = "https://github.com/renchengxiaofeixia";
     Params._isDevoloperClient      = null;
     Params.BottomPannelAnswerCount = 5;
     Params.RulePatternMatchStrict  = true;
     Params.AppStartTime            = DateTime.Now;
     Params.IsAppClosing            = false;
 }
예제 #2
0
 public static void UpdateForTip(UpdateDownloadEntity updtEt)
 {
     if (!updtEt.IsForceUpdate)
     {
         var ver     = ShareUtil.ConvertVersionToString(updtEt.PatchVersion);
         var msg     = string.Format("发现新版【{0}】,解决问题:\r\n\r\n{1}\r\n\r\n是否升级?", ver, updtEt.Tip);
         var showKey = "ClientUpdater";
         MsgBox.ShowNotTipAgain(msg, "升级提示", showKey, (b1, isOkClicked) => {
             if (isOkClicked)
             {
                 UpdateAsync(updtEt);
             }
         }, null, "升级");
     }
     else
     {
         UpdateAsync(updtEt);
     }
 }
예제 #3
0
 private static void Update(UpdateDownloadEntity updtEt)
 {
     if (!_isUpdating)
     {
         _isUpdating = true;
         try
         {
             Log.Info(string.Format("开始升级,补丁={0}", Util.SerializeWithTypeName(updtEt)));
             var newVerDir = PathEx.ParentOfExePath + ShareUtil.ConvertVersionToString(updtEt.PatchVersion);
             NetUtil.DownFile(updtEt.PatchUrl, _patchFn, updtEt.PatchSize);
             DirectoryEx.DeleteC(newVerDir, true);
             CopyBaseFile(newVerDir);
             Zip.UnZipFile(_patchFn, newVerDir, null);
             File.Delete(_patchFn);
             //DeleteOldVersion(ent.DeleteVersions, ent.DeleteVersionLessThan, ent.PatchVersion);
             InstalledVersionManager.SaveVersionToConfigFile(updtEt.PatchVersion);
             if (updtEt.IsForceUpdate)
             {
                 var msg = string.Format("{0}已升级到版本{1},{0}将自动重启。\r\n\r\n升级信息:{2}", "软件", ShareUtil.ConvertVersionToString(updtEt.PatchVersion), updtEt.Tip);
                 MsgBox.ShowTrayTip(msg, "软件升级", 30, null, () => Reboot());
             }
             else
             {
                 var msg = string.Format("{0}已升级到版本{1},是否立即重启软件,使用新版本?", "软件", ShareUtil.ConvertVersionToString(updtEt.PatchVersion));
                 if (MsgBox.ShowDialog(msg, "提示", null, null, null))
                 {
                     Reboot();
                 }
             }
         }
         catch (Exception ex)
         {
             Log.Exception(ex);
             DispatcherEx.xInvoke(() => MsgBox.ShowErrDialog(string.Format("升级失败,原因={0}", ex.Message)));
         }
         Log.Info("结束升级补丁");
         _isUpdating = false;
     }
 }
예제 #4
0
        private async static void ManualUpdate()
        {
            try
            {
                var updtEt = await BotApi.GetLatestVesion();

                if (updtEt == null)
                {
                    throw new Exception("无法从服务器获取新版信息");
                }
                else
                {
                    MsgBox.ShowDialog(string.Format("正在下载升级文件,版本=【{0}】,不要关闭软件,大概需要3分钟。", ShareUtil.ConvertVersionToString(updtEt.PatchVersion)), null, null, null);
                    Update(updtEt);
                }
            }
            catch (Exception ex)
            {
                Log.Exception(ex);
                MsgBox.ShowErrTip(ex.Message);
            }
        }
예제 #5
0
        public static void SaveVersionToConfigFile(int v)
        {
            string fn = PathEx.ParentOfExePath + "config.ini";

            FileEx.SaveToFile(fn, ShareUtil.ConvertVersionToString(v));
        }