private void OnMainAppStarted(LocalRunInfo localRunInfo, string msg) { this.Invoke((Action)(() => { if (string.IsNullOrEmpty(localRunInfo.ClientId)) { localRunInfo.ClientId = InputClientId(); } UpdateHelper.SaveLocalRunInfo(localRunInfo); _mainAppPath = localRunInfo.AppRunCmd.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[0]; var urlInfo = UpdateUrlInfo.Parse(localRunInfo.UpdateUrl); this._config = UpdateHelper.GetSystemConfig(urlInfo.Host, urlInfo.SystemId); //var urlInfo = UpdateUrlInfo.Parse(localRunInfo.UpdateUrl); //this._config = UpdateHelper.GetSystemConfig(urlInfo.Host, urlInfo.SystemId); if (UpdateHelper.IsThisAppRunning() || !this._config.DetectEnabled) {// 保证更新程序只有一个在后台运行 Exit(localRunInfo); } else { StartUpdateDetect(localRunInfo, this._config); StartMainAppStateDetect(_mainAppPath, localRunInfo, this._config); } var appName = Path.GetFileName(_mainAppPath); notifyIcon.Text = this.Text = "更新检测-" + appName; LogHelper.LogInfoToServer($"程序启动成功({msg})", localRunInfo); })); }
private void InputUpdateUrl(LocalRunInfo localRunInfo) { FrmInput frm = new FrmInput("输入更新地址:", localRunInfo.UpdateUrl); if (frm.ShowDialog() == DialogResult.OK) { localRunInfo.UpdateUrl = frm.Value; UpdateHelper.SaveLocalRunInfo(localRunInfo); UpdateHelper.Update("正常启动"); } else { Exit(localRunInfo); } }
private void OnUpdateComplete( LocalRunInfo localRunInfo, IEnumerable <UpdateRunFile> fileDiff, List <string> failedUpdateFiles, List <string> failedDeleteFiles, bool initStart, bool runBat, string msg) { this.Invoke((Action)(() => { _frmProgress.Hide(); Show(); OnUpdateStatus("正在保存配置信息..."); UpdateHelper.SaveLocalRunInfo(localRunInfo); if (runBat) { OnUpdateStatus("正在做初始化工作..."); UpdateHelper.RunBat(); } if (!initStart && fileDiff.Count() > 0) { // 由于首次运行的时候更新的文件较多,不写更新日志 OnUpdateStatus("正在写更新日志..."); LogHelper.WriteUpdateLog(localRunInfo.Ver, fileDiff, failedUpdateFiles, failedDeleteFiles); } OnUpdateStatus("正在启动主程序..."); if (string.IsNullOrEmpty(localRunInfo.AppRunCmd)) { InputStartApp(localRunInfo); } else { UpdateHelper.RunMainApp(localRunInfo, msg); } })); }