Beispiel #1
0
 // The method checks whether the record contains new data and if so, adds it to sessions data.
 public void AddEntry(AirBnbSessionRecord record)
 {
     // In case record's user already present in the sessions data
     if (UsersToSessions.ContainsKey(record.VisitorId))
     {
         UsersToSessions[record.VisitorId].Add((record.SessionEnd - record.SessionStart).TotalMinutes);
     }
     // In case the record contains new user id
     else
     {
         UsersToSessions.Add(record.VisitorId, new List <double>()
         {
             (record.SessionEnd - record.SessionStart).TotalMinutes
         });
     }
 }
Beispiel #2
0
        public static IEnumerable <AirBnbSessionRecord> GetAllAirBnbSessionsRecords(string dataFilePath)
        {
            var data = new List <AirBnbSessionRecord>();

            try
            {
                string[] rawDatalines = File.ReadAllLines(dataFilePath);

                for (int i = 1; i < rawDatalines.Length; i++)
                {
                    string[] rawEntry = rawDatalines[i].Split(delimiter);

                    try
                    {
                        var entry = new AirBnbSessionRecord
                        {
                            VisitorId          = rawEntry[0],
                            SessionId          = Guid.Parse(rawEntry[1]),
                            SessionNumber      = int.Parse(rawEntry[2]),
                            UserAgent          = rawEntry[3],
                            DeviceAppCombo     = rawEntry[4],
                            SessionDate        = DateTime.Parse(rawEntry[5]),
                            SessionStart       = DateTime.Parse(rawEntry[6]),
                            SessionEnd         = DateTime.Parse(rawEntry[7]),
                            DidSearch          = rawEntry[8].Equals("1"),
                            SentMessage        = rawEntry[9].Equals("1"),
                            SentBookingRequest = rawEntry[10].Equals("1"),
                        };

                        data.Add(entry);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Bad input:'{0}'. Skipping current line.", e.Message);
                    }
                }
            }
            catch (FileNotFoundException e)
            {
                Console.WriteLine("A problem occured while locating sessions file:'{0}'.", e.Message);
            }

            return(data);
        }
Beispiel #3
0
 // The method checks whether the record contains new data and if so, adds it to devices data.
 public void AddEntry(AirBnbSessionRecord record)
 {
     // In case record's device already present in the data
     if (DevicesToClients.ContainsKey(record.DeviceAppCombo))
     {
         // Check if we already know that record's user uses this device
         if (!DevicesToClients[record.DeviceAppCombo].Contains(record.VisitorId))
         {
             DevicesToClients[record.DeviceAppCombo].Add(record.VisitorId);
         }
     }
     // In case the record contains new type of device
     else
     {
         DevicesToClients.Add(record.DeviceAppCombo, new List <string>()
         {
             record.VisitorId
         });
     }
 }
Beispiel #4
0
 // The method checks whether the record contains new data and if so, adds it to user agents data.
 public void AddEntry(AirBnbSessionRecord record)
 {
     // In case record's user agent is already present in the data
     if (UserAgentsToClients.ContainsKey(record.UserAgent))
     {
         // Check if we already know that record's user uses this user agent
         if (!UserAgentsToClients[record.UserAgent].Contains(record.VisitorId))
         {
             UserAgentsToClients[record.UserAgent].Add(record.VisitorId);
         }
     }
     // In case the record contains new type of user agent
     else
     {
         UserAgentsToClients.Add(record.UserAgent, new List <string>()
         {
             record.VisitorId
         });
     }
 }