Esempio n. 1
0
 public static TimePeriod Create(TimeSpan timeSpan)
 {
     var now = DateTime.UtcNow;
     var startTime = (timeSpan == TimeSpan.MaxValue) ? DateTime.MinValue : now - timeSpan;
     var res = new TimePeriod(startTime, now);
     return res;
 }
Esempio n. 2
0
 public static TimePeriod TryRead(NameValueCollection vals)
 {
     var res = new TimePeriod(vals);
     if (res.StartTime.Equals(Unlimited.StartTime))
         return null;
     return res;
 }
Esempio n. 3
0
        public static List<SessionEx> Parse(string dataPath, TimePeriod period)
        {
            var watch = Stopwatch.StartNew();

            var res = new List<SessionEx>();

            {
                var sessions = DataReader.GetSessionsFromPath(dataPath, period);

                foreach (var session in sessions)
                {
                    var records = DataReader.GetRecordsFromSession(session, period);

                    var sessionEx = new SessionEx
                                        {
                                            Id = session.Id,
                                            CreationTime = session.CreationTime,
                                            LastUpdateTime = session.LastUpdateTime
                                        };
                    res.Add(sessionEx);

                    sessionEx.Records = records.ConvertAll(
                        val => new RecordEx(sessionEx)
                                {
                                    SessionId = val.SessionId,
                                    Name = val.Name,
                                    Time = val.Time,
                                    Value = val.Value
                                });
                }
            }

            GC.Collect();
            Trace.WriteLine(string.Format("Parsing data: {0} secs", watch.Elapsed.TotalSeconds));
            return res;
        }