Пример #1
0
 /// <summary>
 /// Sands the box db test.
 /// </summary>
 /// <param name="action">The action.</param>
 /// <param name="ignoreEntityID">if set to <c>true</c> [ignore entity ID].</param>
 /// <param name="stringLength">Length of the string.</param>
 public static void SandBoxDbTest(Action <Fixture> action, bool ignoreEntityID = true, int stringLength = 30)
 {
     using (TransactionScope scope = TranScopeHelper.GetTranScope())
     {
         var fixture = AutoFixtureUtil.GetFixture(ignoreEntityID, stringLength);
         action(fixture);
     }
 }
Пример #2
0
 /// <summary>
 /// Sandbox db test.
 /// </summary>
 /// <param name="action">The test action.</param>
 /// <param name="ignoreEntityID">if set to <c>true</c> [ignore entity ID].</param>
 /// <param name="stringLength">Length of the fake string.</param>
 public static void SandBoxDbTest(Action <Fixture, ISession> action, bool ignoreEntityID = true, int stringLength = 30)
 {
     using (TransactionScope scope = TranScopeHelper.GetTranScope())
         using (ISession session = NHibernateSessionFactory.Session)
         {
             var fixture = AutoFixtureUtil.GetFixture(ignoreEntityID, stringLength);
             action(fixture, session);
         }
 }
Пример #3
0
        /// <summary>
        /// Executes the specified action.
        /// </summary>
        /// <param name="action">The action.</param>
        public static void Execute(Action <DateTime> action,
                                   TransactionScopeOption tsOption = TransactionScopeOption.Required,
                                   int timeoutSec          = 3600,
                                   IsolationLevel isoLevel = IsolationLevel.ReadCommitted)
        {
            using (TransactionScope scope = TranScopeHelper.GetTranScope(tsOption, timeoutSec, isoLevel))
            {
                DateTime now = GetNow();
                action(now);

                scope.Complete();
            }
        }
Пример #4
0
        /// <summary>
        /// Executes the specified action.
        /// </summary>
        /// <param name="action">The action.</param>
        public static void Execute(Action <ISession, DateTime> action,
                                   bool isOpenNewSession           = false,
                                   TransactionScopeOption tsOption = TransactionScopeOption.Required,
                                   int timeoutSec          = 3600,
                                   IsolationLevel isoLevel = IsolationLevel.ReadCommitted)
        {
            using (TransactionScope scope = TranScopeHelper.GetTranScope(tsOption, timeoutSec, isoLevel))
                using (ISession session = GetSession(isOpenNewSession))
                {
                    DateTime now = GetNow();
                    action(session, now);

                    scope.Complete();
                }
        }
Пример #5
0
        /// <summary>
        /// Executes the boolean.
        /// </summary>
        /// <param name="f">The f.</param>
        public static void ExecuteBoolean(Func <DateTime, bool> f,
                                          TransactionScopeOption tsOption = TransactionScopeOption.Required,
                                          int timeoutSec          = 3600,
                                          IsolationLevel isoLevel = IsolationLevel.ReadCommitted)
        {
            using (TransactionScope scope = TranScopeHelper.GetTranScope(tsOption, timeoutSec, isoLevel))
            {
                DateTime now  = GetNow();
                bool     flag = f(now);

                if (flag)
                {
                    scope.Complete();
                }
            }
        }