private void DeleteCascade(List <IBatisNetBatchStatement> statements, GroupPK pk) { //此处增加级联删除代码 //删除组成员关系 GroupMember gm = new GroupMember { GroupId = pk.GroupId }; statements.Add(new IBatisNetBatchStatement { StatementName = gm.GetDeleteMethodName(), ParameterObject = gm.ToStringObjectDictionary(false), Type = SqlExecuteType.DELETE }); //删除组权限 GroupPermit gp = new GroupPermit { GroupId = pk.GroupId }; statements.Add(new IBatisNetBatchStatement { StatementName = gp.GetDeleteMethodName(), ParameterObject = gp.ToStringObjectDictionary(false), Type = SqlExecuteType.DELETE }); }
public InvokeResult DeleteSelected(string strGroupIds) { InvokeResult result = new InvokeResult { Success = true }; try { List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>(); string[] arrGroupIds = strGroupIds.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (arrGroupIds.Length == 0) { result.Success = false; result.ErrorCode = 59996; return(result); } string statementName = new Group().GetDeleteMethodName(); foreach (string strGroupId in arrGroupIds) { GroupPK pk = new GroupPK { GroupId = strGroupId.ToGuid() }; DeleteCascade(statements, pk); statements.Add(new IBatisNetBatchStatement { StatementName = statementName, ParameterObject = pk, Type = SqlExecuteType.DELETE }); } BuilderFactory.DefaultBulder(GetHttpHeader(GlobalManager.ConnectIdKey)).ExecuteNativeSqlNoneQuery(statements); } catch (Exception ex) { result.Success = false; result.ErrorMessage = ex.Message; } return(result); }
public ModelInvokeResult <GroupPK> Delete(string strGroupId) { ModelInvokeResult <GroupPK> result = new ModelInvokeResult <GroupPK> { Success = true }; try { List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>(); Guid?_GroupId = strGroupId.ToGuid(); if (_GroupId == null) { result.Success = false; result.ErrorCode = 59996; return(result); } GroupPK pk = new GroupPK { GroupId = _GroupId }; DeleteCascade(statements, pk); statements.Add(new IBatisNetBatchStatement { StatementName = new Group().GetDeleteMethodName(), ParameterObject = pk, Type = SqlExecuteType.DELETE }); /***********************begin 自定义代码*******************/ /***********************此处添加自定义代码*****************/ /***********************end 自定义代码*********************/ BuilderFactory.DefaultBulder(GetHttpHeader(GlobalManager.ConnectIdKey)).ExecuteNativeSqlNoneQuery(statements); result.instance = pk; } catch (Exception ex) { result.Success = false; result.ErrorMessage = ex.Message; } return(result); }