Пример #1
0
 public void CloseSession(string sessionId)
 {
     if (sessions.TryRemove(sessionId, out var storageSessionId))
     {
         sessionManager.CloseSession(storageSessionId);
     }
 }
Пример #2
0
        //public static void CloseAllForUser(UserInfo target)
        //{
        //    IEnumerable<UserSession> todestroy = UserSessionManager.GetSessions(aa => aa.User.User_Id == target.User_Id);
        //    foreach (InitVent.Metadata.Session.ISession ses in todestroy)
        //    {
        //        CloseSession(ses.SessionToken.ToString());
        //    }
        //}

        /// <summary>
        /// Closes the session associated with the specified session token.
        /// </summary>
        /// <param name="sessionToken">A token identifying the session to close.</param>
        /// <remarks>
        /// Note: This method always returns cleanly, whether or not the given session was in fact closed.
        /// </remarks>
        public static void CloseSession(string sessionToken)
        {
            Guid token;
            var  goodToken = Guid.TryParse(sessionToken, out token);

            if (!goodToken)
            {
                return;
            }

            UserSessionManager.CloseSession(token);
        }
Пример #3
0
 public JsonResult Logout([FromBody] RequestBody sess)
 {
     if (sess != null && sess.SessionId != null && sess.SessionId.Length > 0)
     {
         _sessionManager.CloseSession(
             sess.SessionId,
             Request.HttpContext.Connection.RemoteIpAddress
             );
     }
     // I chose to always return success.
     // return Json(new {result = "OK"});
     return(ApiController.success());
 }
Пример #4
0
 public async Task <string> CloseSession()
 {
     try
     {
         _logger.Debug("CloseSession started");
         Session session = GetSession(Request);
         return(await _sessionManager.CloseSession(session));
     }
     catch (Exception e)
     {
         _logger.Error(e);
         throw;
     }
     finally
     {
         _logger.Debug("CloseSession finished");
     }
 }
        public void DoTest()
        {
            var session_guid = CreateSession();

            for (int inx = 0; inx < IterationCount; inx++)
            {
                var user = SessionMgr.GetSessionUser(session_guid);
                if (user == null)
                {
                    throw new Exception("Session '" + session_guid + "' not found");
                }
                var user_role = user.Role.Where(r => r.Id == UserRoles.User).FirstOrDefault();
                if (user_role == null)
                {
                    throw new Exception("User '" + user.Name + "' has not User role");
                }
                var powerusr_role = user.Role.Where(r => r.Id == UserRoles.PowerUser).FirstOrDefault();
                var admin_role    = user.Role.Where(r => r.Id == UserRoles.Admin).FirstOrDefault();
            }
            SessionMgr.CloseSession(session_guid);
        }
Пример #6
0
        public void Close()
        {
            if (transaction != null)
            {
                if (!transaction.WasCommitted && !transaction.WasRolledBack)
                {
                    try
                    {
                        transaction.Rollback();
                    }
                    catch (NHibernate.TransactionException)
                    {
                    }
                }
            }

            sessionManager.CloseSession();

            IsOpen      = false;
            transaction = null;
        }
Пример #7
0
 public void Close()
 {
     _sessionManager.CloseSession();
     Application.Current.Shutdown();
 }
Пример #8
0
 public static void CloseSession()
 {
     _sessionManager.CloseSession();
 }