/// <summary> /// 实体类操作 (增删改) /// </summary> /// <param name="entitys"></param> /// <param name="optype"></param> /// <returns></returns> public bool NoTransactionOPEntitys(List <T> entitys, EOPType optype) { if (entitys == null) { return(false); } return(pm.GetCurrentDataPlugin().NoTransactionOPEntitys(entitys, optype)); }
public bool MenusNoTransactionOPEntitys(OPEntityCmd cmd) { SystemBusiness _SysInfoBusiness = new SystemBusiness(); List <MenuInfo> itemList = JsonUtil.fromJson <List <MenuInfo> >(cmd.EntityJson); EOPType eopType = (EOPType)cmd.optype; return(_SysInfoBusiness.NoTransactionOPEntitys <MenuInfo>(itemList, eopType)); }
/// <summary> /// 实体类操作 (增删改) /// </summary> /// <param name="entitys"></param> /// <param name="optype"></param> /// <returns></returns> public bool NoTransactionOPEntitys(List <T> entitys, EOPType optype) { bool result = false; try { //itemList.AddRange(entitys); if (optype == EOPType.Insert) { DbContext.InsertRange(entitys); result = true; } else if (optype == EOPType.Update) { //由于需要在实体中强制指定主键: [ColumnAttribute(IsPrimaryKey = true)] //不是主流标准,目前EPAS中实体不支持 if (DbContext.Update(entitys) >= 0) { result = true; } } else if (optype == EOPType.Delete) { //由于需要在实体中强制指定主键: [ColumnAttribute(IsPrimaryKey = true)] //不是主流标准,目前EPAS中实体不支持 if (DbContext.Delete(entitys) >= 0) { result = true; } } } catch (Exception ex) { Debug.WriteLine(ex.Message); } return(result); }
public bool NoTransactionOPEntitys(OPEntityCmd cmd) { BaseBusinessObject _BaseBusinessObject = new BaseBusinessObject(); #region 动态实体解析 Type type = ObjectHelper.GetSingleObjectTypeByName(cmd.Namespace, cmd.EntityTypeName); Type listType = ObjectHelper.GetListObjectTypeByName(cmd.Namespace, cmd.EntityTypeName); var itemList = typeof(JsonUtil).GetMethod("fromJson").MakeGenericMethod(listType)?.Invoke(null, new object[] { cmd.EntityJson }); #endregion EOPType eopType = (EOPType)cmd.optype; object result = typeof(BaseBusinessObject).GetMethod("NoTransactionOPEntitys").MakeGenericMethod(type)?.Invoke(_BaseBusinessObject, new object[] { itemList, eopType }); return((bool)result); // List <MenuInfo> itemList = JsonUtil.fromJson<List<MenuInfo>>(cmd.EntityJson); //return _SysInfoBusiness.NoTransactionOPEntitys<MenuInfo>(itemList, eopType); }
/// <summary> /// 实体类操作 (增删改) /// </summary> /// <param name="entitys"></param> /// <param name="optype"></param> /// <returns></returns> public bool NoTransactionOPEntitys(List <T> entitys, EOPType optype) { bool result = false; try { //itemList.AddRange(entitys); if (optype == EOPType.Insert) { if (this.Inserts(entitys) >= 0) { result = true; } } else if (optype == EOPType.Update) { if (this.Updates(entitys) >= 0) { result = true; } } else if (optype == EOPType.Delete) { if (this.Deletes(entitys) >= 0) { result = true; } } } catch (Exception ex) { Debug.WriteLine(ex.Message); } return(result); }
/// <summary> /// 事务开始 /// </summary> /// <returns></returns> public static bool TransactionOPEntitysAdd <T>(IDbConnection cn, IDbTransaction transaction, EOPType eop, List <T> itemList) where T : class { BaseEntityData <T> data = new BaseEntityData <T>(); return(data.TransactionOPEntitysAdd <T>(cn, transaction, eop, itemList)); }
/// <summary> /// 实体类操作 (增删改) /// </summary> /// <param name="entitys"></param> /// <param name="optype"></param> /// <returns></returns> public static bool NoTransactionOPEntitys <T>(List <T> entitys, EOPType optype) where T : class { BaseEntityData <T> data = new BaseEntityData <T>(); return(data.NoTransactionOPEntitys(entitys, optype)); }
public bool TransactionOPEntitysAdd <TE> (IDbConnection cn, IDbTransaction transaction, EOPType eop, List <TE> itemList) where TE : class { int count = 0; try { #region 插入事务 if (eop == EOPType.Insert) { cn.Insert <TE>(itemList, transaction); } #endregion #region 更新事务 if (eop == EOPType.Update) { foreach (var item in itemList) { if (cn.Update <TE>(item, transaction)) { count++; } else { transaction.Rollback(); return(false); } } } #endregion #region 除事务 if (eop == EOPType.Delete) { foreach (var item in itemList) { if (!cn.Delete <TE>(item, transaction)) { transaction.Rollback(); return(false); } else { //删除成功 count++; } } } #endregion } catch (Exception ex) { Debug.WriteLine(ex.Message); } return(true); }
/// <summary> /// 事务开始 /// </summary> /// <returns></returns> public bool TransactionOPEntitysAdd <TE>(IDbConnection cn, IDbTransaction transaction, EOPType eop, List <TE> itemList) where TE : class { return(pm.GetCurrentDataPlugin().TransactionOPEntitysAdd <TE>(cn, transaction, eop, itemList)); }
/// <summary> /// 未发布方法 无法使用 2019-6-27 /// </summary> /// <typeparam name="TE"></typeparam> /// <param name="cn"></param> /// <param name="transaction"></param> /// <param name="eop"></param> /// <param name="itemList"></param> /// <returns></returns> public bool TransactionOPEntitysAdd <TE>(IDbConnection cn, IDbTransaction transaction, EOPType eop, List <TE> itemList) where TE : class { int count = 0; try { #region 插入事务 if (eop == EOPType.Insert) { DbContext.InsertRange(itemList); } #endregion #region 更新事务 if (eop == EOPType.Update) { foreach (TE item in itemList) { if (DbContext.Update <TE>(item) >= 0) { count++; } else { if (DbContext.Session.IsInTransaction) { DbContext.Session.RollbackTransaction(); } return(false); } } } #endregion #region 除事务 if (eop == EOPType.Delete) { foreach (TE item in itemList) { if (DbContext.Delete <TE>(item) >= 0) { if (DbContext.Session.IsInTransaction) { DbContext.Session.RollbackTransaction(); } return(false); } else { //删除成功 count++; } } } #endregion } catch (Exception ex) { Debug.WriteLine(ex.Message); } return(true); }
/// <summary> /// 实体 增删改操作 /// </summary> /// <param name="itemList"></param> /// <param name="eopType"></param> /// <returns></returns> public bool NoTransactionOPEntitys <T>(List <T> itemList, EOPType eopType) where T : class { return(BaseEntityFac.NoTransactionOPEntitys <T>(itemList, eopType)); }