Example #1
0
        public void OpenSession()
        {
            ISession session = GetNewSession();
            ISessionStorageContainer sessionStorageContainer = SessionStorageFactory.GetStorageContainer();

            sessionStorageContainer.Store(session);
        }
Example #2
0
        public ISession GetCurrentSession()
        {
            ISessionStorageContainer sessionStorageContainer = SessionStorageFactory.GetStorageContainer();
            ISession currentSession = sessionStorageContainer.GetCurrentSession();

            if (currentSession == null)
            {
                currentSession = GetNewSession();
                sessionStorageContainer.Store(currentSession);
            }
            return(currentSession);
        }
        public void CloseSession()
        {
            ISession session = GetCurrentSession();

            if (session != null && session.IsOpen)
            {
                //session.Flush();
                session.Close();
            }
            ISessionStorageContainer sessionStorageContainer = SessionStorageFactory.GetStorageContainer();

            sessionStorageContainer.Store(null);
        }
        public static ISession GetCurrentSession(string dbName)
        {
            ISessionStorageContainer sessionStorageContainer = SessionStorageFactory.GetStorageContainer();

            ISession currentSession = sessionStorageContainer.GetCurrentSession(dbName);

            if (currentSession == null)
            {
                currentSession = GetNewSession(dbName);
                sessionStorageContainer.Store(dbName, currentSession);
            }

            return(currentSession);
        }
        public static ISession GetCurrentSession(Web.IHttpContextAccessor context)
        {
            ISessionStorageContainer sessionStorageContainer =
                SessionStorageFactory.GetStorageContainer(context);

            ISession currentSession = sessionStorageContainer.GetCurrentSession();

            if (currentSession == null)
            {
                currentSession = GetNewSession();
                sessionStorageContainer.Store(currentSession);
            }

            return(currentSession);
        }
        public ISession GetCurrentSession()
        {
            var currentSession = _sessionStorageContainer.GetCurrentSession();

            if (currentSession != null)
            {
                return(currentSession);
            }

            currentSession = GetNewSession();

            _sessionStorageContainer.Store(currentSession);

            return(currentSession);
        }
Example #7
0
        /// <summary>
        /// 获取当前的会话
        /// </summary>
        /// <returns></returns>
        public static ISession GetCurrentSession()
        {
            //获取贮藏容器
            ISessionStorageContainer _sessionStorageContainer = SessionStorageFactory.GetStorageContainer();

            //每个实现的贮藏容器获得当前的
            ISession currentSession = _sessionStorageContainer.GetCurrentSession();

            if (currentSession == null)
            {
                //获取当前贮藏中的会话(需打开OpenSession)
                currentSession = GetNewSession();
                //贮藏容器执行存储当前会话的操作
                _sessionStorageContainer.Store(currentSession);
            }

            return(currentSession);
        }