From f3cc265135407973f216b51b8870edc9ff7d9be7 Mon Sep 17 00:00:00 2001 From: Noah Hilverling Date: Thu, 9 Nov 2017 09:27:15 +0100 Subject: [PATCH 1/2] SetupWizard: Remove Convert.ToString where useless refs #5705 --- agent/windows-setup-agent/SetupWizard.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/agent/windows-setup-agent/SetupWizard.cs b/agent/windows-setup-agent/SetupWizard.cs index 1b068fc3f..3b3b32b03 100644 --- a/agent/windows-setup-agent/SetupWizard.cs +++ b/agent/windows-setup-agent/SetupWizard.cs @@ -194,21 +194,21 @@ namespace Icinga string master_host, master_port; GetMasterHostPort(out master_host, out master_port); - args += " --master_host " + Convert.ToString(master_host).Trim() - + "," + Convert.ToString(master_port).Trim(); + args += " --master_host " + master_host.Trim() + + "," + master_port.Trim(); foreach (ListViewItem lvi in lvwEndpoints.Items) { - args += " --endpoint " + Convert.ToString(lvi.SubItems[0].Text).Trim(); + args += " --endpoint " + lvi.SubItems[0].Text.Trim(); if (lvi.SubItems.Count > 1) { - args += "," + Convert.ToString(lvi.SubItems[1].Text).Trim() - + "," + Convert.ToString(lvi.SubItems[2].Text).Trim(); + args += "," + lvi.SubItems[1].Text.Trim() + + "," + lvi.SubItems[2].Text.Trim(); } } }); if (rdoListener.Checked) - args += " --listen ::," + Convert.ToString(txtListenerPort.Text).Trim(); + args += " --listen ::," + txtListenerPort.Text.Trim(); if (chkAcceptConfig.Checked) args += " --accept-config"; @@ -216,14 +216,14 @@ namespace Icinga if (chkAcceptCommands.Checked) args += " --accept-commands"; - string ticket = Convert.ToString(txtTicket.Text).Trim(); + string ticket = txtTicket.Text.Trim(); if (ticket.Length > 0) args += " --ticket \"" + ticket + "\""; args += " --trustedcert \"" + _TrustedFile + "\""; - args += " --cn \"" + Convert.ToString(txtInstanceName.Text).Trim() + "\""; - args += " --zone \"" + Convert.ToString(txtInstanceName.Text) + "\""; + args += " --cn \"" + txtInstanceName.Text.Trim() + "\""; + args += " --zone \"" + txtInstanceName.Text.Trim() + "\""; if (!RunProcess(Program.Icinga2InstallDir + "\\sbin\\icinga2.exe", "node setup" + args, @@ -234,7 +234,7 @@ namespace Icinga SetConfigureStatus(50, "Setting ACLs for the Icinga 2 directory..."); - string serviceUser = Convert.ToString(txtUser.Text).Trim(); + string serviceUser = txtUser.Text.Trim(); DirectoryInfo di = new DirectoryInfo(Program.Icinga2InstallDir); DirectorySecurity ds = di.GetAccessControl(); From 4579e8f7f539c56524fbb9c8e7dc1a46889efbaa Mon Sep 17 00:00:00 2001 From: Noah Hilverling Date: Thu, 9 Nov 2017 09:28:05 +0100 Subject: [PATCH 2/2] SetupWizard: Move Trim to GetMasterHostPort() refs #5705 --- agent/windows-setup-agent/SetupWizard.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/agent/windows-setup-agent/SetupWizard.cs b/agent/windows-setup-agent/SetupWizard.cs index 3b3b32b03..0837195f2 100644 --- a/agent/windows-setup-agent/SetupWizard.cs +++ b/agent/windows-setup-agent/SetupWizard.cs @@ -54,8 +54,8 @@ namespace Icinga { foreach (ListViewItem lvi in lvwEndpoints.Items) { if (lvi.SubItems.Count > 1) { - host = lvi.SubItems[1].Text; - port = lvi.SubItems[2].Text; + host = lvi.SubItems[1].Text.Trim(); + port = lvi.SubItems[2].Text.Trim(); return true; } } @@ -194,8 +194,8 @@ namespace Icinga string master_host, master_port; GetMasterHostPort(out master_host, out master_port); - args += " --master_host " + master_host.Trim() - + "," + master_port.Trim(); + args += " --master_host " + master_host + + "," + master_port; foreach (ListViewItem lvi in lvwEndpoints.Items) { args += " --endpoint " + lvi.SubItems[0].Text.Trim();