Beispiel #1
0
 /// <summary>
 /// Opens a session within a transaction at the beginning of the HTTP request.  Note that 
 /// it ONLY begins transactions for those designated as being transactional.
 /// </summary>
 /// <param name="sender"></param>
 public void BeginTransaction()
 {
     OpenSessionInViewSection openSessionInViewSection = GetOpenSessionInViewSection();
     AuditInterceptor audit = new AuditInterceptor(_currentUser);
     foreach (SessionFactoryElement sessionFactorySettings in openSessionInViewSection.SessionFactories)
     {
         if (sessionFactorySettings.IsTransactional)
         {
             NHibernateSessionManager.Instance.CloseSessionOn(sessionFactorySettings.FactoryConfigPath);
             NHibernateSessionManager.Instance.RegisterInterceptorOn(sessionFactorySettings.FactoryConfigPath, audit);
             NHibernateSessionManager.Instance.BeginTransactionOn(sessionFactorySettings.FactoryConfigPath);
         }
     }
 }
Beispiel #2
0
        /// <summary>
        /// Opens a session within a transaction at the beginning of the HTTP request.  Note that 
        /// it ONLY begins transactions for those designated as being transactional.
        /// </summary>
        /// <param name="sender"></param>
        public void BeginTransaction(string utenteCorrente, IsolationLevel isolationLevel, bool? flushOnCommit)
        {
            var openSessionInViewSection = GetOpenSessionInViewSection();
            _audit = new AuditInterceptor();
            _audit.SetUtenteCorrente(utenteCorrente);

            var flushMode = FlushMode.Unspecified;
            if (flushOnCommit.GetValueOrDefault())
                flushMode = FlushMode.Commit;

            foreach (SessionFactoryElement sessionFactorySettings in openSessionInViewSection.SessionFactories)
            {
                if (sessionFactorySettings.IsTransactional)
                {
                    NHibernateSessionManager.Instance.CloseSessionOn(sessionFactorySettings.FactoryConfigPath);
                    NHibernateSessionManager.Instance.RegisterInterceptorOn(sessionFactorySettings.FactoryConfigPath, flushMode, _audit);
                    NHibernateSessionManager.Instance.BeginTransactionOn(sessionFactorySettings.FactoryConfigPath, isolationLevel, flushMode);
                }
            }
        }