Esempio n. 1
0
        private void ContentFilesDownloadFinished(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                var message = Localization.GetText("GameUpdater.Message.CannotReadContentFile");

#pragma warning disable CS0162
                if (LauncherSetup.IS_CHANGELOG_HTML)
                {
                    //only wrap in HTML if we already expect an HTML document
                    message = message.WrapAsHTML();
                }
#pragma warning restore CS0162

                ChangelogLoaded?.Invoke(message);
                UpdateFailed?.Invoke(this, EventArgs.Empty);
            }
            else
            {
                if (File.Exists("content.changes"))
                {
                    ChangelogLoaded?.Invoke(File.ReadAllText("content.changes"));
                }
                StatusUpdate?.Invoke(Localization.GetText("GameUpdater.Status.CheckingLocalFiles"));
                GameVersionDetected?.Invoke(contentFile.GameVersion);

                fileCheckWorker                     = new BackgroundWorker();
                fileCheckWorker.DoWork             += CheckFiles;
                fileCheckWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(this.CheckFilesFinished);
                fileCheckWorker.RunWorkerAsync();
            }
        }
Esempio n. 2
0
 private void FailThread()
 {
     lock (GUILocker)
     {
         Worker     = null;
         InProgress = false;
     }
     UpdateFailed?.Invoke(this, EventArgs.Empty);
 }
Esempio n. 3
0
        private void HandleUpdateFailed(string updateFailureErrorMessage)
        {
            if (IsTaskbarSupported())
            {
                tbp.SetState(WindowManager.GetWindowHandle(), TaskbarProgress.TaskbarStates.NoProgress);
            }

            UpdateFailed?.Invoke(this, new UpdateFailureEventArgs(updateFailureErrorMessage));
        }
Esempio n. 4
0
        private async void _webClient_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
        {
            if (!_updating)
            {
                return;
            }

            if (e.Error != null || e.Cancelled)
            {
                UpdateFailed?.Invoke();
                return;
            }

            await Task.Delay(1000);

            ProcessUpdate();
        }
Esempio n. 5
0
 public static void OnUpdateFailed(UpdateFailedEventArgs ufea)
 {
     UpdateFailed?.Invoke(null, ufea);
 }
        private void PerformUpdateInternal()
        {
            UpdaterLogger.Log("Performing update.");

            CreateTemporaryDirectory();

            UpdateMirror updateMirror = updateMirrors[lastUpdateMirrorId];

            char dsc = Path.DirectorySeparatorChar;

            string buildPath         = localBuildInfo.BuildPath;
            string downloadDirectory = buildPath + TEMPORARY_UPDATER_DIRECTORY + dsc;

            List <RemoteFileInfo> filesToDownload = GatherFilesToDownload(buildPath, downloadDirectory);

            CleanUpDownloadDirectory(filesToDownload, downloadDirectory);

            UpdaterLogger.Log("Creating downloader.");

            UpdateDownloader downloader = new UpdateDownloader();

            downloader.DownloadProgress += Downloader_DownloadProgress;
            UpdateDownloadResult result = downloader.DownloadUpdates(buildPath, downloadDirectory, filesToDownload, updateMirror);

            downloader.DownloadProgress -= Downloader_DownloadProgress;

            lock (locker)
            {
                updateInProgress = false;
            }

            switch (result.UpdateDownloadResultState)
            {
            case UpdateDownloadResultType.CANCELLED:
                UpdateCancelled?.Invoke(this, EventArgs.Empty);
                return;

            case UpdateDownloadResultType.COMPLETED:
                // If a new second-stage updater was downloaded, update it
                // first before launching it

                string originalSecondStageUpdaterPath = localBuildInfo.BuildPath + SecondStageUpdaterPath;

                string updatedSecondStageUpdaterPath = localBuildInfo.BuildPath +
                                                       TEMPORARY_UPDATER_DIRECTORY + dsc +
                                                       SecondStageUpdaterPath;

                if (File.Exists(updatedSecondStageUpdaterPath))
                {
                    File.Delete(originalSecondStageUpdaterPath);
                    File.Move(updatedSecondStageUpdaterPath, originalSecondStageUpdaterPath);
                }

                // Also update the second-stage updater's config file

                string originalSecondStageConfigPath = Path.GetDirectoryName(originalSecondStageUpdaterPath)
                                                       + dsc + SECOND_STAGE_UPDATER_CONFIGURATION_FILE;

                string updatedSecondStageConfigPath = Path.GetDirectoryName(updatedSecondStageUpdaterPath)
                                                      + dsc + SECOND_STAGE_UPDATER_CONFIGURATION_FILE;

                if (File.Exists(updatedSecondStageConfigPath))
                {
                    File.Delete(originalSecondStageConfigPath);
                    File.Move(updatedSecondStageConfigPath, originalSecondStageConfigPath);
                }

                // Generate local build information file
                LocalBuildInfo newBuildInfo = LocalBuildInfoFromRemoteBuildInfo();
                newBuildInfo.Write(localBuildInfo.BuildPath + TEMPORARY_UPDATER_DIRECTORY + dsc + LOCAL_BUILD_INFO_FILE);

                Process.Start(originalSecondStageUpdaterPath);

                // No null checking necessary here, it's actually better to
                // crash the application in case this is not subscribed to
                DownloadCompleted.Invoke(this, EventArgs.Empty);
                return;

            case UpdateDownloadResultType.FAILED:
                UpdateFailed?.Invoke(this, new UpdateFailureEventArgs(result.ErrorDescription));
                return;
            }
        }
Esempio n. 7
0
 private void OnUpdateFailed()
 {
     UpdateFailed?.Invoke(this, null);
 }
 protected virtual void OnUpdateFailed(UpdateFailedArgs e) => UpdateFailed?.Invoke(this, e);
 internal void OnUpdateFailed()
 {
     Log.Warning($"Server {this.ID:00} Updated Failed.");
     UpdateFailed.Invoke(this, null);
 }