Example #1
0
        private void cmdTestAddress_Click(object sender, EventArgs e)
        {
            HttpPingEntry tmpHttpPingEntry = new HttpPingEntry();

            if (!(txtAddress.Text.StartsWith("http://", StringComparison.CurrentCultureIgnoreCase) || txtAddress.Text.StartsWith("https://", StringComparison.CurrentCultureIgnoreCase)))
            {
                txtAddress.Text = "http://" + txtAddress.Text;
            }
            tmpHttpPingEntry.Url         = txtAddress.Text;
            tmpHttpPingEntry.ProxyServer = txtProxyServer.Text;
            tmpHttpPingEntry.MaxTime     = (int)nudExpextedTime.Value;
            tmpHttpPingEntry.TimeOut     = (int)nudTimeOut.Value;
            try
            {
                int pingTime = tmpHttpPingEntry.Ping();
                if (pingTime == int.MaxValue)
                {
                    throw new Exception("An error occured while trying to ping the URL\r\n" + tmpHttpPingEntry.LastError);
                }

                MessageBox.Show(string.Format("Test success!\r\nTime: {0}ms", pingTime), "Test", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #2
0
 private void cmdOK_Click(object sender, EventArgs e)
 {
     if (CheckOKButtonEnable())
     {
         SelectedHttpPingEntry             = new HttpPingEntry();
         SelectedHttpPingEntry.Url         = txtAddress.Text;
         SelectedHttpPingEntry.ProxyServer = txtProxyServer.Text;
         SelectedHttpPingEntry.MaxTime     = (int)nudExpextedTime.Value;
         SelectedHttpPingEntry.TimeOut     = (int)nudTimeOut.Value;
         DialogResult = System.Windows.Forms.DialogResult.OK;
         Close();
     }
 }
Example #3
0
 private void cmdOK_Click(object sender, EventArgs e)
 {
     if (CheckOKButtonEnable())
     {
         SelectedHttpPingConfig.Entries.Clear();
         foreach (ListViewItem lvi in lvwEntries.Items)
         {
             HttpPingEntry httpPingEntry = (HttpPingEntry)lvi.Tag;
             SelectedHttpPingConfig.Entries.Add(httpPingEntry);
         }
         DialogResult = System.Windows.Forms.DialogResult.OK;
         Close();
     }
 }
Example #4
0
        public void ReadConfiguration(XmlDocument config)
        {
            XmlElement root = config.DocumentElement;

            Entries.Clear();
            foreach (XmlElement addressNode in root.SelectNodes("addresses/address"))
            {
                HttpPingEntry httpPingEntry = new HttpPingEntry();
                httpPingEntry.Url         = addressNode.ReadXmlElementAttr("url", "");
                httpPingEntry.ProxyServer = addressNode.ReadXmlElementAttr("proxyServer", "");
                httpPingEntry.TimeOut     = int.Parse(addressNode.ReadXmlElementAttr("timeOutMS", "5000"));
                httpPingEntry.MaxTime     = int.Parse(addressNode.ReadXmlElementAttr("maxTimeMS", "1000"));
                Entries.Add(httpPingEntry);
            }
        }
Example #5
0
        private void RefreshList()
        {
            System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;
            lvwHosts.BeginUpdate();
            foreach (ListViewItem itmX in lvwHosts.Items)
            {
                HttpPingEntry httpPingEntry = (HttpPingEntry)itmX.Tag;
                try
                {
                    int pingTime = httpPingEntry.Ping();

                    itmX.SubItems[1].Text = pingTime.ToString();
                    if (pingTime > httpPingEntry.TimeOut)
                    {
                        itmX.ImageIndex       = 2;
                        itmX.BackColor        = Color.Salmon;
                        itmX.SubItems[1].Text = "Time-out";
                    }
                    else if (pingTime > httpPingEntry.MaxTime)
                    {
                        itmX.ImageIndex = 1;
                        itmX.BackColor  = Color.SandyBrown;
                    }
                    else
                    {
                        itmX.ImageIndex = 0;
                        itmX.BackColor  = SystemColors.Window;
                    }
                }
                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");
        }