Exemplo n.º 1
0
        private SessionWithKey GetNewSession(string session_key)
        {
            SessionWithKey swk = new SessionWithKey();

            swk.Key             = session_key;
            swk.session_time    = 10;
            swk.tracking_time   = 2;
            swk.additional_time = 10;
            swk.lastRequest     = DateTime.Now;
            return(swk);
        }
Exemplo n.º 2
0
 private Session SingIn(string session_key)
 {
     if (!Users.Contains(session_key) || Sessions.FirstOrDefault(p => p.Key == session_key) != null)
     {
         return(null);
     }
     else
     {
         SessionWithKey swk = GetNewSession(session_key);
         Sessions.Add(swk);
         return((Session)swk);
     }
 }
Exemplo n.º 3
0
 private Session SetData(string session_key, int tracking_time)
 {
     if (!Users.Contains(session_key) || Sessions.FirstOrDefault(p => p.Key == session_key) == null)
     {
         return(null);
     }
     else
     {
         SessionWithKey swk = Sessions.FirstOrDefault(p => p.Key == session_key);
         swk.session_time -= (DateTime.Now.Second - swk.lastRequest.Second) + (DateTime.Now.Minute - swk.lastRequest.Minute) * 60 + (DateTime.Now.Hour - swk.lastRequest.Hour) * 3600;
         if (swk.session_time < 0)
         {
             swk.session_time = 0;
             Sessions.Remove(swk);
         }
         swk.lastRequest = DateTime.Now;
         return((Session)swk);
     }
 }