/// <summary> /// 启动事务 /// </summary> public void Start() { Parent = Current; Current = this; StartTime = DateTime.Now; Status = Status.Default <TransStatus_Running>(); TransactionPublic.ProcessTransactionEvent(this); }
/// <summary> /// 提交 /// </summary> public void Commit() { Status = new TransStatus_Committed() { SpendTime = DateTime.Now - StartTime }; TransactionPublic.ProcessTransactionEvent(this); End(); }
/// <summary> /// 回滚 /// </summary> public void Rollback() { Status = Status.Default <TransStatus_Rollbacked>(); TransactionPublic.ProcessTransactionEvent(this); }
/// <summary> /// 事务进入回滚异常状态 /// </summary> /// <param name="exp">异常</param> public void RollbackException(Exception exp) { Status = new TransStatus_RollbackExcepted(exp); TransactionPublic.ProcessTransactionEvent(this); }