public void Add(PageView pv) { if (!m_sites.Contains(pv.Site)) { m_sites.Add(pv.Site); } }
public void Add(PageView pv) { if (!m_viewsByVisitors.TryGetValue(pv.Visitor, out List <long> timestamps)) { timestamps = new List <long>(); m_viewsByVisitors[pv.Visitor] = timestamps; } timestamps.Add(pv.Timestamp); }
private static void AddPvToUsers(PageView pv) { if (!visitors.TryGetValue(pv.Visitor, out VisitorInfo visitor)) { visitor = new VisitorInfo(pv.Visitor); visitors[pv.Visitor] = visitor; } visitor.Add(pv); }
private static void AddPvToSites(PageView pv) { if (!sites.TryGetValue(pv.Site, out SiteInfo site)) { site = new SiteInfo(pv.Site); sites[pv.Site] = site; } site.Add(pv); }
static void Main(string[] args) { //collect all files from directory pointed by user // argument[0] must be directory if (args.Length != 1) { PrintUsage(); Console.ReadLine(); return; } sites = new Dictionary <string, SiteInfo>(); visitors = new Dictionary <string, VisitorInfo>(); foreach (string file in Directory.EnumerateFiles(args[0], "*.csv")) { string[] lines = File.ReadAllLines(file); foreach (string line in lines) { PageView pv = PageView.ParseLineToPageView(line); if (pv != null) { AddPvToSites(pv); AddPvToUsers(pv); } } } //Pre-process all data foreach (var site in sites) { site.Value.Process(); } foreach (var visitor in visitors) { visitor.Value.Process(); } //ask user for queries while (!exit) { DisplayMainMenu(); } }