Example #1
0
        public static String LongestIdleTime(DoublyLinkedList <LogEntry> log)
        {
            TimeSpan startTime, endTime;
            String   idle = "";

            if (log.Count() == 1 || log.Count == 0)
            {
                idle = "00:00:00";
            }
            else
            {
                for (int i = 0; i < log.Count() - 1; i++)
                {
                    startTime = TimeSpan.ParseExact(log.ItemAt(i).getTime(), @"h\:mm\:ss", CultureInfo.InvariantCulture);
                    endTime   = TimeSpan.ParseExact(log.ItemAt(i + 1).getTime(), @"h\:mm\:ss", CultureInfo.InvariantCulture);
                    double   diffInSeconds = (endTime - startTime).TotalSeconds;
                    TimeSpan time          = TimeSpan.FromSeconds(diffInSeconds);
                    idle = time.ToString(@"h\:mm\:ss");
                }
            }
            return(idle);
        }
Example #2
0
        public static DoublyLinkedList <LogEntry> AddEntry(LogEntry entry, DoublyLinkedList <LogEntry> list, int size = 50)
        {
            DoublyLinkedList <LogEntry> newDoublyLinkedList = list.Clone();

            if (list.Count() < size)
            {
                newDoublyLinkedList.Add(entry);
            }
            else
            {
                newDoublyLinkedList.Remove(newDoublyLinkedList.ItemAt(0));
                newDoublyLinkedList.Add(entry);
            }
            return(newDoublyLinkedList);
        }