Beispiel #1
0
        protected void SetSessionData(DragonSession sessionRecord)
        {
            sessionRecord.Hash = m_session.GetHashCode();

            // each request "touches" expires
            sessionRecord.Expires = DateTime.UtcNow.AddMinutes(SlidingWindowMinutes);

            SetLocationIfRequired(sessionRecord);
        }
Beispiel #2
0
        protected void SetSessionData(DragonSession sessionRecord)
        {
            sessionRecord.Hash = m_session.GetHashCode();

            // each request "touches" expires
            sessionRecord.Expires = DateTime.UtcNow.AddMinutes(SlidingWindowMinutes);

            SetLocationIfRequired(sessionRecord);
        }
 protected override void SaveSessionRecord(DragonSession sessionRecord)
 {
     while (s_sessions.ContainsKey(sessionRecord.SessionID))
     {
         DragonSession oldSessionRecord;
         s_sessions.TryRemove(sessionRecord.SessionID, out oldSessionRecord);
     }
     while (!s_sessions.ContainsKey(sessionRecord.SessionID))
     {
         s_sessions.TryAdd(sessionRecord.SessionID, sessionRecord);
     }
 }
Beispiel #4
0
 protected override void SaveSessionRecord(DragonSession sessionRecord)
 {
     while (s_sessions.ContainsKey(sessionRecord.SessionID))
     {
         DragonSession oldSessionRecord;
         s_sessions.TryRemove(sessionRecord.SessionID, out oldSessionRecord);
     }
     while (!s_sessions.ContainsKey(sessionRecord.SessionID))
     {
         s_sessions.TryAdd(sessionRecord.SessionID, sessionRecord);
     }
 }
        protected virtual bool TryGetSessionRecord(Guid sessionID, out DragonSession sessionRecord)
        {
            sessionRecord = new DragonSession() { SessionID = m_session.ID };

            while (s_sessions.ContainsKey(sessionID))
            {
                if (s_sessions.TryGetValue(sessionID, out sessionRecord))
                {
                    return true;
                }
            }

            return false;
        }
Beispiel #6
0
 protected void SetLocationIfRequired(DragonSession sessionRecord)
 {
     // perform ip -> location lookup if configured
     if (!sessionRecord.Hash.Equals(m_session.GetHashCode()))
     {
         if (m_configuration.IsTrue(CONFIG_DOREVERSEIPLOOKUP) && m_reverseLookupService != null)
         {
             // if forwarded for avaiable try that first, otherwise just ip
             sessionRecord.Location = !string.IsNullOrWhiteSpace(m_session.ForwardedForAddress)
                                          ? (m_reverseLookupService.GetLocationString(m_session.ForwardedForAddress) ??
                                             m_reverseLookupService.GetLocationString(m_session.IPAddress))
                                          : (m_reverseLookupService.GetLocationString(m_session.IPAddress));
         }
     }
 }
Beispiel #7
0
 protected void SetLocationIfRequired(DragonSession sessionRecord)
 {
     // perform ip -> location lookup if configured
     if (!sessionRecord.Hash.Equals(m_session.GetHashCode()))
     {
         if (m_configuration.IsTrue(CONFIG_DOREVERSEIPLOOKUP) && m_reverseLookupService != null)
         {
             // if forwarded for avaiable try that first, otherwise just ip
             sessionRecord.Location = !string.IsNullOrWhiteSpace(m_session.ForwardedForAddress)
                                          ? (m_reverseLookupService.GetLocationString(m_session.ForwardedForAddress) ??
                                             m_reverseLookupService.GetLocationString(m_session.IPAddress))
                                          : (m_reverseLookupService.GetLocationString(m_session.IPAddress));
         }
     }
 }
Beispiel #8
0
        protected virtual bool TryGetSessionRecord(Guid sessionID, out DragonSession sessionRecord)
        {
            sessionRecord = new DragonSession()
            {
                SessionID = m_session.ID
            };

            while (s_sessions.ContainsKey(sessionID))
            {
                if (s_sessions.TryGetValue(sessionID, out sessionRecord))
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #9
0
        protected override DragonSession GetSessionRecord()
        {
            DragonSession sessionRecord = null;
            if (true /* disabling in memory for a test todo */ || !base.TryGetSessionRecord(m_session.ID, out sessionRecord))
            {
                sessionRecord = GetSessionRecord(m_session.ID);
                if (sessionRecord == null)
                {
                    sessionRecord = new DragonSession()
                        {
                            SessionID = m_session.ID
                        };

                    SaveSessionRecord(sessionRecord);
                }
            }
            return sessionRecord;
        }
Beispiel #10
0
        protected override DragonSession GetSessionRecord()
        {
            DragonSession sessionRecord = null;

            if (true /* disabling in memory for a test todo */ || !base.TryGetSessionRecord(m_session.ID, out sessionRecord))
            {
                sessionRecord = GetSessionRecord(m_session.ID);
                if (sessionRecord == null)
                {
                    sessionRecord = new DragonSession()
                    {
                        SessionID = m_session.ID
                    };

                    SaveSessionRecord(sessionRecord);
                }
            }
            return(sessionRecord);
        }
Beispiel #11
0
        protected override DragonSession GetSessionRecord()
        {
            DragonSession sessionRecord = null;

            while (sessionRecord == null)
            {
                // try to get record from memory
                sessionRecord = null;

                TryGetSessionRecord(m_session.ID, out sessionRecord);

                // if expired remove record
                if (sessionRecord.Expires <= DateTime.UtcNow)
                {
                    RemoveSessionRecord(m_session.ID);
                }
            }

            return(sessionRecord);
        }
Beispiel #12
0
        protected override void SaveSessionRecord(DragonSession sessionRecord)
        {
            using (var conn = ConnectionHelper.Open())
            {
                SetSessionData(sessionRecord);
                var p = new
                {
                    Hash      = sessionRecord.Hash,
                    SessionID = sessionRecord.SessionID,
                    Expires   = sessionRecord.Expires,
                    Location  = sessionRecord.Location,
                    UserID    = sessionRecord.UserID
                };
                if (conn.ExecuteFor <DragonSession>(SQL.SqlSessionStore_Update, p) == 0)
                {
                    conn.ExecuteFor <DragonSession>(SQL.SqlSessionStore_Insert, p);
                }
            }

            base.SaveSessionRecord(sessionRecord);
        }
Beispiel #13
0
        protected override void SaveSessionRecord(DragonSession sessionRecord)
        {
            using (var conn = ConnectionHelper.Open())
            {

                SetSessionData(sessionRecord);
                var p = new
                    {
                        Hash = sessionRecord.Hash,
                        SessionID = sessionRecord.SessionID,
                        Expires = sessionRecord.Expires,
                        Location = sessionRecord.Location,
                        UserID = sessionRecord.UserID
                    };
                if (conn.ExecuteFor<DragonSession>(SQL.SqlSessionStore_Update, p) == 0)
                {
                    conn.ExecuteFor<DragonSession>(SQL.SqlSessionStore_Insert, p);
                }
            }

            base.SaveSessionRecord(sessionRecord);
        }
Beispiel #14
0
 protected abstract void SaveSessionRecord(DragonSession sessionRecord);
Beispiel #15
0
 protected abstract void SaveSessionRecord(DragonSession sessionRecord);