Beispiel #1
0
 public void InsertSession(string session)
 {
     lock (Content)
     {
         var sessionStatus = new SessionStatus {
             Session = session, BornTime = DateTime.Now
         };
         if (Content.Contains(sessionStatus))
         {
             SessionStatus find = Content.Find(p => string.Equals(p.Session, session));
             Content.Remove(find);
         }
         if (Content.Count == 100)
         {
             DeleteSession(1800);
         }
         if (Content.Count == 100)
         {
             Comparison <SessionStatus> p =
                 (span, timeSpan) =>
                 (int)span.BornTime.Subtract(timeSpan.BornTime).TotalSeconds;
             Content.Sort(p);
             Content.RemoveAt(0);
         }
         Content.Add(sessionStatus);
     }
 }
Beispiel #2
0
 public void DeleteSession(string session)
 {
     lock (Content)
     {
         SessionStatus find = Content.Find(p => p.Session.Equals(session));
         if (find != null)
         {
             Content.Remove(find);
         }
     }
 }
 public void InsertSession(string session)
 {
     lock (Content)
     {
         var sessionStatus = new SessionStatus { Session = session, BornTime = DateTime.Now };
         if (Content.Contains(sessionStatus))
         {
             SessionStatus find = Content.Find(p => string.Equals(p.Session, session));
             Content.Remove(find);
         }
         if (Content.Count == 100)
         {
             DeleteSession(1800);
         }
         if (Content.Count == 100)
         {
             Comparison<SessionStatus> p =
                 (span, timeSpan) =>
                 (int)span.BornTime.Subtract(timeSpan.BornTime).TotalSeconds;
             Content.Sort(p);
             Content.RemoveAt(0);
         }
         Content.Add(sessionStatus);
     }
 }