public void Update() { if (!config.Enabled) { return; } Dictionary <string, RemoteFile> listRemotFile = ParseRemoteXml(config.ServerUrl); 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 (config.Silence == true) { StartDownload(downloadList); } else if (DialogResult.OK == dc.ShowDialog()) { StartDownload(downloadList); } } }
public void Update() { if (!config.Enabled) { return; } Dictionary <string, RemoteFile> listRemotFile = ParseRemoteXml(config.ServerUrl); 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) string v1 = rf.Verison; string v2 = file.Version; if (v1 != v2) { downloadList.Add(new DownloadFileInfo(rf.Url, rf.Path, rf.LastVer, rf.Size, rf.Verison)); file.Path = rf.Path; file.LastVer = rf.LastVer; file.Size = rf.Size; file.Version = rf.Verison; 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, file.Verison)); bDownload = true; config.UpdateFileList.Add(new LocalFile(file.Path, file.LastVer, file.Size, file.Verison)); if (file.NeedRestart) { bNeedRestart = true; } } downloadFileListTemp = downloadList; if (bDownload) { OperProcess op = new OperProcess(); op.InitUpdateEnvironment(); DownloadConfirm dc = new DownloadConfirm(downloadList); if (this.OnShow != null) { this.OnShow(); } StartDownload(downloadList); } }