コード例 #1
0
        public void Save(ISessionStateContext context, IDictionary <string, object> values)
        {
            EnsureInitialized(context);
            var sessionState = new SessionStateStoreData(new SessionStateItemCollection().AddItems(values), new HttpStaticObjectsCollection(), _timeout);
            var data         = new SessionStateEncoding().Serialize(sessionState);

            _sessionStore.Save(SqlSessionId.Create(context.MetabasePath, context.SessionId), data);
        }
コード例 #2
0
 private void InsertItem(SqlSessionId sessionId, byte[] data)
 {
     SqlProcedure.Create(_connectionString, SqlSession.IsShortData(data) ?
                         "TempInsertStateItemShort" :
                         "TempInsertStateItemLong").
     Execute(x => x.In("id", sessionId.ToString()),
             x => x.In(SqlSession.IsShortData(data) ? "itemShort" : "itemLong", data),
             x => x.In("timeout", _timeout));
 }
コード例 #3
0
        public void Abandon(SqlSessionId sessionId)
        {
            var session = GetSessionData(sessionId);

            if (!session.Empty)
            {
                AbandonSession(session);
            }
        }
コード例 #4
0
 private void UpdateItem(SqlSessionId sessionId, byte[] data, int lockCookie)
 {
     SqlProcedure.Create(_connectionString, SqlSession.IsShortData(data) ?
                         "TempUpdateStateItemShortNullLong" :
                         "TempUpdateStateItemLongNullShort").
     Execute(x => x.In("id", sessionId.ToString()),
             x => x.In(SqlSession.IsShortData(data) ? "itemShort" : "itemLong", data),
             x => x.In("timeout", _timeout),
             x => x.In("lockCookie", lockCookie));
 }
コード例 #5
0
        public byte[] Load(SqlSessionId sessionId)
        {
            var session = GetSessionData(sessionId);

            if (!session.Empty)
            {
                ReleaseSessionLock(session);
            }
            return(session.Data);
        }
コード例 #6
0
        public IDictionary <string, object> Load(ISessionStateContext context)
        {
            EnsureInitialized(context);
            var data = _sessionStore.Load(SqlSessionId.Create(context.MetabasePath, context.SessionId));

            if (data == null || data.Length == 0)
            {
                return(null);
            }
            return(ValidateItems(new SessionStateEncoding().Deserialize(data).Items).ToDictionary());
        }
コード例 #7
0
        public void Save(SqlSessionId sessionId, byte[] data)
        {
            var session = GetSessionData(sessionId);

            if (session.Empty)
            {
                InsertItem(sessionId, data);
            }
            else
            {
                UpdateItem(sessionId, data, session.LockCookie);
            }
        }
コード例 #8
0
        private SqlSession GetSessionData(SqlSessionId sessionId)
        {
            var session = new SqlSession {
                Id = sessionId
            };

            SqlProcedure.Create(_connectionString, "TempGetStateItem3").
            Execute(x => session.Data = x.Read() ? (byte[])x[0] : session.Data,
                    x => x.In("id", sessionId.ToString()),
                    x => x.Out <byte[]>("itemShort", SqlDbType.VarBinary, 7000, y => session.Data = y),
                    x => x.Out <bool?>("locked", SqlDbType.Bit, y => session.Locked          = y.GetValueOrDefault()),
                    x => x.Out <int?>("lockAge", SqlDbType.Int, y => session.LockAge         = y.GetValueOrDefault()),
                    x => x.Out <int?>("lockCookie", SqlDbType.Int, y => session.LockCookie   = y.GetValueOrDefault()),
                    x => x.Out <int?>("actionFlags", SqlDbType.Int, y => session.ActionFlags = y.GetValueOrDefault()));
            return(session);
        }
コード例 #9
0
 public void Abandon(ISessionStateContext context)
 {
     EnsureInitialized(context);
     _sessionStore.Abandon(SqlSessionId.Create(context.MetabasePath, context.SessionId));
 }