public UpdatingViewModel(UpdatingView updatingView) { _updatingView = updatingView; Message = "请勿关闭程序,正在升级中......\r\n升级完成后会自动启动新版本。"; UpdatingCommand = new DelegateCommand(UpdatingAsync); }
private async Task CheckUpdate() { bool hasUpdate = false; try { string updateUrl = GlobalData.Instance.AggregatedConfig.GetInterfaceItem().ServerUpdatePath; Log.Logger.Debug($"CheckUpdate => {updateUrl}"); using (var updateMgr = new UpdateManager(updateUrl)) { var updateInfo = await updateMgr.CheckForUpdate(); if (updateInfo != null && updateInfo.ReleasesToApply?.Any() == true) { // 包含更新 hasUpdate = true; } } if (hasUpdate) { string updateMsg = "检测到有新版本,是否升级?"; UpdateConfirmView updateConfirmView = new UpdateConfirmView(updateMsg); bool?update = updateConfirmView.ShowDialog(); if (update.HasValue && update.Value) { Log.Logger.Debug("【agree to update】"); UpdatingView updatingView = new UpdatingView(); updatingView.ShowDialog(); } else { Log.Logger.Debug("【refuse to update】"); } } } catch (Exception ex) { Log.Logger.Error($"CheckUpdate => {ex}"); } }