예제 #1
0
 /// <summary>
 /// 提交事务
 /// </summary>
 public void Commit()
 {
     if (_Tran != null)
     {
         var Sql = new ODAScript()
         {
             ScriptType = SQLType.Commit,
         };
         Sql.SqlScript.Append("Commit Tran:" + _Tran.TransactionId);
         FireODASqlEvent(new ExecuteEventArgs()
         {
             SqlParams = Sql,
         });
         _Tran.Commit();
         _Tran = null;
     }
 }
예제 #2
0
 /// <summary>
 /// 回滚事务
 /// </summary>
 public void RollBack()
 {
     if (_Tran != null)
     {
         _Tran.RollBack();
         var Sql = new ODAScript()
         {
             ScriptType = SQLType.Rollback,
         };
         Sql.SqlScript.Append("Rollback Tran:" + _Tran.TransactionId);
         FireODASqlEvent(new ExecuteEventArgs()
         {
             SqlParams = Sql,
         });
         _Tran = null;
     }
 }
예제 #3
0
        /// <summary>
        /// 开启事务
        /// </summary>
        /// <param name="TimeOut">事务超时时长,小于或等于0时事务不会超时,单位:秒</param>
        /// <returns></returns>
        public virtual void BeginTransaction(int TimeOut)
        {
            if (_Tran != null)
            {
                throw new ODAException(30021, "Transaction had begun!");
            }
            _Tran = new ODATransaction(TimeOut);
            _Tran.TransactionTimeOut = this.RollBack;
            var Sql = new ODAScript()
            {
                ScriptType = SQLType.BeginTransation,
            };

            Sql.SqlScript.Append("Begin Tran:" + _Tran.TransactionId);
            FireODASqlEvent(new ExecuteEventArgs()
            {
                SqlParams = Sql,
            });
        }