private void cmdTestAddress_Click(object sender, EventArgs e) { SoapWebServicePingConfigEntry tmpSoapWebServicePingConfigEntry = new SoapWebServicePingConfigEntry(); if (!(txtServiceURL.Text.StartsWith("http://", StringComparison.CurrentCultureIgnoreCase) || txtServiceURL.Text.StartsWith("https://", StringComparison.CurrentCultureIgnoreCase))) { txtServiceURL.Text = "http://" + txtServiceURL.Text; } tmpSoapWebServicePingConfigEntry.ServiceBaseURL = txtServiceURL.Text; tmpSoapWebServicePingConfigEntry.ServiceName = txtServiceName.Text; tmpSoapWebServicePingConfigEntry.MethodName = txtMethodName.Text; tmpSoapWebServicePingConfigEntry.Parameters = new List <string>(); foreach (string par in txtParameters.Text.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries)) { if (par.Trim().Length > 0) { tmpSoapWebServicePingConfigEntry.Parameters.Add(par); } } tmpSoapWebServicePingConfigEntry.CheckType = (SoapWebServicePingCheckType)cboCheckType.SelectedIndex; tmpSoapWebServicePingConfigEntry.ResultType = (SoapWebServicePingResult)cboResultType.SelectedIndex; tmpSoapWebServicePingConfigEntry.CustomValue1 = cboErrorCustomValue1.Text; tmpSoapWebServicePingConfigEntry.CustomValue2 = cboErrorCustomValue2.Text; try { object pingResult = tmpSoapWebServicePingConfigEntry.ExecuteMethod(); if (tmpSoapWebServicePingConfigEntry.ResultType == SoapWebServicePingResult.CheckAvailabilityOnly) { MessageBox.Show("Web service is available!", "Test", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (pingResult != null && pingResult.ToString() != "") { string formattedVal = ""; bool result = tmpSoapWebServicePingConfigEntry.CheckResultMatch(pingResult, tmpSoapWebServicePingConfigEntry.ResultType, tmpSoapWebServicePingConfigEntry.CustomValue1, tmpSoapWebServicePingConfigEntry.CustomValue2, out formattedVal); MessageBox.Show(string.Format("Method was executed successfully\r\nResult: {0}\r\nValue: {1}", result ? "Success" : "Fail", formattedVal), "Test", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Method was executed successfully but return nothing!", "Test", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//public List<SoapWebServicePingConfigEntry> Entries = new List<SoapWebServicePingConfigEntry>(); #region IAgentConfig Members public void ReadConfiguration(string configurationString) { XmlDocument config = new XmlDocument(); config.LoadXml(configurationString); XmlElement root = config.DocumentElement; Entries.Clear(); foreach (XmlElement addressNode in root.SelectNodes("webServices/webService")) { SoapWebServicePingConfigEntry webServicePingEntry = new SoapWebServicePingConfigEntry(); webServicePingEntry.ServiceBaseURL = addressNode.ReadXmlElementAttr("url", ""); webServicePingEntry.ServiceName = addressNode.ReadXmlElementAttr("name", ""); webServicePingEntry.MethodName = addressNode.ReadXmlElementAttr("method"); string parameterStr = addressNode.ReadXmlElementAttr("paramatersCSV"); webServicePingEntry.Parameters = new List <string>(); if (parameterStr.Trim().Length > 0) { webServicePingEntry.Parameters.AddRange(parameterStr.Split(',')); } if (addressNode.ReadXmlElementAttr("checkType") == "0") { webServicePingEntry.CheckType = SoapWebServicePingCheckType.Success; } else { webServicePingEntry.CheckType = SoapWebServicePingCheckType.Failure; } int tmpResultType = 0; if (int.TryParse(addressNode.ReadXmlElementAttr("resultType"), out tmpResultType)) { webServicePingEntry.ResultType = (SoapWebServicePingResult)tmpResultType; } else { webServicePingEntry.ResultType = SoapWebServicePingResult.CheckAvailabilityOnly; } webServicePingEntry.CustomValue1 = addressNode.ReadXmlElementAttr("checkValue1"); webServicePingEntry.CustomValue2 = addressNode.ReadXmlElementAttr("checkValue2"); Entries.Add(webServicePingEntry); } }
public override void OKClicked() { if (CheckOKEnabled()) { if (SelectedConfig == null) { SelectedConfig = new SoapWebServicePingCollectorConfig(); } ((SoapWebServicePingCollectorConfig)SelectedConfig).Entries.Clear(); foreach (ListViewItem lvi in lvwEntries.Items) { SoapWebServicePingConfigEntry soapWebServicePingConfigEntry = (SoapWebServicePingConfigEntry)lvi.Tag; ((SoapWebServicePingCollectorConfig)SelectedConfig).Entries.Add(soapWebServicePingConfigEntry); } DialogResult = System.Windows.Forms.DialogResult.OK; Close(); } }
private void cmdOK_Click(object sender, EventArgs e) { if (CheckOKButtonEnable()) { SoapWebServicePingConfigEntry selectedEntry; if (SelectedEntry != null) { selectedEntry = (SoapWebServicePingConfigEntry)SelectedEntry; } else if (SelectedConfig != null) { selectedEntry = (SoapWebServicePingConfigEntry)SelectedConfig; } else { selectedEntry = new SoapWebServicePingConfigEntry(); SelectedEntry = selectedEntry; } selectedEntry.ServiceBaseURL = txtServiceURL.Text; selectedEntry.ServiceName = txtServiceName.Text; selectedEntry.MethodName = txtMethodName.Text; selectedEntry.Parameters = new List <string>(); foreach (string par in txtParameters.Text.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries)) { if (par.Trim().Length > 0) { selectedEntry.Parameters.Add(par); } } selectedEntry.CheckType = (SoapWebServicePingCheckType)cboCheckType.SelectedIndex; selectedEntry.ResultType = (SoapWebServicePingResult)cboResultType.SelectedIndex; selectedEntry.CustomValue1 = cboErrorCustomValue1.Text; selectedEntry.CustomValue2 = cboErrorCustomValue2.Text; DialogResult = System.Windows.Forms.DialogResult.OK; Close(); } }
public override void RefreshDisplayData() { System.Windows.Forms.Cursor.Current = Cursors.WaitCursor; lvwEntries.BeginUpdate(); foreach (ListViewItem itmX in lvwEntries.Items) { SoapWebServicePingConfigEntry soapWebServicePingConfigEntry = (SoapWebServicePingConfigEntry)itmX.Tag; try { object obj = soapWebServicePingConfigEntry.ExecuteMethod(); string formattedVal = ""; bool success = soapWebServicePingConfigEntry.CheckResultMatch(obj, soapWebServicePingConfigEntry.ResultType, soapWebServicePingConfigEntry.CustomValue1, soapWebServicePingConfigEntry.CustomValue2, out formattedVal); itmX.SubItems[1].Text = formattedVal; if (success) { itmX.ImageIndex = 0; itmX.BackColor = SystemColors.Window; } else { itmX.ImageIndex = 2; itmX.BackColor = Color.Salmon; } } catch (Exception ex) { itmX.SubItems[1].Text = ex.Message; itmX.ImageIndex = 2; itmX.BackColor = Color.Salmon; } } lvwEntries.EndUpdate(); System.Windows.Forms.Cursor.Current = Cursors.Default; toolStripStatusLabelDetails.Text = "Last updated " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); }