private object InternalExecute()
        {
            DataExecutionContext <TLogs> context = new DataExecutionContext <TLogs>(this.OperationType, this);

            ExecutionWrapper("PrepareData", () => PrepareData(context));
            ExecutionWrapper("PrepareOperationLog", () => PrepareOperationLog(context));
            ExecutionWrapper("PersistOperationLogInContext", () => PersistOperationLogInContext(context));

            object result = null;

            if (this.AutoStartTransaction)
            {
                using (TransactionScope scope = TransactionScopeFactory.Create())
                {
                    ExecutionWrapper("DoOperation", () => result = DoOperation(context));
                    ExecutionWrapper("PersistOperationLog", () => PersistOperationLog(context));
                    ExecutionWrapper("BeforeTransactionComplete", () => BeforeTransactionComplete(context));

                    scope.Complete();
                }

                ExecutionWrapper("AfterTransactionCompleted", () => AfterTransactionCompleted(context));
            }
            else
            {
                ExecutionWrapper("DoOperation", () => result = DoOperation(context));
                ExecutionWrapper("PersistOperationLog", () => PersistOperationLog(context));
                ExecutionWrapper("BeforeTransactionComplete", () => BeforeTransactionComplete(context));
                ExecutionWrapper("AfterTransactionCompleted", () => AfterTransactionCompleted(context));
            }

            return(result);
        }
 /// <summary>
 /// 操作完成以后,事务提交之前
 /// </summary>
 /// <param name="context"></param>
 protected virtual void BeforeTransactionComplete(DataExecutionContext <TLogs> context)
 {
 }
 /// <summary>
 /// 准备数据,包括校验数据。这个操作在事务之外
 /// </summary>
 /// <param name="context"></param>
 protected virtual void PrepareData(DataExecutionContext <TLogs> context)
 {
 }
 /// <summary>
 /// 执行在事务内具体的数据操作,需要重载
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 protected abstract object DoOperation(DataExecutionContext <TLogs> context);
 /// <summary>
 /// 需要重载,在上下文中保存日志
 /// </summary>
 /// <param name="context"></param>
 protected virtual void PersistOperationLogInContext(DataExecutionContext <TLogs> context)
 {
 }
 /// <summary>
 /// 准备操作日志
 /// </summary>
 /// <param name="context"></param>
 protected virtual void PrepareOperationLog(DataExecutionContext <TLogs> context)
 {
 }
 /// <summary>
 /// 事务完成以后
 /// </summary>
 /// <param name="context"></param>
 protected virtual void AfterTransactionCompleted(DataExecutionContext <TLogs> context)
 {
 }