private void DeployGameServer() { //Enable cancel button to terminate deployment process if needed. lblDownloadProgressDetails.Text = "Status: Downloading " + dropdownServerSelection.Text + "..."; switch (DeploymentValues.STEAM_steamcmd_required == true) { case true: { lblDownloadProgressDetails.Text = "Status: Downloading / Initializing SteamCMD..."; SteamCMD.DownloadSteamCMD(); switch (DeploymentValues.STEAM_authrequired == true) { case true: MetroMessageBox.Show(BorealisServerManager.ActiveForm, "Due to the fact that we do not have an authentication system in place for Steam, you cannot download non-anonymous SteamCMD dedicated servers at this time. We apologize, and hope to get this incorporated soon!", "Steam Authentication Required", MessageBoxButtons.OK, MessageBoxIcon.Error); btnDeployGameserver.Enabled = true; btnCancelDeployGameserver.Visible = false; break; case false: try { ExecuteWithRedirect(Environment.CurrentDirectory + @"\steamcmd.exe", string.Concat("+login anonymous +force_install_dir ", "\"", DeploymentValues.DIR_install_location, "\"", " +app_update ", ServerAPI.QUERY_STEAM_APPID(dropdownServerSelection.Text), DeploymentValues.verify_integrity, " +quit")); } catch (Exception) { MetroMessageBox.Show(BorealisServerManager.ActiveForm, "We cannot find the required executable to deploy the server! Either it is missing, or the server configuration for this gameserver is corrupted.", "Error Deploying GameServer", MessageBoxButtons.OK, MessageBoxIcon.Error); } break; } } break; case false: { //RUN OTHER CODE TO DEPLOY THE NON-STEAMCMD GAMESERVER } break; } }
//Method to deploy gameservers given values from the DeploymentValues class private void serverDeploy(DeploymentValues deploymentValues) { _currentDeploymentValues = deploymentValues; //Enable cancel button to terminate deployment process if needed. lblDownloadProgressDetails.Text = "Status: Downloading " + dropdownServerSelection.Text + "..."; switch (deploymentValues.STEAM_steamcmd_required) { case true: { lblDownloadProgressDetails.Text = "Status: Downloading / Initializing SteamCMD..."; SteamCMD.DownloadSteamCMD(); switch (deploymentValues.STEAM_authrequired) { case true: if (txtSteamUsername.Text == "" || txtSteamPassword.Text == "") { MetroMessageBox.Show(ActiveForm, "Please fill out your Steam username and password.", "Steam Credentials Missing", MessageBoxButtons.OK, MessageBoxIcon.Error); } SteamGuardProcess.StartInfo.Arguments = string.Format(@"+login {0} {1} +force_install_dir {2} +app_update {3} {4} +quit", txtSteamUsername.Text, txtSteamPassword.Text, deploymentValues.DIR_install_location, ServerAPI.QUERY_STEAM_APPID(dropdownServerSelection.Text), deploymentValues.verify_integrity); SteamGuardProcess.StartInfo.FileName = Environment.CurrentDirectory + @"\steamcmd.exe"; SteamGuardProcess.StartInfo.UseShellExecute = false; SteamGuardProcess.StartInfo.RedirectStandardOutput = true; SteamGuardProcess.StartInfo.RedirectStandardInput = true; SteamGuardProcess.StartInfo.RedirectStandardError = true; SteamGuardProcess.EnableRaisingEvents = true; SteamGuardProcess.StartInfo.CreateNoWindow = true; SteamGuardProcess.ErrorDataReceived += proc_DataReceived; SteamGuardProcess.OutputDataReceived += proc_DataReceived; SteamGuardProcess.Start(); SteamGuardProcess.BeginErrorReadLine(); SteamGuardProcess.BeginOutputReadLine(); break; case false: try { Execute(Environment.CurrentDirectory + @"\steamcmd.exe", string.Format(@"+login anonymous +force_install_dir {0} +app_update {1} {2} +quit", deploymentValues.DIR_install_location, ServerAPI.QUERY_STEAM_APPID(dropdownServerSelection.Text), deploymentValues.verify_integrity), true); } catch (Exception) { MetroMessageBox.Show(ActiveForm, "We cannot find the required executable to deploy the server! Either it is missing, or the server configuration for this gameserver is corrupted.", "Error Deploying GameServer", MessageBoxButtons.OK, MessageBoxIcon.Error); } break; } } break; case false: { //RUN OTHER CODE TO DEPLOY THE NON-STEAMCMD GAMESERVER } break; } }