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);
            }
        }
Beispiel #2
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");
        }