public bool SaveSession(SessionData sessionData) { bool status = false; if (sessionData != null) { var session = (SessionData) HttpRuntime.Cache[sessionData.SessionId]; if (session != null) { try { HttpRuntime.Cache.Insert(sessionData.SessionId, sessionData, null, DateTime.Now.AddMinutes(15), Cache.NoSlidingExpiration, CacheItemPriority.Normal, null); status = true; } catch (Exception ex) { Logger.LogException(ex, Source, "SaveSession", Severity.Critical); status = false; } } } return status; }
public bool UpdateSession(string sessionId, string authenticationId, SessionData sessionData, out string errorMessage) { errorMessage = string.Empty; var session = (SessionData) HttpRuntime.Cache[sessionId]; bool status = false; if (session == null) errorMessage = "No session found"; else if (!string.Equals(session.AuthenticationId, authenticationId, StringComparison.OrdinalIgnoreCase)) errorMessage = "Authorization Failed."; else { sessionData.AuthenticationId = authenticationId; sessionData.SessionId = sessionId; try { HttpRuntime.Cache.Insert(sessionId, sessionData, null, DateTime.Now.AddMinutes(15), Cache.NoSlidingExpiration, CacheItemPriority.Normal, null); status = true; } catch (Exception exception) { errorMessage = exception.Message; } } return status; }
public string CreateSession(SessionData session) { ISessionDataProvider sessionDataProvider = SessionDataProviderFactory.CreateSessionDataProvider(); if (sessionDataProvider != null) { return sessionDataProvider.CreateSession(session); } return null; }
public string AddRequestToSession(SessionData session) { ISessionDataProvider sessionDataProvider = SessionDataProviderFactory.CreateSessionDataProvider(); if (sessionDataProvider != null) { if(sessionDataProvider.SaveSession(session)) return session.SessionId; } return null; }
public void CreateSessionTest() { if (string.IsNullOrEmpty(sessionId)) { var target = new MockSessionProvider(); var session = new SessionData(); string actual; actual = target.CreateSession(session); Assert.IsNotNull(actual); sessionId = actual; } }
public string CreateSession(SessionData session) { string key = Guid.NewGuid().ToString(); if (session != null) session.SessionId = key; try { HttpRuntime.Cache.Add(key, session, null, DateTime.Now.AddMinutes(15), Cache.NoSlidingExpiration, CacheItemPriority.Normal, null); } catch (Exception exception) { Logger.LogException(exception, Source, "CreateSession", Severity.Normal); } return key; }
public string CreateSession(SessionData session) { string key = session == null || string.IsNullOrEmpty(session.SessionId) ? Guid.NewGuid().ToString() : session.SessionId; try { var existingSession = (SessionData)HttpRuntime.Cache[key]; if (existingSession == null) { session.SessionId = key; HttpRuntime.Cache.Insert(key, session, null, DateTime.Now.AddMinutes(15), Cache.NoSlidingExpiration, CacheItemPriority.Normal, null); } } catch (Exception ex) { Logger.LogException(ex, Source, "CreateSession", Severity.Critical); } return key; }
public void UpdateSessionTest() { try { AssignSessionTest(); } catch { } var target = new MockSessionProvider(); var sessionData = new SessionData(); string errorMessage = string.Empty; string errorMessageExpected = string.Empty; bool expected = true; bool actual; actual = target.UpdateSession(sessionId, authenticationId, sessionData, out errorMessage); Assert.AreEqual(errorMessageExpected, errorMessage); Assert.AreEqual(expected, actual); }
public void SaveSessionTest() { var target = new SessionDataProvider(); var sessionData = new SessionData {SessionId = sessionId}; bool expected = true; bool actual; actual = target.SaveSession(sessionData); Assert.AreEqual(expected, actual); }
public bool UpdateSession(string sessionId, string authenticationId, SessionData sessionData, out string errorMessage) { ISessionDataProvider sessionDataProvider = SessionDataProviderFactory.CreateSessionDataProvider(); errorMessage = string.Empty; if (sessionDataProvider != null && _authenticationProvider != null && _authenticationProvider.Validate(authenticationId)) { SessionData storedSession = sessionDataProvider.GetSession(sessionId); if (storedSession != null) { if (!string.IsNullOrEmpty(storedSession.AuthenticationId) && !string.Equals(storedSession.AuthenticationId, authenticationId, StringComparison.OrdinalIgnoreCase)) { errorMessage = "Session already assigned."; return false; } sessionData.AuthenticationId = authenticationId; sessionData.SessionId = sessionId; return sessionDataProvider.SaveSession(sessionData); } errorMessage = "Session not found."; } return false; }
public string AddRequestToSession(SessionData session) { throw new NotImplementedException(); }