/// <summary> /// Collects not empty info for each record at the record's time. /// </summary> public IEnumerable<Info> CollectOpenInfo() { var result = new List<Info>(); for (int iRecord = 0; iRecord < _records.Count; ++iRecord) { var record = _records[iRecord]; // init info var info = new Info() { Path = record.Path }; // get the rest CollectFileInfo(info, iRecord + 1, record.Time); if (info.Idle.TotalHours < Settings.Default.Limit0) continue; // return not empty if (info.UseCount > 0) result.Add(info); } SetEvidences(result, CollectEvidences()); return result; }
/// <summary> /// Collects info for a file. /// </summary> void CollectFileInfo(Info info, int start, DateTime now) { for (int iRecord = start; iRecord < _records.Count; ++iRecord) { // skip data from the future var record = _records[iRecord]; if (record.Time > now) continue; // skip alien if (!record.Path.Equals(info.Path, StringComparison.OrdinalIgnoreCase)) continue; // count cases, init if not yet if (++info.UseCount == 1) { info.Head = record.Time; info.Tail = record.Time; info.Idle = now - record.Time; info.KeyCount = record.Keys; info.DayCount = 1; continue; } // sum keys info.KeyCount += record.Keys; // different days if (info.Head.Date != record.Time.Date) { ++info.DayCount; // Why 2 is the best for all records so far, 3..4 are so so, and 5 is bad? // NB // Factor 4 gives values 0..4 (max is used); factors 5..6 still give 0..4 (max is not used). // Should we just use 4 or should we dig the max factor value M which gives values 0..M? // NB // With 2 and Idle > X Activity is rare/never actually equal to 2. if ((now - record.Time).TotalDays < 2) ++info.Activity; } // now save the record time info.Head = record.Time; } }
/// <summary> /// Collects the unordered history info. /// </summary> public IList<Info> CollectInfo(DateTime now, bool reduced) { var result = new List<Info>(); var set = new HashSet<string>(StringComparer.OrdinalIgnoreCase); for (int iRecord = 0; iRecord < _records.Count; ++iRecord) { // skip data from the future var record = _records[iRecord]; if (record.Time > now) continue; // add, skip existing if (!set.Add(record.Path)) continue; // skip recent and too old var idle = now - record.Time; if (reduced && (idle.TotalHours < Settings.Default.Limit0 || record.What == Record.AGED)) continue; // init info var info = new Info() { Path = record.Path, Head = record.Time, Tail = record.Time, Idle = idle, KeyCount = record.Keys, DayCount = 1, UseCount = 1, }; // get the rest CollectFileInfo(info, iRecord + 1, now); result.Add(info); } return result; }