private void DynamicWSCollectorEditEntry_Shown(object sender, EventArgs e) { WSCollectorConfigEntry editingEntry; if (SelectedEntry == null) { SelectedEntry = new WSCollectorConfigEntry(); } editingEntry = (WSCollectorConfigEntry)SelectedEntry; txtServiceURL.Text = editingEntry.ServiceBaseURL; cboEndPoint.Text = editingEntry.ServiceBindingName; cboMethodName.Text = editingEntry.MethodName; txtParameters.Text = editingEntry.ToStringFromParameters(); cboExpectedValueType.SelectedIndex = (int)editingEntry.ValueExpectedReturnType; cboValueFormatMacro.SelectedItem = (from ValueFormatMacroDisplay v in cboValueFormatMacro.Items where v.MacroFormatType == editingEntry.MacroFormatType select v).FirstOrDefault(); indexOrRowNumericUpDown.Value = editingEntry.CheckValueArrayIndex; dataSetColumnNumericUpDown.Value = editingEntry.CheckValueColumnIndex; cboReturnCheckSequence.SelectedIndex = (int)editingEntry.ReturnCheckSequence; txtSuccess.Text = editingEntry.GoodScriptText; cboSuccessMatchType.SelectedIndex = (int)editingEntry.GoodResultMatchType; txtWarning.Text = editingEntry.WarningScriptText; cboWarningMatchType.SelectedIndex = (int)editingEntry.WarningResultMatchType; txtError.Text = editingEntry.ErrorScriptText; cboErrorMatchType.SelectedIndex = (int)editingEntry.ErrorResultMatchType; }
private void cmdTestService_Click(object sender, EventArgs e) { if (txtServiceURL.Text.Trim().Length > 0) { string lastStep = "Creating entry"; try { WSCollectorConfigEntry textEntry = new WSCollectorConfigEntry(); string successVal = ApplyConfigVarsOnField(txtSuccess.Text); string warningVal = ApplyConfigVarsOnField(txtWarning.Text); string errorVal = ApplyConfigVarsOnField(txtError.Text); textEntry.ServiceBaseURL = txtServiceURL.Text; textEntry.ServiceBindingName = cboEndPoint.Text; textEntry.MethodName = cboMethodName.Text; textEntry.ParametersFromString(txtParameters.Text); 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.ReturnCheckSequence = (CollectorAgentReturnValueCheckSequence)cboReturnCheckSequence.SelectedIndex; textEntry.GoodScriptText = successVal; textEntry.GoodResultMatchType = (CollectorAgentReturnValueCompareMatchType)cboSuccessMatchType.SelectedIndex; textEntry.WarningScriptText = warningVal; textEntry.WarningResultMatchType = (CollectorAgentReturnValueCompareMatchType)cboWarningMatchType.SelectedIndex; textEntry.ErrorScriptText = errorVal; textEntry.ErrorResultMatchType = (CollectorAgentReturnValueCompareMatchType)cboErrorMatchType.SelectedIndex; lastStep = "Running GetCurrentState"; MonitorState currentState = textEntry.GetCurrentState(); MessageBox.Show("Returned state: " + currentState.State.ToString() + "\r\nDetails: " + currentState.ReadAllRawDetails(), "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) { WSCollectorConfigEntry editingEntry = (WSCollectorConfigEntry)SelectedEntry; try { editingEntry.ServiceBaseURL = txtServiceURL.Text; editingEntry.ServiceBindingName = cboEndPoint.Text; editingEntry.MethodName = cboMethodName.Text; editingEntry.ParametersFromString(txtParameters.Text); 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.ReturnCheckSequence = (CollectorAgentReturnValueCheckSequence)cboReturnCheckSequence.SelectedIndex; editingEntry.GoodScriptText = txtSuccess.Text; editingEntry.GoodResultMatchType = (CollectorAgentReturnValueCompareMatchType)cboSuccessMatchType.SelectedIndex; editingEntry.WarningScriptText = txtWarning.Text; editingEntry.WarningResultMatchType = (CollectorAgentReturnValueCompareMatchType)cboWarningMatchType.SelectedIndex; editingEntry.ErrorScriptText = txtError.Text; editingEntry.ErrorResultMatchType = (CollectorAgentReturnValueCompareMatchType)cboErrorMatchType.SelectedIndex; SelectedEntry = editingEntry; DialogResult = System.Windows.Forms.DialogResult.OK; Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }