private void UpdateNICs()
 {
     if (txtNIC.Text.Trim().Length > 0 && !fileSystemUpdated)
     {
         if (lvwNICs.SelectedItems.Count == 1)
         {
             ListViewItem   lvi  = lvwNICs.SelectedItems[0];
             NIXNICSubEntry dsse = (NIXNICSubEntry)lvwNICs.SelectedItems[0].Tag;
             dsse.NICName         = txtNIC.Text;
             dsse.WarningValueKB  = (long)warningNumericUpDown.Value;
             dsse.ErrorValueKB    = (long)errorNumericUpDown.Value;
             lvi.Text             = txtNIC.Text;
             lvi.SubItems[1].Text = warningNumericUpDown.Value.ToString();
             lvi.SubItems[2].Text = errorNumericUpDown.Value.ToString();
         }
         else
         {
             NIXNICSubEntry dsse = new NIXNICSubEntry()
             {
                 NICName = txtNIC.Text, WarningValueKB = (long)warningNumericUpDown.Value, ErrorValueKB = (long)errorNumericUpDown.Value
             };
             ListViewItem lvi = new ListViewItem()
             {
                 Text = dsse.NICName
             };
             lvi.SubItems.Add(dsse.WarningValueKB.ToString());
             lvi.SubItems.Add(dsse.ErrorValueKB.ToString());
             lvi.Tag = dsse;
             lvwNICs.Items.Add(lvi);
             lvwNICs.SelectedItems.Clear();
             lvi.Selected = true;
         }
     }
 }
Пример #2
0
        private void lblAutoAdd_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            try
            {
                SSHConnectionDetails sshConnection = sshConnectionDetails.Clone();
                sshConnection.ComputerName     = ApplyConfigVarsOnField(sshConnection.ComputerName);
                sshConnection.UserName         = ApplyConfigVarsOnField(sshConnection.UserName);
                sshConnection.Password         = ApplyConfigVarsOnField(sshConnection.Password);
                sshConnection.PrivateKeyFile   = ApplyConfigVarsOnField(sshConnection.PrivateKeyFile);
                sshConnection.PassPhrase       = ApplyConfigVarsOnField(sshConnection.PassPhrase);
                sshConnection.ConnectionName   = ApplyConfigVarsOnField(sshConnection.ConnectionName);
                sshConnection.ConnectionString = ApplyConfigVarsOnField(sshConnection.ConnectionString);

                if (lvwNICs.Items.Count > 0 && (MessageBox.Show("Clear all existing entries?", "Clear", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No))
                {
                    return;
                }
                else
                {
                    lvwNICs.Items.Clear();
                    lvwNICs.Items.Add(new ListViewItem("Querying " + sshConnection.ComputerName + "..."));
                    Application.DoEvents();
                }

                Renci.SshNet.SshClient sshClient = SshClientTools.GetSSHConnection(sshConnection);
                if (sshClient.IsConnected)
                {
                    lvwNICs.Items.Clear();
                    foreach (NicInfo di in NicInfo.GetCurrentNicStats(sshClient))
                    {
                        NIXNICSubEntry dsse = new NIXNICSubEntry()
                        {
                            NICName = di.Name, WarningValueKB = (long)warningNumericUpDown.Value, ErrorValueKB = (long)errorNumericUpDown.Value
                        };
                        ListViewItem lvi = new ListViewItem()
                        {
                            Text = dsse.NICName
                        };
                        lvi.SubItems.Add(dsse.WarningValueKB.ToString());
                        lvi.SubItems.Add(dsse.ErrorValueKB.ToString());
                        lvi.Tag = dsse;
                        lvwNICs.Items.Add(lvi);
                    }
                }
                else
                {
                    lvwNICs.Items.Clear();
                    MessageBox.Show("Could not connect to computer!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
 private void lvwNICs_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (lvwNICs.SelectedItems.Count == 1)
     {
         fileSystemUpdated = true;
         NIXNICSubEntry dsse = (NIXNICSubEntry)lvwNICs.SelectedItems[0].Tag;
         warningNumericUpDown.SaveValueSet((decimal)dsse.WarningValueKB);
         errorNumericUpDown.SaveValueSet((decimal)dsse.ErrorValueKB);
         txtNIC.Text       = dsse.NICName;
         fileSystemUpdated = false;
     }
     else if (lvwNICs.SelectedItems.Count == 0)
     {
         fileSystemUpdated = true;
         txtNIC.Text       = "";
         fileSystemUpdated = false;
     }
 }
Пример #4
0
        private void cmdOK_Click(object sender, EventArgs e)
        {
            NIXNICEntry selectedEntry;

            if (SelectedEntry == null)
            {
                SelectedEntry = new NIXNICEntry();
            }
            selectedEntry = (NIXNICEntry)SelectedEntry;
            selectedEntry.SSHConnection = sshConnectionDetails;
            selectedEntry.SubItems      = new List <ICollectorConfigSubEntry>();

            foreach (ListViewItem lvi in lvwNICs.Items)
            {
                NIXNICSubEntry dsse = (NIXNICSubEntry)lvi.Tag;
                selectedEntry.SubItems.Add(dsse);
            }

            DialogResult = System.Windows.Forms.DialogResult.OK;
            Close();
        }