public override void LoadList()
 {
     if (SelectedConfig != null)
     {
         lvwEntries.BeginUpdate();
         lvwEntries.Items.Clear();
         try
         {
             SoapWebServicePingCollectorConfig currentConfig = (SoapWebServicePingCollectorConfig)SelectedConfig;
             foreach (SoapWebServicePingConfigEntry entry in currentConfig.Entries)
             {
                 ListViewItem lvi = new ListViewItem(entry.ServiceBaseURL);
                 lvi.SubItems.Add(entry.ServiceName);
                 lvi.SubItems.Add(entry.MethodName);
                 lvi.SubItems.Add(entry.ToStringFromParameters());
                 lvi.Tag = entry;
                 lvwEntries.Items.Add(lvi);
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         finally
         {
             lvwEntries.EndUpdate();
         }
     }
     base.LoadList();
 }
Esempio n. 2
0
 public override void LoadDisplayData()
 {
     if (Collector != null)
     {
         SoapWebServicePingCollectorConfig config = (SoapWebServicePingCollectorConfig)Collector.AgentConfig;
         lvwEntries.Items.Clear();
         foreach (SoapWebServicePingConfigEntry soapWebServicePingConfigEntry in config.Entries)
         {
             ListViewItem lvi = new ListViewItem(string.Format("{0}\\{1}", soapWebServicePingConfigEntry.ServiceBaseURL, soapWebServicePingConfigEntry.MethodName));
             lvi.SubItems.Add("-");
             lvi.Tag = soapWebServicePingConfigEntry;
             lvwEntries.Items.Add(lvi);
         }
     }
 }
        public override void OKClicked()
        {
            if (CheckOKEnabled())
            {
                if (SelectedConfig == null)
                {
                    SelectedConfig = new SoapWebServicePingCollectorConfig();
                }

                ((SoapWebServicePingCollectorConfig)SelectedConfig).Entries.Clear();
                foreach (ListViewItem lvi in lvwEntries.Items)
                {
                    SoapWebServicePingConfigEntry soapWebServicePingConfigEntry = (SoapWebServicePingConfigEntry)lvi.Tag;
                    ((SoapWebServicePingCollectorConfig)SelectedConfig).Entries.Add(soapWebServicePingConfigEntry);
                }
                DialogResult = System.Windows.Forms.DialogResult.OK;
                Close();
            }
        }
Esempio n. 4
0
        public override MonitorState GetState()
        {
            MonitorState  returnState         = new MonitorState();
            StringBuilder plainTextDetails    = new StringBuilder();
            StringBuilder htmlTextTextDetails = new StringBuilder();
            string        lastAction          = "";
            int           errors  = 0;
            int           success = 0;

            try
            {
                SoapWebServicePingCollectorConfig config = (SoapWebServicePingCollectorConfig)AgentConfig;
                plainTextDetails.AppendLine(string.Format("Calling {0} web service(s)", config.Entries.Count));
                htmlTextTextDetails.AppendLine(string.Format("<b>Calling {0} web service(s)</b>", config.Entries.Count));

                htmlTextTextDetails.AppendLine("<ul>");
                foreach (SoapWebServicePingConfigEntry soapWebServicePingConfigEntry in config.Entries)
                {
                    plainTextDetails.Append(string.Format("\t\t{0} - ", soapWebServicePingConfigEntry.ServiceBaseURL));
                    htmlTextTextDetails.Append(string.Format("<li>{0} - ", soapWebServicePingConfigEntry.ServiceBaseURL));

                    object val              = soapWebServicePingConfigEntry.ExecuteMethod();
                    string formattedVal     = "";
                    bool   checkResultMatch = soapWebServicePingConfigEntry.CheckResultMatch(val, soapWebServicePingConfigEntry.ResultType, soapWebServicePingConfigEntry.CustomValue1, soapWebServicePingConfigEntry.CustomValue2, out formattedVal);
                    //LastDetailMsg.LastValue = formattedVal;
                    if (checkResultMatch)
                    {
                        success++;
                        plainTextDetails.Append("Success - ");
                        htmlTextTextDetails.Append("<b>Success</b> - ");
                    }
                    else
                    {
                        errors++;
                        plainTextDetails.Append("Failure - ");
                        htmlTextTextDetails.Append("<b>Failure</b> - ");
                    }
                    switch (soapWebServicePingConfigEntry.ResultType)
                    {
                    case SoapWebServicePingResult.CheckAvailabilityOnly:
                        plainTextDetails.Append("Available");
                        htmlTextTextDetails.Append("Available");
                        break;

                    case SoapWebServicePingResult.NoValueOnly:
                        plainTextDetails.Append("No value returned");
                        htmlTextTextDetails.Append("No value returned");
                        break;

                    default:
                        plainTextDetails.Append(string.Format("Value:{0}", formattedVal));
                        htmlTextTextDetails.Append(string.Format("Value:{0}", formattedVal));
                        break;
                    }

                    plainTextDetails.AppendLine();
                    htmlTextTextDetails.AppendLine("</li>");
                }
                htmlTextTextDetails.AppendLine("</ul>");

                if (errors > 0 && success == 0) //are all errors
                {
                    returnState.State = CollectorState.Error;
                }
                else if (errors > 0 && success > 0) //mixture
                {
                    returnState.State = CollectorState.Warning;
                }
                else
                {
                    returnState.State = CollectorState.Good;
                }
                returnState.RawDetails  = plainTextDetails.ToString().TrimEnd('\r', '\n');
                returnState.HtmlDetails = htmlTextTextDetails.ToString();
            }
            catch (Exception ex)
            {
                returnState.RawDetails  = ex.Message;
                returnState.HtmlDetails = string.Format("<p><b>Last action:</b> {0}</p><blockquote>{1}</blockquote>", lastAction, ex.Message);
                returnState.State       = CollectorState.Error;
            }

            return(returnState);
        }
Esempio n. 5
0
 public SoapWebServicePingCollector()
 {
     AgentConfig = new SoapWebServicePingCollectorConfig();
 }