Example #1
0
 public TripSession CreateSession(string userName, int truckId)
 {
     try
     {
         TripSession tripSession = new TripSession
                                       {
                                           Id = Guid.NewGuid(),
                                           Expiration = DateTime.Now + _maxAge,
                                           TruckId = truckId,
                                           UserName = userName
                                       };
         _sessions[tripSession.Id] = tripSession;
         SaveSessionFile();
         _logger.Debug("Created session for: username="******",truckid=" + truckId);
         return tripSession;
     }
     catch (Exception ex)
     {
         _logger.Error("Failed to create session. ", ex);
     }
     return null;
 }
Example #2
0
 public static TripSession ParseLine(string line)
 {
     string[] parts = line.Split('\t');
     if(parts.Length!=4)
     {
         return null;
     }
     try
     {
         TripSession tripSession = new TripSession
                                       {
                                           Id = new Guid(parts[0]),
                                           Expiration = DateTime.Parse(parts[1]),
                                           UserName = parts[2],
                                           TruckId = int.Parse(parts[3])
                                       };
         return tripSession;
     }
     catch (Exception)
     {
         return null;
     }
 }