예제 #1
0
 public AsyncUpdateController(params IUpdater[] updateQueue)
 {
     DownloadType     = UpdateDownloadType.ToFile;
     updatesToInstall = new ConcurrentBag <IUpdater>();
     updatesToPerform = updateQueue;
 }
예제 #2
0
        public void PrepareToDownload(UpdateDownloadType type, List <string> strs, PatchServer server)
        {
            HideDownloadBar();
            if (strs.Count < 2)
            {
                if (type == UpdateDownloadType.UpdaterPatch)
                {
                    MsgRequestInfo mri = new MsgRequestInfo();
                    mri.CurrentVersion = m_usCurrentVersion;
                    server.Send(mri);

                    Kernel.Stage = AutoPatchStage.WaitingForGamePatchs;
                    Edit(lblCenterStatus, LabelAsyncOperation.Text,
                         LanguageManager.GetString("StrLookingForGameUpdates"));
                }
                else
                {
                    NoDownload(UpdateReturnMessage.Success);
                }

                return;
            }

            m_actuallyDownloading = type;
            Edit(lblCenterStatus, LabelAsyncOperation.Text, LanguageManager.GetString("StrCalculatingDownloadSize"));

            string domain = strs[0];

            if (!domain.EndsWith("/"))
            {
                domain += "/";
            }

            m_nTotalDownloadSize  = 0;
            m_nCurrentDownloading = 0;
            m_nTotalDownloads     = 0;

            Edit(lblDownloadStatus, LabelAsyncOperation.Text,
                 LanguageManager.GetString("StrLabelCalculatingDownloadAmount", m_nTotalDownloads,
                                           ParseFileSize(m_nTotalDownloadSize)));
            Edit(lblDownloadStatus, LabelAsyncOperation.Visible, true);

            for (int i = 1; i < strs.Count; i++)
            {
                if (!strs[i].EndsWith(".exe"))
                {
                    strs[i] += ".exe";
                }

                if (!RemoteFileExists($"{domain}{strs[i]}"))
                {
                    continue;
                }

                m_nTotalDownloadSize += FetchFileSize($"{domain}{strs[i]}");
                m_nTotalDownloads++;
                m_queueNextDownloads.Enqueue($"{domain}{strs[i]}");
                Edit(lblDownloadStatus, LabelAsyncOperation.Text,
                     LanguageManager.GetString("StrLabelCalculatingDownloadAmount", m_nTotalDownloads,
                                               ParseFileSize(m_nTotalDownloadSize)));
            }

            Edit(lblDownloadStatus, LabelAsyncOperation.Text,
                 LanguageManager.GetString("StrLabelCalculatingDownloadAmount", m_nTotalDownloads,
                                           ParseFileSize(m_nTotalDownloadSize)));
            Edit(pbDownload, ProgressBarAsyncOperation.Value, 0);
            Edit(pbDownload, ProgressBarAsyncOperation.Max, m_nTotalDownloadSize);
            ShowDownloadBar();
            StartDownloading();
        }