private MonitorState RunPingTest() { MonitorState result; PingCollectorHostEntry tmpPingCollectorHostEntry = new PingCollectorHostEntry(); if (cboPingType.SelectedIndex == 1) { tmpPingCollectorHostEntry.PingType = PingCollectorType.HTTP; if (!txtAddress.Text.ToUpper().StartsWith("HTTP")) { txtAddress.Text = "http://" + txtAddress.Text; } } else if (cboPingType.SelectedIndex == 2) { tmpPingCollectorHostEntry.PingType = PingCollectorType.Socket; } else { tmpPingCollectorHostEntry.PingType = PingCollectorType.Ping; } string address = ApplyConfigVarsOnField(txtAddress.Text); string description = ApplyConfigVarsOnField(txtDescription.Text); string httpHeaderUserName = ApplyConfigVarsOnField(txtHTTPHeaderUsername.Text); string httpHeaderPassword = ApplyConfigVarsOnField(txtHTTPHeaderPassword.Text); string httpProxyServer = ApplyConfigVarsOnField(txtHttpProxy.Text); string httpProxyUserName = ApplyConfigVarsOnField(txtProxyUsername.Text); string httpProxyPassword = ApplyConfigVarsOnField(txtProxyPassword.Text); string htmlContentContain = ApplyConfigVarsOnField(txtHTMLContent.Text); string telnetUserName = ApplyConfigVarsOnField(txtUserName.Text); string telnetPassword = ApplyConfigVarsOnField(txtPassword.Text); string socketPingMsgBody = ApplyConfigVarsOnField(txtSocketPingMsgBody.Text); tmpPingCollectorHostEntry.Address = address; tmpPingCollectorHostEntry.DescriptionLocal = description; tmpPingCollectorHostEntry.MaxTimeMS = Convert.ToInt32(nudExpextedTime.Value); tmpPingCollectorHostEntry.TimeOutMS = Convert.ToInt32(nudTimeOut.Value); tmpPingCollectorHostEntry.HttpHeaderUserName = httpHeaderUserName; tmpPingCollectorHostEntry.HttpHeaderPassword = httpHeaderPassword; tmpPingCollectorHostEntry.HttpProxyServer = httpProxyServer; tmpPingCollectorHostEntry.HttpProxyUserName = httpProxyUserName; tmpPingCollectorHostEntry.HttpProxyPassword = httpProxyPassword; tmpPingCollectorHostEntry.HTMLContentContain = htmlContentContain; tmpPingCollectorHostEntry.IgnoreInvalidHTTPSCerts = chkIgnoreInvalidHTTPSCerts.Checked; tmpPingCollectorHostEntry.SocketPort = (int)nudPortNumber.Value; tmpPingCollectorHostEntry.ReceiveTimeOutMS = (int)nudReceiveTimeout.Value; tmpPingCollectorHostEntry.SendTimeOutMS = (int)nudSendTimeout.Value; tmpPingCollectorHostEntry.UseTelnetLogin = chkUseTelNetLogin.Checked; tmpPingCollectorHostEntry.TelnetUserName = telnetUserName; tmpPingCollectorHostEntry.TelnetPassword = telnetPassword; tmpPingCollectorHostEntry.SocketPingMsgBody = socketPingMsgBody; tmpPingCollectorHostEntry.HttpsSecurityProtocol = cboHttpsProtocol.Text; result = tmpPingCollectorHostEntry.GetCurrentState(); return(result); }
//public DialogResult ShowHostAddress() //{ // switch (HostEntry.PingType) // { // case PingCollectorType.HTTP: // cboPingType.SelectedIndex = 1; // break; // case PingCollectorType.Socket: // cboPingType.SelectedIndex = 2; // break; // default: // cboPingType.SelectedIndex = 0; // break; // } // txtAddress.Text = HostEntry.Address; // txtDescription.Text = HostEntry.DescriptionLocal; // nudExpextedTime.Value = HostEntry.MaxTimeMS; // nudTimeOut.Value = HostEntry.TimeOutMS; // txtHTTPHeaderUsername.Text = HostEntry.HttpHeaderUserName; // txtHTTPHeaderPassword.Text = HostEntry.HttpHeaderPassword; // txtHttpProxy.Text = HostEntry.HttpProxyServer; // txtProxyUsername.Text = HostEntry.HttpProxyUserName; // txtProxyPassword.Text = HostEntry.HttpProxyPassword; // txtHTMLContent.Text = HostEntry.HTMLContentContain; // chkIgnoreInvalidHTTPSCerts.Checked = HostEntry.IgnoreInvalidHTTPSCerts; // nudPortNumber.Value = HostEntry.SocketPort; // nudReceiveTimeout.Value = HostEntry.ReceiveTimeOutMS; // nudSendTimeout.Value = HostEntry.SendTimeOutMS; // chkUseTelNetLogin.Checked = HostEntry.UseTelnetLogin; // txtUserName.Text = HostEntry.TelnetUserName; // txtPassword.Text = HostEntry.TelnetPassword; // txtSocketPingMsgBody.Text = HostEntry.SocketPingMsgBody; // CheckOkEnabled(); // return ShowDialog(); //} private void PingCollectorEditHostAddress_Load(object sender, EventArgs e) { if (SelectedEntry == null) { SelectedEntry = new PingCollectorHostEntry(); } HostEntry = (PingCollectorHostEntry)SelectedEntry; switch (HostEntry.PingType) { case PingCollectorType.HTTP: cboPingType.SelectedIndex = 1; break; case PingCollectorType.Socket: cboPingType.SelectedIndex = 2; break; default: cboPingType.SelectedIndex = 0; break; } txtAddress.Text = HostEntry.Address; txtDescription.Text = HostEntry.DescriptionLocal; nudExpextedTime.Value = HostEntry.MaxTimeMS; nudTimeOut.Value = HostEntry.TimeOutMS; txtHTTPHeaderUsername.Text = HostEntry.HttpHeaderUserName; txtHTTPHeaderPassword.Text = HostEntry.HttpHeaderPassword; txtHttpProxy.Text = HostEntry.HttpProxyServer; txtProxyUsername.Text = HostEntry.HttpProxyUserName; txtProxyPassword.Text = HostEntry.HttpProxyPassword; txtHTMLContent.Text = HostEntry.HTMLContentContain; nudPortNumber.Value = HostEntry.SocketPort; nudReceiveTimeout.Value = HostEntry.ReceiveTimeOutMS; nudSendTimeout.Value = HostEntry.SendTimeOutMS; chkUseTelNetLogin.Checked = HostEntry.UseTelnetLogin; txtUserName.Text = HostEntry.TelnetUserName; txtPassword.Text = HostEntry.TelnetPassword; cboHttpsProtocol.SelectedIndex = 0; chkIgnoreInvalidHTTPSCerts.Checked = HostEntry.IgnoreInvalidHTTPSCerts; if (HostEntry.HttpsSecurityProtocol != null) { if (HostEntry.HttpsSecurityProtocol == "Tls") { cboHttpsProtocol.SelectedIndex = 1; } else if (HostEntry.HttpsSecurityProtocol == "Tls11") { cboHttpsProtocol.SelectedIndex = 2; } else if (HostEntry.HttpsSecurityProtocol == "Tls12") { cboHttpsProtocol.SelectedIndex = 3; } } }