Exemplo n.º 1
0
 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.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);
         }
     }
 }
Exemplo n.º 2
0
Arquivo: WS.cs Projeto: utobe/QuickMon
        public void FromXml(string configurationString)
        {
            XmlDocument config = new XmlDocument();

            config.LoadXml(configurationString);
            XmlElement root = config.DocumentElement;

            Entries.Clear();
            foreach (XmlElement addressNode in root.SelectNodes("webServices/webService"))
            {
                WSCollectorConfigEntry webServicePingEntry = new WSCollectorConfigEntry();
                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);
            }
        }
Exemplo n.º 3
0
        private void cmdTestService_Click(object sender, EventArgs e)
        {
            if (txtServiceURL.Text.Trim().Length > 0)
            {
                string lastStep = "Creating entry";
                try
                {
                    WSCollectorConfigEntry textEntry = new WSCollectorConfigEntry();
                    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);
                    }
                }
            }
        }
Exemplo n.º 4
0
        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();
            chkResultXOr.Checked = !editingEntry.ResultIsSuccess;
            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;
            cboValueOrMacro.Text             = editingEntry.CheckValueOrMacro;
            chkUseRegEx.Checked = editingEntry.UseRegEx;
        }
Exemplo n.º 5
0
        public void FromXml(string configurationString)
        {
            XmlDocument config = new XmlDocument();

            config.LoadXml(configurationString);
            XmlElement root = config.DocumentElement;

            Entries.Clear();
            foreach (XmlElement addressNode in root.SelectNodes("webServices/webService"))
            {
                WSCollectorConfigEntry webServicePingEntry = new WSCollectorConfigEntry();
                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);

                if (addressNode.ReadXmlElementAttr("resultIsSuccess", true))
                {
                    webServicePingEntry.ReturnCheckSequence = CollectorAgentReturnValueCheckSequence.GWE;
                }
                else
                {
                    webServicePingEntry.ReturnCheckSequence = CollectorAgentReturnValueCheckSequence.EWG;
                }

                webServicePingEntry.GoodResultMatchType = CollectorAgentReturnValueCompareMatchType.Contains;
                webServicePingEntry.GoodScriptText      = addressNode.ReadXmlElementAttr("valueOrMacro", "");
                if (webServicePingEntry.ValueExpectedReturnType == WebServiceValueExpectedReturnTypeEnum.CheckAvailabilityOnly)
                {
                    webServicePingEntry.GoodScriptText = "[Available]";
                }
                else if (addressNode.ReadXmlElementAttr("useRegEx", false))
                {
                    webServicePingEntry.GoodResultMatchType = CollectorAgentReturnValueCompareMatchType.RegEx;
                }
                else if (webServicePingEntry.GoodScriptText.StartsWith("[Between] "))
                {
                    webServicePingEntry.GoodResultMatchType = CollectorAgentReturnValueCompareMatchType.Between;
                    webServicePingEntry.GoodScriptText      = webServicePingEntry.GoodScriptText.Substring("[Between] ".Length);
                    webServicePingEntry.GoodScriptText      = webServicePingEntry.GoodScriptText.Replace("[and]", "and");
                }
                else if (webServicePingEntry.GoodScriptText.StartsWith("[LargerThan] "))
                {
                    webServicePingEntry.GoodResultMatchType = CollectorAgentReturnValueCompareMatchType.LargerThan;
                    webServicePingEntry.GoodScriptText      = webServicePingEntry.GoodScriptText.Substring("[LargerThan] ".Length);
                }
                else if (webServicePingEntry.GoodScriptText.StartsWith("[SmallerThan] "))
                {
                    webServicePingEntry.GoodResultMatchType = CollectorAgentReturnValueCompareMatchType.SmallerThan;
                    webServicePingEntry.GoodScriptText      = webServicePingEntry.GoodScriptText.Substring("[SmallerThan] ".Length);
                }
                else if (webServicePingEntry.GoodScriptText.StartsWith("[Contains] "))
                {
                    webServicePingEntry.GoodResultMatchType = CollectorAgentReturnValueCompareMatchType.Contains;
                    webServicePingEntry.GoodScriptText      = webServicePingEntry.GoodScriptText.Substring("[Contains] ".Length);
                }
                else if (webServicePingEntry.GoodScriptText.StartsWith("[BeginsWith] "))
                {
                    webServicePingEntry.GoodResultMatchType = CollectorAgentReturnValueCompareMatchType.StartsWith;
                    webServicePingEntry.GoodScriptText      = webServicePingEntry.GoodScriptText.Substring("[BeginsWith] ".Length);
                }
                else if (webServicePingEntry.GoodScriptText.StartsWith("[EndsWith] "))
                {
                    webServicePingEntry.GoodResultMatchType = CollectorAgentReturnValueCompareMatchType.EndsWith;
                    webServicePingEntry.GoodScriptText      = webServicePingEntry.GoodScriptText.Substring("[EndsWith] ".Length);
                }

                webServicePingEntry.WarningResultMatchType = CollectorAgentReturnValueCompareMatchType.Contains;
                webServicePingEntry.WarningScriptText      = "[null]";

                webServicePingEntry.ErrorResultMatchType = CollectorAgentReturnValueCompareMatchType.Contains;
                webServicePingEntry.ErrorScriptText      = "[any]";

                if (webServicePingEntry.ReturnCheckSequence == CollectorAgentReturnValueCheckSequence.EWG)
                {
                    CollectorAgentReturnValueCompareMatchType tmpMT = webServicePingEntry.GoodResultMatchType;
                    string tmpTestValue = webServicePingEntry.GoodScriptText;
                    webServicePingEntry.GoodResultMatchType  = webServicePingEntry.ErrorResultMatchType;
                    webServicePingEntry.GoodScriptText       = webServicePingEntry.ErrorScriptText;
                    webServicePingEntry.ErrorResultMatchType = tmpMT;
                    webServicePingEntry.ErrorScriptText      = tmpTestValue;
                }

                Entries.Add(webServicePingEntry);
            }
            foreach (XmlElement carvceEntryNode in root.SelectNodes("carvcesEntries/carvceEntry"))
            {
                WSCollectorConfigEntry webServicePingEntry = new WSCollectorConfigEntry();
                XmlNode dataSourceNode = carvceEntryNode.SelectSingleNode("dataSource");
                webServicePingEntry.ServiceBaseURL     = dataSourceNode.ReadXmlElementAttr("url", "");
                webServicePingEntry.ServiceBindingName = dataSourceNode.ReadXmlElementAttr("serviceBindingName", "");
                webServicePingEntry.MethodName         = dataSourceNode.ReadXmlElementAttr("method", "");
                string parameterStr = dataSourceNode.ReadXmlElementAttr("paramatersCSV", "");
                webServicePingEntry.Parameters = new List <string>();
                if (parameterStr.Trim().Length > 0)
                {
                    webServicePingEntry.Parameters.AddRange(parameterStr.Split(','));
                }
                webServicePingEntry.ValueExpectedReturnType = WebServiceValueExpectedReturnTypeConverter.FromString(dataSourceNode.ReadXmlElementAttr("valueExpectedReturnType", ""));
                webServicePingEntry.MacroFormatType         = WebServiceMacroFormatTypeConverter.FromString(dataSourceNode.ReadXmlElementAttr("macroFormatType", ""));
                webServicePingEntry.CheckValueArrayIndex    = dataSourceNode.ReadXmlElementAttr("arrayIndex", 0);
                webServicePingEntry.CheckValueColumnIndex   = dataSourceNode.ReadXmlElementAttr("columnIndex", 0);
                webServicePingEntry.PrimaryUIValue          = dataSourceNode.ReadXmlElementAttr("primaryUIValue", false);

                XmlNode testConditionsNode = carvceEntryNode.SelectSingleNode("testConditions");
                if (testConditionsNode != null)
                {
                    webServicePingEntry.ReturnCheckSequence = CollectorAgentReturnValueCompareEngine.CheckSequenceTypeFromString(testConditionsNode.ReadXmlElementAttr("testSequence", "gwe"));
                    XmlNode goodScriptNode = testConditionsNode.SelectSingleNode("success");
                    webServicePingEntry.GoodResultMatchType = CollectorAgentReturnValueCompareEngine.MatchTypeFromString(goodScriptNode.ReadXmlElementAttr("testType", "match"));
                    webServicePingEntry.GoodScriptText      = goodScriptNode.InnerText;
                    if (webServicePingEntry.ValueExpectedReturnType == WebServiceValueExpectedReturnTypeEnum.CheckAvailabilityOnly)
                    {
                        webServicePingEntry.GoodScriptText = "[Available]";
                    }

                    XmlNode warningScriptNode = testConditionsNode.SelectSingleNode("warning");
                    webServicePingEntry.WarningResultMatchType = CollectorAgentReturnValueCompareEngine.MatchTypeFromString(warningScriptNode.ReadXmlElementAttr("testType", "match"));
                    webServicePingEntry.WarningScriptText      = warningScriptNode.InnerText;

                    XmlNode errorScriptNode = testConditionsNode.SelectSingleNode("error");
                    webServicePingEntry.ErrorResultMatchType = CollectorAgentReturnValueCompareEngine.MatchTypeFromString(errorScriptNode.ReadXmlElementAttr("testType", "match"));
                    webServicePingEntry.ErrorScriptText      = errorScriptNode.InnerText;
                }
                else
                {
                    webServicePingEntry.ReturnCheckSequence = CollectorAgentReturnValueCheckSequence.GWE;
                }

                Entries.Add(webServicePingEntry);
            }
        }