コード例 #1
0
		public static PendingUpdates GetPendingUpdateQueues(ClientService.ClientService service)
		{
			PendingUpdates returnValue = new PendingUpdates();

			var lobbies = ServiceHandler.Service.CheckAvailableLobbies();
			foreach (LobbyResult lobby in lobbies)
			{
				//Get autoupdate files associated with lobby
				var results = service.CheckForUpdates(lobby.LobbyId, true);

				List<FindAutoUpdateFilesResult> updateQueue = ProcessPendingUpdates(lobby, results);

				returnValue.AutoUpdateBaseAddress.Add(lobby.LobbyId, results.AutoUpdateBaseAddress);
				returnValue.AllFilesInUpdatePackage.Add(lobby.LobbyId, results.Files);
				returnValue.PendingUpdateList.Add(lobby.LobbyId, updateQueue);
			}

			return returnValue;
		}
コード例 #2
0
        public static PendingUpdates GetPendingUpdateQueues(ClientService.ClientService service)
        {
            PendingUpdates returnValue = new PendingUpdates();

            var lobbies = ServiceHandler.Service.CheckAvailableLobbies();

            foreach (LobbyResult lobby in lobbies)
            {
                //Get autoupdate files associated with lobby
                var results = service.CheckForUpdates(lobby.LobbyId, true);

                List <FindAutoUpdateFilesResult> updateQueue = ProcessPendingUpdates(lobby, results);

                returnValue.AutoUpdateBaseAddress.Add(lobby.LobbyId, results.AutoUpdateBaseAddress);
                returnValue.AllFilesInUpdatePackage.Add(lobby.LobbyId, results.Files);
                returnValue.PendingUpdateList.Add(lobby.LobbyId, updateQueue);
            }

            return(returnValue);
        }
コード例 #3
0
        public static bool ProcessPendingUpdates(PendingUpdates pendingUpdates, LobbyResult lobby, AutoupdateProgressCallback progressCallback, Control parentControl)
        {
            string dataKey    = "Files_" + lobby.LobbyId;
            var    autoUpdate = DataStore.Open("autoupdate.ds", "Ga46^#a042");
            bool   updateExe  = false;
            int    received   = 0;
            bool   continueDownloadingFiles = true;

            //Get files from auto-update
            foreach (var file in pendingUpdates.PendingUpdateList[lobby.LobbyId])
            {
                if (continueDownloadingFiles == false)
                {
                    return(false);
                }

                var filename     = file.Filename;
                var downloadPath = String.Empty;

                //Check if filename matches the ClientExecutableName
                if (string.Equals(file.Filename, GlobalSettings.ClientExecutableName))
                {
                    filename     = GlobalSettings.TempExecutableName;
                    updateExe    = true;
                    downloadPath = Path.Combine(AllegianceRegistry.LobbyPath, filename);
                }
                // Launcher.PDB also goes into the lobby root.
                else if (string.Equals(file.Filename, GlobalSettings.ClientExecutablePDB))
                {
                    filename     = GlobalSettings.TempExecutablePDB;
                    downloadPath = Path.Combine(AllegianceRegistry.LobbyPath, filename);
                }
                else
                {
                    downloadPath = GetLobbyPath(lobby, filename);
                }

                if (!Directory.Exists(Path.GetDirectoryName(downloadPath)))
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(downloadPath));
                }

                var message = string.Format("Updating {0}...", file.Filename);

                try
                {
                    continueDownloadingFiles = DownloadFile(++received, pendingUpdates.PendingUpdateList[lobby.LobbyId].Count, pendingUpdates.AutoUpdateBaseAddress[lobby.LobbyId],
                                                            lobby.LobbyId, file.Filename, downloadPath, lobby.Name, progressCallback);

                    message += " Succeeded.";
                }
                catch (Exception error)
                {
                    message += string.Concat(" Failed: ", error.Message);
                    message += "\n autoUpdateURL: " + pendingUpdates.AutoUpdateBaseAddress[lobby.LobbyId];
                    message += "\n lobby.LobbyId: " + lobby.LobbyId;
                    message += "\n received: " + received;
                    message += "\n updateQueue.Count: " + pendingUpdates.PendingUpdateList[lobby.LobbyId].Count;
                    message += "\n file.Filename: " + file.Filename;
                    message += "\n downloadPath: " + downloadPath;
                    message += "\n exception details: " + error.ToString();
                    throw;
                }
                finally
                {
                    Log.Write(message);
                }
            }

            //Save updated AutoUpdateResults dictionary to datastore
            if (pendingUpdates.PendingUpdateList[lobby.LobbyId].Count != 0)
            {
                var dictionary = new Dictionary <string, FindAutoUpdateFilesResult>();
                foreach (var f in pendingUpdates.AllFilesInUpdatePackage[lobby.LobbyId])
                {
                    dictionary.Add(f.Filename, f);
                }

                autoUpdate[dataKey] = dictionary;
                autoUpdate.Save();
            }

            if (updateExe)             //Start the new executable, which will wait for this process to complete its autoupdate
            {
                var signal = new UiInteraction(delegate()
                {
                    MessageBox.Show("The Allegiance Security Client has an update and must restart.");
                    var tempLauncher = Path.Combine(AllegianceRegistry.LobbyPath, GlobalSettings.TempExecutableName);
                    Process.Start(tempLauncher);
                    Application.Exit();
                });

                if (parentControl.InvokeRequired == true)
                {
                    parentControl.Invoke(signal);
                }
                else
                {
                    signal();
                }
            }
            else
            {
                //Update the registry to assign the configuration url to the lobby's host value
                UpdateConfigurationUrlForSelectedLobby(lobby);
            }

            return(updateExe);
        }
コード例 #4
0
		public static bool ProcessPendingUpdates(PendingUpdates pendingUpdates, LobbyResult lobby, AutoupdateProgressCallback progressCallback, Control parentControl)
        {
			string dataKey = "Files_" + lobby.LobbyId; 
			var autoUpdate = DataStore.Open("autoupdate.ds", "Ga46^#a042");
			bool updateExe = false;
			int received = 0;
			bool continueDownloadingFiles = true;

            //Get files from auto-update
			foreach (var file in pendingUpdates.PendingUpdateList[lobby.LobbyId])
            {
				if (continueDownloadingFiles == false)
					return false;

                var filename    = file.Filename;
				var downloadPath = String.Empty;

                //Check if filename matches the ClientExecutableName
				if (string.Equals(file.Filename, GlobalSettings.ClientExecutableName))
				{
					filename = GlobalSettings.TempExecutableName;
					updateExe = true; 
					downloadPath = Path.Combine(AllegianceRegistry.LobbyPath, filename);
				}
				// Launcher.PDB also goes into the lobby root.
				else if (string.Equals(file.Filename, GlobalSettings.ClientExecutablePDB))
				{
					filename = GlobalSettings.TempExecutablePDB;
					downloadPath = Path.Combine(AllegianceRegistry.LobbyPath, filename);
				}
				else
				{
					downloadPath = GetLobbyPath(lobby, filename);
				}

                if (!Directory.Exists(Path.GetDirectoryName(downloadPath)))
                    Directory.CreateDirectory(Path.GetDirectoryName(downloadPath));

                var message = string.Format("Updating {0}...", file.Filename);

                try
                {
					continueDownloadingFiles = DownloadFile(++received, pendingUpdates.PendingUpdateList[lobby.LobbyId].Count, pendingUpdates.AutoUpdateBaseAddress[lobby.LobbyId], 
                        lobby.LobbyId, file.Filename, downloadPath, lobby.Name, progressCallback);

                    message += " Succeeded.";
                }
                catch (Exception error)
                {
                    message += string.Concat(" Failed: ", error.Message);
					message += "\n autoUpdateURL: " + pendingUpdates.AutoUpdateBaseAddress[lobby.LobbyId];
					message += "\n lobby.LobbyId: " + lobby.LobbyId;
					message += "\n received: " + received;
					message += "\n updateQueue.Count: " + pendingUpdates.PendingUpdateList[lobby.LobbyId].Count;
					message += "\n file.Filename: " + file.Filename;
					message += "\n downloadPath: " + downloadPath;
					message += "\n exception details: " + error.ToString();
                    throw;
                }
                finally
                {
                    Log.Write(message);
                }
            }

            //Save updated AutoUpdateResults dictionary to datastore
			if (pendingUpdates.PendingUpdateList[lobby.LobbyId].Count != 0)
            {
                var dictionary = new Dictionary<string, FindAutoUpdateFilesResult>();
				foreach (var f in pendingUpdates.AllFilesInUpdatePackage[lobby.LobbyId])
                    dictionary.Add(f.Filename, f);

				autoUpdate[dataKey] = dictionary;
                autoUpdate.Save();
            }

			if (updateExe) //Start the new executable, which will wait for this process to complete its autoupdate
			{
				var signal = new UiInteraction(delegate()
				{
					MessageBox.Show("The Allegiance Security Client has an update and must restart.");
					var tempLauncher = Path.Combine(AllegianceRegistry.LobbyPath, GlobalSettings.TempExecutableName);
					Process.Start(tempLauncher);
					Application.Exit();
				});

				if (parentControl.InvokeRequired == true)
					parentControl.Invoke(signal);
				else
					signal();
			}
            else
            {
                //Update the registry to assign the configuration url to the lobby's host value
				UpdateConfigurationUrlForSelectedLobby(lobby);
            }

            return updateExe;
        }