Ejemplo n.º 1
0
 public SystemEventLogging()
 {
     _eventLog = new EventLog();
     _eventLog.BeginInit();
     _eventLog.Log = "ВИРД";
     _eventLog.Source = "ВИРД";
     _eventLog.EndInit();
 }
Ejemplo n.º 2
0
 private EventLogWriter( )
 {
     evLog = new EventLog();
     evLog.BeginInit();
     evLog.Log = "Application";
     evLog.Source = "ShareIndexService";
     evLog.EndInit();
 }
Ejemplo n.º 3
0
        public void LoadConfig(TailFileConfig tailConfig, string configPath)
        {
            try
            {
                _eventLog = new EventLog(tailConfig.FilePath);
                _eventLog.EntryWritten += new EntryWrittenEventHandler(_eventLog_EntryWritten);
                _eventLog.EndInit();
                if (_eventLog.Entries.Count == -1)
                    return; // Crazy check just to ensure we have permissions to read the log
            }
            catch (System.Security.SecurityException ex)
            {
                MessageBox.Show(this, "Access denied when opening log: " + tailConfig.FilePath + "\n\n" + ex.Message);
                Close();
                return;
            }

            _messageLookup = new EventLogMesageLookup(_eventLog);

            if (tailConfig.FormBackColor != null)
                _eventListView.BackColor = tailConfig.FormBackColor.Value;
            if (tailConfig.FormTextColor != null)
                _eventListView.ForeColor = tailConfig.FormTextColor.Value;

            if (tailConfig.FormFont != null)
            {
                _eventListView.Font = tailConfig.FormFont;
                _eventMessageText.Font = tailConfig.FormFont;
            }

            if (tailConfig.Title != null)
                _formTitle = tailConfig.Title;
            else
                _formTitle = "EventLog - " + _eventLog.LogDisplayName;

            TabPage parentTab = this.Tag as TabPage;
            if (parentTab != null)
                parentTab.Text = _formTitle;

            if (tailConfig.ColumnFilters != null)
            {
                foreach (List<string> filter in tailConfig.ColumnFilters)
                {
                    List<Regex> columnFilter = new List<Regex>();
                    foreach (string regexPattern in filter)
                    {
                        if (!string.IsNullOrEmpty(regexPattern))
                            columnFilter.Add(new Regex(regexPattern));
                        else
                            columnFilter.Add(null);
                    }
                    _columnFilters.Add(columnFilter);
                }
            }

            _filterActive = tailConfig.ColumnFilterActive;
            _displayTabIcon = tailConfig.DisplayTabIcon;

            if (Visible)
            {
                ConfigureColumnFilter(_filterActive);
            }
        }