Ejemplo n.º 1
0
 private void cmdOK_Click(object sender, EventArgs e)
 {
     if (CheckOKButtonEnable())
     {
         SelectedSoapWebServicePingConfig.Entries.Clear();
         foreach (ListViewItem lvi in lvwEntries.Items)
         {
             SoapWebServicePingConfigEntry soapWebServicePingConfigEntry = (SoapWebServicePingConfigEntry)lvi.Tag;
             SelectedSoapWebServicePingConfig.Entries.Add(soapWebServicePingConfigEntry);
         }
         DialogResult = System.Windows.Forms.DialogResult.OK;
         Close();
     }
 }
        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   = (SoapWebServicePingResultEnum)cboResultType.SelectedIndex;
            tmpSoapWebServicePingConfigEntry.CustomValue1 = cboErrorCustomValue1.Text;
            tmpSoapWebServicePingConfigEntry.CustomValue2 = cboErrorCustomValue2.Text;
            try
            {
                object pingResult = tmpSoapWebServicePingConfigEntry.ExecuteMethod();
                if (tmpSoapWebServicePingConfigEntry.ResultType == SoapWebServicePingResultEnum.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);
            }
        }
Ejemplo n.º 3
0
        public void ReadConfiguration(XmlDocument config)
        {
            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 = (SoapWebServicePingResultEnum)tmpResultType;
                }
                else
                {
                    webServicePingEntry.ResultType = SoapWebServicePingResultEnum.CheckAvailabilityOnly;
                }
                webServicePingEntry.CustomValue1 = addressNode.ReadXmlElementAttr("checkValue1");
                webServicePingEntry.CustomValue2 = addressNode.ReadXmlElementAttr("checkValue2");
                Entries.Add(webServicePingEntry);
            }
        }
Ejemplo n.º 4
0
        private void RefreshList()
        {
            System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;
            lvwHosts.BeginUpdate();
            foreach (ListViewItem itmX in lvwHosts.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;
                }
            }
            lvwHosts.EndUpdate();
            System.Windows.Forms.Cursor.Current = Cursors.Default;
            toolStripStatusLabel1.Text          = "Last updated " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
        }
 private void cmdOK_Click(object sender, EventArgs e)
 {
     if (CheckOKButtonEnable())
     {
         SelectedSoapWebServicePingConfigEntry = new SoapWebServicePingConfigEntry();
         SelectedSoapWebServicePingConfigEntry.ServiceBaseURL = txtServiceURL.Text;
         SelectedSoapWebServicePingConfigEntry.ServiceName    = txtServiceName.Text;
         SelectedSoapWebServicePingConfigEntry.MethodName     = txtMethodName.Text;
         SelectedSoapWebServicePingConfigEntry.Parameters     = new List <string>();
         foreach (string par in txtParameters.Text.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries))
         {
             if (par.Trim().Length > 0)
             {
                 SelectedSoapWebServicePingConfigEntry.Parameters.Add(par);
             }
         }
         SelectedSoapWebServicePingConfigEntry.CheckType    = (SoapWebServicePingCheckType)cboCheckType.SelectedIndex;
         SelectedSoapWebServicePingConfigEntry.ResultType   = (SoapWebServicePingResultEnum)cboResultType.SelectedIndex;
         SelectedSoapWebServicePingConfigEntry.CustomValue1 = cboErrorCustomValue1.Text;
         SelectedSoapWebServicePingConfigEntry.CustomValue2 = cboErrorCustomValue2.Text;
         DialogResult = System.Windows.Forms.DialogResult.OK;
         Close();
     }
 }