Exemplo n.º 1
0
        protected void SetSessionData(DragonSession sessionRecord)
        {
            sessionRecord.Hash = m_session.GetHashCode();

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

            SetLocationIfRequired(sessionRecord);
        }
Exemplo n.º 2
0
        protected void SetSessionData(DragonSession sessionRecord)
        {
            sessionRecord.Hash = m_session.GetHashCode();

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

            SetLocationIfRequired(sessionRecord);
        }
Exemplo n.º 3
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);
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 5
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;
        }
Exemplo n.º 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));
         }
     }
 }
Exemplo n.º 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));
         }
     }
 }
Exemplo n.º 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);
        }
Exemplo n.º 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;
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 14
0
 protected abstract void SaveSessionRecord(DragonSession sessionRecord);
Exemplo n.º 15
0
 protected abstract void SaveSessionRecord(DragonSession sessionRecord);