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); }
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)); }
public void Abandon(SqlSessionId sessionId) { var session = GetSessionData(sessionId); if (!session.Empty) { AbandonSession(session); } }
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)); }
public byte[] Load(SqlSessionId sessionId) { var session = GetSessionData(sessionId); if (!session.Empty) { ReleaseSessionLock(session); } return(session.Data); }
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()); }
public void Save(SqlSessionId sessionId, byte[] data) { var session = GetSessionData(sessionId); if (session.Empty) { InsertItem(sessionId, data); } else { UpdateItem(sessionId, data, session.LockCookie); } }
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); }
public void Abandon(ISessionStateContext context) { EnsureInitialized(context); _sessionStore.Abandon(SqlSessionId.Create(context.MetabasePath, context.SessionId)); }