Beispiel #1
0
        private void LoadSources()
        {
            if (cboLog.SelectedIndex > -1)
            {
                try
                {
                    EventLogCollectorEntry selectedEntry;
                    if (SelectedEntry != null)
                    {
                        selectedEntry = (EventLogCollectorEntry)SelectedEntry;
                    }
                    else
                    {
                        selectedEntry = (EventLogCollectorEntry)SelectedEventLogEntry;
                    }

                    string hostName = txtComputer.Text;
                    if (hostName == ".")
                    {
                        hostName = System.Net.Dns.GetHostName();
                    }

                    List <ListViewItem> sources = new List <ListViewItem>();
                    lvwSources.BeginUpdate();
                    lvwSources.Items.Clear();
                    foreach (string s in EventLogUtil.GetEventSources(hostName, cboLog.SelectedItem.ToString()))
                    {
                        ListViewItem lvi = new ListViewItem(s);
                        if (selectedEntry.Sources.Contains(s))
                        {
                            lvi.Checked = true;
                        }
                        sources.Add(lvi);
                    }
                    lvwSources.Items.AddRange(sources.ToArray());
                }
                catch (System.Security.SecurityException)
                {
                    MessageBox.Show("This editor window requires that the application runs in Administrative mode to access all functionality!\r\nPlease restart the application in 'Administrative' mode if you need to access all functionality.", "Admin Access", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    lvwSources.EndUpdate();
                }
            }
        }
Beispiel #2
0
        private void LoadComputerEventsLogs()
        {
            try
            {
                cboLog.Items.Clear();
                if (txtComputer.Text.Trim().Length == 0)
                {
                    txtComputer.Text = System.Net.Dns.GetHostName();
                }
                string hostName = txtComputer.Text;
                if (hostName == ".")
                {
                    hostName = System.Net.Dns.GetHostName();
                }
                hostName = ApplyConfigVarsOnField(hostName);

                if (System.Net.Dns.GetHostAddresses(hostName).Length == 0)
                {
                    return;
                }

                foreach (string eventLogName in EventLogUtil.GetEventLogNames(hostName))
                {
                    cboLog.Items.Add(eventLogName);
                }
                EventLogCollectorEntry selectedEntry;
                if (SelectedEntry != null)
                {
                    selectedEntry = (EventLogCollectorEntry)SelectedEntry;
                }
                else
                {
                    selectedEntry = SelectedEventLogEntry;
                }

                if (selectedEntry.EventLog != null)
                {
                    cboLog.SelectedItem = selectedEntry.EventLog;
                }
                else
                {
                    cboLog.SelectedItem = "Application";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Load Event logs", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            CheckOkEnabled();
        }
Beispiel #3
0
        private void LoadSources()
        {
            if (cboLog.SelectedIndex > -1)
            {
                try
                {
                    string hostName = txtComputer.Text;
                    if (hostName == ".")
                    {
                        hostName = System.Net.Dns.GetHostName();
                    }
                    hostName = ApplyConfigVarsOnField(hostName);

                    List <ListViewItem> sources         = new List <ListViewItem>();
                    List <ListViewItem> sourcesSelected = new List <ListViewItem>();
                    lvwSources.BeginUpdate();
                    lvwSources.Items.Clear();
                    lvwSourcesSelected.Items.Clear();
                    foreach (string s in EventLogUtil.GetEventSources(hostName, cboLog.SelectedItem.ToString()))
                    {
                        ListViewItem lvi = new ListViewItem(s);
                        if (SelectedSources.Contains(s))
                        {
                            sourcesSelected.Add(lvi);
                        }
                        else
                        {
                            if (txtQuickFilter.Text.Trim().Length < 2 || s.ToLower().Contains(txtQuickFilter.Text))
                            {
                                sources.Add(lvi);
                            }
                        }
                    }
                    lvwSources.Items.AddRange(sources.ToArray());
                    lvwSourcesSelected.Items.AddRange(sourcesSelected.ToArray());
                }
                catch (System.Security.SecurityException)
                {
                    MessageBox.Show("This editor window requires that the application runs in Administrative mode to access all functionality!\r\nPlease restart the application in 'Administrative' mode if you need to access all functionality.", "Admin Access", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    lvwSources.EndUpdate();
                }
            }
        }