Exemplo n.º 1
0
        public static List <EventData> ReadLogDataJsonLite(string FileName, bool RelativeTime, EventDataListExtension.ESortType Sort)
        {
            string           _json   = File.ReadAllText(FileName);
            var              _data   = JsonConvert.DeserializeObject <List <Dictionary <string, string> > >(_json);
            List <EventData> _return = new List <EventData>();

            foreach (var _l in _data)
            {
                EventData e = new EventData();
                foreach (var _k in _l.Keys)
                {
                    if (_k == "PersonIdentifier")
                    {
                        e.PersonIdentifier = _l[_k];
                    }
                    else if (_k == "TimeStamp")
                    {
                        e.TimeStamp = DateTime.Parse(_l[_k]);
                    }
                    else if (_k == "EventName")
                    {
                        e.EventName = _l[_k];
                    }
                    else if (_k == "TimeDifferencePrevious")
                    {
                        e.TimeDifferencePrevious = TimeSpan.Parse(_l[_k]);
                    }
                    else
                    {
                        e.AddEventValue(_k, _l[_k]);
                    }
                }

                _return.Add(e);
            }

            if (RelativeTime)
            {
                _return = EventDataListExtension.SortByRelativeTime(_return, Sort);
                _return.ComputeTimedifferencePreviousWithRelativeTimes();
            }
            else
            {
                _return = EventDataListExtension.SortByTimeStamp(_return, Sort);
                _return.ComputeTimedifferencePrevious();
            }

            return(_return);
        }