Exemplo n.º 1
0
 public void Add(PageView pv)
 {
     if (!m_sites.Contains(pv.Site))
     {
         m_sites.Add(pv.Site);
     }
 }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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();
            }
        }