Esempio n. 1
0
        /// <summary>Counts the system log events of required type</summary>
        /// <param name="value">the type of log event (Error, Event, Information etc)</param>
        /// <returns>
        ///   Returns the number of System log entries of specified type
        /// </returns>
        public int GetSpecificEventEntriesCount(EventLogEntryType value)
        {
            EventLogEntryCollection systemEvents = (new EventLog("System", ".")).Entries;

            return(systemEvents
                   .OfType <EventLogEntry>()
                   .Count(e => e.EntryType == value));
        }
Esempio n. 2
0
        /// <summary>Counts the system log events of required type</summary>
        /// <param name="value">the type of log event (Error, Event, Information etc)</param>
        /// <returns>
        ///   Returns the number of System log entries of specified type
        /// </returns>
        public int GetSpecificEventEntriesCount(EventLogEntryType value)
        {
            // TODO : Implement GetSpecificEventEntriesCount
            //throw new NotImplementedException();

            EventLogEntryCollection systemEvents = (new EventLog("System", ".")).Entries;

            return(systemEvents.OfType <EventLogEntry>().Count(x => x.EntryType == value));
        }
Esempio n. 3
0
        /// <summary>Counts the system log events of required type</summary>
        /// <param name="value">the type of log event (Error, Event, Information etc)</param>
        /// <returns>
        ///   Returns the number of System log entries of specified type
        /// </returns>
        public int GetSpecificEventEntriesCount(EventLogEntryType value)
        {
            EventLogEntryCollection systemEvents = (new EventLog("System", ".")).Entries;


            return(systemEvents.OfType <EventLogEntry>().Count(x => x.EntryType == value));

            /*
             * var arr = new EventLogEntry[systemEvents.Count];
             * systemEvents.CopyTo(arr, 0);
             *
             * return arr.Where(x => x.EntryType == value).Count();
             */
            // TODO : Implement GetSpecificEventEntriesCount
            //throw new NotImplementedException();
        }
Esempio n. 4
0
        private static List <KeyValuePair <TimeSpan, TimeSpan> > GetBreaks(EventLogEntryCollection collection)
        {
            var      today      = DateTime.Now.Date;
            var      breaks     = new List <KeyValuePair <TimeSpan, TimeSpan> >();
            TimeSpan?breakStart = null;

            foreach (var log in collection.OfType <EventLogEntry>().Where(x => x.TimeGenerated.Date == today))
            {
                if (log.InstanceId == 4800)
                {
                    breakStart = log.TimeGenerated.TimeOfDay;
                }
                else if (log.InstanceId == 4801 && breakStart.HasValue)
                {
                    breaks.Add(new KeyValuePair <TimeSpan, TimeSpan>(breakStart.Value, log.TimeGenerated.TimeOfDay));
                    breakStart = null;
                }
            }

            return(breaks);
        }