internal virtual bool DMSUpdate(DMSTransactionScopeEntity entity) #endif { Queue <TransactionScopeEntity> scopeEntityList = entity.GetEditTS(); if (scopeEntityList != null && scopeEntityList.Count > 0) { DMSDbType dbType = entity.InternalDMSDbType; foreach (TransactionScopeEntity item in scopeEntityList) { System.Diagnostics.Debug.WriteLine(item.ResultSql); System.Console.WriteLine(item.ResultSql); if (item.DataParameter != null) { string strParam = string.Empty; foreach (var p in item.DataParameter.parameters) { strParam += string.Format("Name:{0} DbType:{1} Value:{2}{3}", p.Value.Name, p.Value.DbType, p.Value.Value, System.Environment.NewLine); } System.Diagnostics.Debug.WriteLine(strParam); System.Console.WriteLine(strParam); } } } return(true); }
/// <summary> /// 执行事务操作 /// </summary> /// <param name="entity">DMSTransactionEntity 实现实体</param> /// <param name="resultValueList">执行查询时返回执行的行数</param> /// <param name="errMsg">返回错误信息</param> /// <returns></returns> public virtual bool Update(DMSTransactionScopeEntity entity, ref List <int> resultValueList, ref string errMsg) { resultValueList = new List <int>(); Queue <TransactionScopeEntity> scopeEntityList = entity.GetEditTS(); bool flag = true; if (scopeEntityList != null && scopeEntityList.Count > 0) { //string providerName = string.Empty; //IDMSDbProfiler dbProfiler = GetProfiler(out providerName); #region scopeEntityList DMSDbType dbType = entity.InternalDMSDbType; using (var conn = entity.InternalDbProvider.GetOpenConnection()) { IDbTransaction transaction = conn.BeginTransaction(System.Data.IsolationLevel.ReadCommitted); int resultValue = 0; string ResultSql = string.Empty; try { foreach (TransactionScopeEntity item in scopeEntityList) { #region scopeEntityList resultValue = 0; ResultSql = item.ResultSql; if (item.ExcuteType == DMSExcuteType.INSERTIDENTITY) { resultValue = TryParse.StrToInt(DMSDbAccess.ExecuteScalar(conn, item.EntityName, item.ResultSql, item.DataParameter, transaction, 30)); } else { resultValue = DMSDbAccess.Execute(conn, item.EntityName, item.ResultSql, item.DataParameter, transaction, 60); } #endregion #region ResultFlag if (item.ResultFlag && resultValue == 0) { errMsg = item.ResultFlag + "不能满足条件不能执行"; Log.Debug(ReflectionUtils.GetMethodBaseInfo(System.Reflection.MethodBase.GetCurrentMethod()), errMsg + "当前事务:" + item.ResultSql, null); if (item.DataParameter != null) { string strParam = string.Empty; foreach (var p in item.DataParameter.parameters) { strParam += string.Format("Name:{0} DbType:{1} Value:{2}{3}", p.Value.Name, p.Value.DbType, p.Value.Value, System.Environment.NewLine); } Log.Debug(ReflectionUtils.GetMethodBaseInfo(System.Reflection.MethodBase.GetCurrentMethod()), strParam, null); } flag = false; resultValueList.Add(resultValue); break; } #endregion resultValueList.Add(resultValue); } if (flag) { transaction.Commit(); } else { transaction.Rollback(); } } catch (Exception ex) { Log.Debug(ReflectionUtils.GetMethodBaseInfo(System.Reflection.MethodBase.GetCurrentMethod()), errMsg + "当前事务:" + ResultSql, ex); resultValue = 0; transaction.Rollback(); throw ex; } finally { entity.Clear(); conn.Close(); } } #endregion } return(flag); }
/// <summary> /// 执行事务操作 /// </summary> /// <param name="entity">事务实体</param> /// <param name="errMsg">错误信息</param> /// <returns></returns> public bool Update(DMSTransactionScopeEntity entity, ref string errMsg) { List <int> resultValueList = new List <int>(); return(this.Update(entity, ref resultValueList, ref errMsg)); }
/// <summary> /// 执行事务操作 /// </summary> /// <param name="entity">DMSTransactionEntity 实现实体</param> /// <returns></returns> #if DEBUG public virtual bool DMSUpdate(DMSTransactionScopeEntity entity)
/// <summary> /// 执行事务操作 /// </summary> /// <param name="entity">事务实体</param> /// <returns></returns> public bool Update(DMSTransactionScopeEntity entity) { string errMsg = string.Empty; return(this.Update(entity, ref errMsg)); }