internal void ShowUpdateDialog() { var downloadList = this._versionUpdates[0].FilesToDownload; downloadList[0].Version = this._versionUpdates[0].Version; DownloadConfirm dc = new DownloadConfirm(downloadList); this.OnShow?.Invoke(); if (DialogResult.OK == dc.ShowDialog()) { var updatePath = DAL.ApplicationSettings.Settings.UpdatePath; if (!DAL.Managers.FileSystemManager.HasWriteAccess(updatePath)) { updatePath = DAL.ApplicationSettings.Settings.RoamingUpdatePath; } if (!Directory.Exists(updatePath)) { Directory.CreateDirectory(updatePath); } StartDownload(downloadList); } }
public void Update() { LogHelper.WriteInfo(typeof(AutoUpdater), "开始升级"); if (!config.Enabled) { return; } Dictionary <string, RemoteFile> listRemotFile = ParseRemoteXml(config.ServerUrl); LogHelper.WriteInfo(typeof(AutoUpdater), "检测到升级文件" + listRemotFile.Count + "个"); List <DownloadFileInfo> downloadList = new List <DownloadFileInfo>(); foreach (LocalFile file in config.UpdateFileList) { if (listRemotFile.ContainsKey(file.Path)) { RemoteFile rf = listRemotFile[file.Path]; Version v1 = new Version(rf.LastVer); Version v2 = new Version(file.LastVer); if (v1 > v2) { downloadList.Add(new DownloadFileInfo(rf.Url, file.Path, rf.LastVer, rf.Size)); file.LastVer = rf.LastVer; file.Size = rf.Size; if (rf.NeedRestart) { bNeedRestart = true; } bDownload = true; } listRemotFile.Remove(file.Path); } } foreach (RemoteFile file in listRemotFile.Values) { downloadList.Add(new DownloadFileInfo(file.Url, file.Path, file.LastVer, file.Size)); if (file.NeedRestart) { bNeedRestart = true; } } downloadFileListTemp = downloadList; if (bDownload) { DownloadConfirm dc = new DownloadConfirm(downloadList); if (this.OnShow != null) { this.OnShow(); } if (DialogResult.OK == dc.ShowDialog()) { StartDownload(downloadList); } } }
public int Update() { if (!CommonUnitity.GlobalConfig.Enabled) { return(0); } List <DownloadFileInfo> downloadList = new List <DownloadFileInfo>(); Dictionary <string, RemoteFile> RemotFileList = ParseRemoteXml(CommonUnitity.GlobalConfig.ServerUrl); foreach (LocalFile file in CommonUnitity.GlobalConfig.UpdateFileList)//本地与服务器文件比较 { if (RemotFileList.ContainsKey(file.Path)) { RemoteFile rf = RemotFileList[file.Path]; string v1 = rf.Version; string v2 = file.Version; if (v1 != v2) { downloadList.Add(new DownloadFileInfo(rf.Url, rf.Path, rf.LastVer, rf.Size, rf.Version)); file.Path = rf.Path; file.LastVer = rf.LastVer; file.Size = rf.Size; file.Version = rf.Version; if (rf.NeedRestart) { bNeedRestart = true; } bDownload = true; } RemotFileList.Remove(file.Path); } } //服务器多余的文件 foreach (RemoteFile file in RemotFileList.Values) { downloadList.Add(new DownloadFileInfo(file.Url, file.Path, file.LastVer, file.Size, file.Version)); bDownload = true; CommonUnitity.GlobalConfig.UpdateFileList.Add(new LocalFile(file.Path, file.LastVer, file.Size, file.Version)); if (file.NeedRestart) { bNeedRestart = true; } } downloadFileListTemp = downloadList; if (bDownload) { //OperProcess op = new OperProcess(); //op.InitUpdateEnvironment(); DownloadConfirm dc = new DownloadConfirm(downloadList); if (dc.ShowDialog() == DialogResult.OK) { if (this.OnShow != null) { this.OnShow(); } StartDownload(downloadList); } return(1); } return(-1); }