Beispiel #1
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();
        }