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")) { DynamicWSCollectorConfigEntry webServicePingEntry = new DynamicWSCollectorConfigEntry(); webServicePingEntry.ServiceBaseURL = addressNode.ReadXmlElementAttr("url", ""); webServicePingEntry.ServiceBindingName = addressNode.ReadXmlElementAttr("serviceBindingName", ""); 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(',')); } webServicePingEntry.ResultIsSuccess = addressNode.ReadXmlElementAttr("resultIsSuccess", true); webServicePingEntry.ValueExpectedReturnType = WebServiceValueExpectedReturnTypeConverter.FromString(addressNode.ReadXmlElementAttr("valueExpectedReturnType", "")); webServicePingEntry.MacroFormatType = WebServiceMacroFormatTypeConverter.FromString(addressNode.ReadXmlElementAttr("macroFormatType", "")); webServicePingEntry.CheckValueArrayIndex = addressNode.ReadXmlElementAttr("arrayIndex", 0); webServicePingEntry.CheckValueColumnIndex = addressNode.ReadXmlElementAttr("columnIndex", 0); webServicePingEntry.CheckValueOrMacro = addressNode.ReadXmlElementAttr("valueOrMacro", ""); webServicePingEntry.UseRegEx = addressNode.ReadXmlElementAttr("useRegEx", false); Entries.Add(webServicePingEntry); } }
public override void RefreshDisplayData() { System.Windows.Forms.Cursor.Current = Cursors.WaitCursor; lvwEntries.BeginUpdate(); foreach (ListViewItem itmX in lvwEntries.Items) { DynamicWSCollectorConfigEntry entry = (DynamicWSCollectorConfigEntry)itmX.Tag; try { object obj = entry.RunMethod(); CollectorState state = entry.GetState(obj); itmX.SubItems[1].Text = entry.LastFormattedValue; if (state == CollectorState.Good) { 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"); }
private void DynamicWSCollectorEditEntry_Load(object sender, EventArgs e) { if (SelectedEntry != null) { editingEntry = (DynamicWSCollectorConfigEntry)SelectedEntry; } else { editingEntry = new DynamicWSCollectorConfigEntry(); } }
private void cmdTestService_Click(object sender, EventArgs e) { if (txtServiceURL.Text.Trim().Length > 0) { string lastStep = "Creating entry"; try { DynamicWSCollectorConfigEntry textEntry = new DynamicWSCollectorConfigEntry(); textEntry.ServiceBaseURL = txtServiceURL.Text; textEntry.ServiceBindingName = cboEndPoint.Text; textEntry.MethodName = cboMethodName.Text; textEntry.ParametersFromString(txtParameters.Text); textEntry.ResultIsSuccess = !chkResultXOr.Checked; textEntry.ValueExpectedReturnType = (WebServiceValueExpectedReturnTypeEnum)cboExpectedValueType.SelectedIndex; if (cboValueFormatMacro.SelectedIndex == -1 || !(cboValueFormatMacro.SelectedItem is ValueFormatMacroDisplay)) { textEntry.MacroFormatType = WebServiceMacroFormatTypeEnum.None; } else { textEntry.MacroFormatType = ((ValueFormatMacroDisplay)cboValueFormatMacro.SelectedItem).MacroFormatType; } textEntry.CheckValueArrayIndex = (int)indexOrRowNumericUpDown.Value; textEntry.CheckValueColumnIndex = (int)dataSetColumnNumericUpDown.Value; textEntry.CheckValueOrMacro = cboValueOrMacro.Text; textEntry.UseRegEx = chkUseRegEx.Checked; lastStep = "Running method"; object returnValue = textEntry.RunMethod(); lastStep = "Evaluating return value"; CollectorState state = textEntry.GetState(returnValue); MessageBox.Show("Returned state: " + state.ToString() + "\r\nValue: " + textEntry.LastFormattedValue, "Test", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { if (ex.Message.Contains("Specified web service invalid or not available")) { MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Last step: " + lastStep + "\r\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void cmdOK_Click(object sender, EventArgs e) { if (txtServiceURL.Text.Trim().Length > 0 && cboEndPoint.Text.Trim().Length > 0 && cboMethodName.Text.Trim().Length > 0) { if (editingEntry == null) { editingEntry = new DynamicWSCollectorConfigEntry(); } try { editingEntry.ServiceBaseURL = txtServiceURL.Text; editingEntry.ServiceBindingName = cboEndPoint.Text; editingEntry.MethodName = cboMethodName.Text; editingEntry.ParametersFromString(txtParameters.Text); editingEntry.ResultIsSuccess = !chkResultXOr.Checked; editingEntry.ValueExpectedReturnType = (WebServiceValueExpectedReturnTypeEnum)cboExpectedValueType.SelectedIndex; if (cboValueFormatMacro.SelectedIndex == -1 || !(cboValueFormatMacro.SelectedItem is ValueFormatMacroDisplay)) { editingEntry.MacroFormatType = WebServiceMacroFormatTypeEnum.None; } else { editingEntry.MacroFormatType = ((ValueFormatMacroDisplay)cboValueFormatMacro.SelectedItem).MacroFormatType; } editingEntry.CheckValueArrayIndex = (int)indexOrRowNumericUpDown.Value; editingEntry.CheckValueColumnIndex = (int)dataSetColumnNumericUpDown.Value; editingEntry.CheckValueOrMacro = cboValueOrMacro.Text; editingEntry.UseRegEx = chkUseRegEx.Checked; SelectedEntry = editingEntry; DialogResult = System.Windows.Forms.DialogResult.OK; Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }