/// <summary> /// 事务处理方法 /// </summary> /// <param name="current">ICE连接</param> /// <param name="work">事务委托(内部请使用DoWork相关方法进行存储过程调用)</param> /// <param name="errmsgInDb">错误信息标识</param> /// <param name="strError">返回错误信息</param> /// <returns>事务处理信息(成功或者失败)</returns> public bool DoExecuteWork(DoWork work) { dbWork = DataAccessor.CreateDatabase(); #region 保存模板事务 using (var connection = dbWork.CreateConnection()) { connection.Open(); trans = connection.BeginTransaction(); try { work(); trans.Commit(); } catch (Exception ex) { trans.Rollback(); this.Errmsg = ex.Message; } finally { trans.Dispose(); if (connection.State != ConnectionState.Closed) { connection.Close(); } dbWork = null; this.ThrowException(""); } } #endregion return(string.IsNullOrEmpty(this.Errmsg)); }
/// <summary> /// 执行返回DataTable的有游标的数据库操作 /// </summary> /// <param name="strProcName">存储过程</param> /// <param name="errmsgInDb">日志基本信息</param> /// <param name="strError">返回错误信息</param> /// <param name="strBMSAH">部门受案号(如果有)</param> /// <returns>DataTable数据</returns> public DataTable DoExecuteDataTable(string strProcName) { Database db = DataAccessor.CreateDatabase(); DataTable rtnDt = new DataTable(); try { AddLogDebug(strProcName); DataSet ds = db.ExecuteDataSet <KeyValueItem>(strProcName, this.KeyValue); if (ds != null && ds.Tables.Count > 0) { rtnDt = ds.Tables[0]; } } catch (Exception ex) { AddLogError(strProcName, ex); throw new Exception("数据库处理出错:" + ex.Message); } finally { this.ThrowException(strProcName); } return(rtnDt); }
/// <summary> /// 执行返回实体类的数据库操作 /// </summary> /// <typeparam name="T">返回实体类型</typeparam> /// <param name="current">ICE连接</param> /// <param name="strProcName">存储过程名</param> /// <param name="errmsgInDb">错误信息标识</param> /// <param name="strError">返回错误信息</param> /// <param name="strBMSAH">部门受案号(如果有)</param> /// <returns></returns> public List <T> DoExecuteSprocAccessor <T>(string strProcName) where T : class, new() { Database db = DataAccessor.CreateDatabase(); List <T> rtnLst = new List <T>(); try { AddLogDebug(strProcName); IEnumerable <T> Info = db.ExecuteSprocAccessor <T, KeyValueItem>(strProcName, this.KeyValue); if (string.IsNullOrEmpty(this.Errmsg) && Info != null) { rtnLst = Info.ToList <T>(); } } catch (Exception ex) { AddLogError(strProcName, ex); throw new Exception("数据库处理出错:" + ex.Message); } finally { this.ThrowException(strProcName); } return(rtnLst); }
/// <summary> /// 执行无返回值的数据库操作 /// </summary> /// <param name="current">ICE连接</param> /// <param name="strProcName">存储过程</param> /// <param name="errmsgInDb">错误信息标识</param> /// <param name="strBMSAH">部门受案号(如果有)</param> /// <returns>操作结果</returns> public bool DoExecuteNonQuery(string strProcName) { Database db = DataAccessor.CreateDatabase(); try { AddLogDebug(strProcName); db.ExecuteNonQuery <KeyValueItem>(strProcName, this.KeyValue); } catch (Exception ex) { AddLogError(strProcName, ex); throw new Exception("数据库处理出错:" + ex.Message); } finally { this.ThrowException(strProcName); } return(string.IsNullOrEmpty(this.Errmsg)); }
/// <summary> /// 执行返回DataSet的有游标的数据库操作 /// </summary> /// <param name="strProcName">存储过程</param> /// <returns>DataSet数据</returns> public DataSet DoExecuteDataSet(string strProcName) { Database db = DataAccessor.CreateDatabase(); DataSet rtnDs = new DataSet(); try { AddLogDebug(strProcName); rtnDs = db.ExecuteDataSet <KeyValueItem>(strProcName, this.KeyValue); } catch (Exception ex) { AddLogError(strProcName, ex); throw new Exception("数据库处理出错:" + ex.Message); } finally { this.ThrowException(strProcName); } return(rtnDs); }
public bll_XT_ZZJG_DWBM() { dbases = DataAccessor.CreateDatabase(); }