Beispiel #1
0
 public SendersManager()
 {
     new EventLogPermission(EventLogPermissionAccess.Administer, ".").Demand();
     _localLog = new EventLog("Application", ".", "el2slservice");
     _senders = new List<SyslogSender>();
     _config = new El2SlConfig();
 }
Beispiel #2
0
 public SyslogSender(El2SlConfig config, EventLog eventLog, EventLog localLog)
 {
     _enUS = new CultureInfo("en-US");
     _localLog = localLog;
     _config   = config;
     _eventLog = eventLog;
     _encoding = new UTF8Encoding();
     _eventLog.EnableRaisingEvents = true;
     _eventLog.EntryWritten += eventLog_EntryWritten;
     _udpClient = new UdpClient();
     _udpClient.DontFragment = false;
     _udpClient.Connect(_config.Host, _config.Port);
     try
     {
         if (_udpClient.Client.Connected)
         {
             _localLog.WriteEntry(
                 string.Format("el2slservice connected to syslog for send events of {0}",_eventLog.LogDisplayName),
                 EventLogEntryType.Information);
         }
     }
     catch (SocketException se)
     {
         _localLog.WriteEntry("el2slservice can not connect to syslog. Reason: " + se.Message, EventLogEntryType.Error);
     }
 }
Beispiel #3
0
        public FormJT2SL(El2SlConfig config, EventLog eventLog, EventLogEntryType eventLogEntryType)
        {
            InitializeComponent();
            _eventLog = eventLog;
            _eventLogEntryType = eventLogEntryType;

            lInfo.Text = string.Format("{0}:{1}", _eventLog.LogDisplayName, eventLogEntryType.ToString());

            cbEnabled.Checked = config.LoggingEnabled(eventLog, eventLogEntryType);
            cbEnabled_CheckedChanged(cbEnabled, new EventArgs());

            #region Grid fill

            #region Preparing Columns headers

            for ( int fh = 0; fh < SFacilityes.Length; fh++ ) // columns
            {
                tlpFacilityPriority.ColumnCount++;
                VerticalLabel lColumn = new VerticalLabel();
                lColumn.Text = SFacilityes[fh];
                //lColumn.TextAlign = ContentAlignment.BottomCenter;
                tlpFacilityPriority.Controls.Add(lColumn, tlpFacilityPriority.ColumnCount - 1, 0);
            }

            #endregion

            for (int pt = 0; pt < SPriorityes.Length; pt++ ) // rows
            {
                #region Preparing row labels

                Label lRow = new Label();
                lRow.Text = SPriorityes[pt];
                lRow.AutoSize = true;
                tlpFacilityPriority.Controls.Add(lRow, 0, tlpFacilityPriority.RowCount);

                #endregion

                int currentColumn = 1;
                tlpFacilityPriority.RowCount++;
                for (int ft = 0; ft < SFacilityes.Length; ft++) // columns
                {
                    int fpNum = SyslogFacilityPriorityPair.ConvertPairToInt(ft, pt);
                    RadioButton bSelection = new RadioButton();
                    bSelection.Width = 16;
                    bSelection.Tag = fpNum;
                    bSelection.Checked = config.LoggingFacilityPriority(eventLog, eventLogEntryType).AsInt() ==
                                         fpNum;
                    bSelection.CheckedChanged += BSelectionOnCheckedChanged;
                    tlpFacilityPriority.Controls.Add(bSelection, currentColumn, tlpFacilityPriority.RowCount - 1);
                    currentColumn++;
                }

            }

            #endregion
        }
        public JournalLevelTextBox(El2SlConfig config, EventLog eventLog, EventLogEntryType eventLogEntryType)
        {
            _eventLog = eventLog;
            _eventLogEntryType = eventLogEntryType;
            _config = config;

            InitializeComponent();

            UpdateControls();
        }
Beispiel #5
0
        public FormMain()
        {
            _config = new El2SlConfig();
            InitializeComponent();

            #region Fill Grid

            #region Preparing rows labels

            foreach (EventLogEntryType et in Enum.GetValues(typeof (EventLogEntryType))) // columns
            {
                tlpJournals.ColumnCount++;
                VerticalLabel jLevels = new VerticalLabel();
                jLevels.Text = et.ToString();
                tlpJournals.Controls.Add(jLevels, tlpJournals.ColumnCount - 1, 0);
            }

            #endregion

            foreach (EventLog eventLog in EventLog.GetEventLogs()) // rows
            {
                #region Preparing row labels

                Label lJournals = new Label();
                lJournals.TextAlign = ContentAlignment.MiddleRight;
                lJournals.Text = eventLog.LogDisplayName;
                lJournals.AutoSize = true;
                tlpJournals.Controls.Add(lJournals, 0, tlpJournals.RowCount);

                #endregion

                int currentColumn = 1;
                tlpJournals.RowCount++;
                foreach (EventLogEntryType eventLogEntryType in Enum.GetValues(typeof (EventLogEntryType))) // columns
                {
                    tlpJournals.Controls.Add(new JournalLevelTextBox(_config, eventLog, eventLogEntryType), currentColumn,
                                             tlpJournals.RowCount - 1);
                    currentColumn++;
                }

            }

            //tlpJournals.RowCount--;
            //tlpJournals.ColumnCount--;

            #endregion

            tbHost.Text = _config.Host;
            nudPort.Value = _config.Port;
        }