public void StartUpdate()
        {
            if (bDownload)
            {
                OperProcess op = new OperProcess();
                op.InitUpdateEnvironment();
                DownloadConfirm dc = new DownloadConfirm(downloadList);

                if (this.OnShow != null)
                {
                    this.OnShow();
                }
                StartDownload(downloadList);
            }
        }
Example #2
0
        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 (DialogResult.OK == dc.ShowDialog())
                {
                    StartDownload(downloadList);
                }
            }
        }