public InvokeResult DeleteSelected(string strMenuIds) { InvokeResult result = new InvokeResult { Success = true }; try { List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>(); string[] arrMenuIds = strMenuIds.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (arrMenuIds.Length == 0) { result.Success = false; result.ErrorCode = 59996; return(result); } string statementName = new Menu().GetDeleteMethodName(); foreach (string strMenuId in arrMenuIds) { MenuPK pk = new MenuPK { MenuId = strMenuId }; DeleteCascade(statements, pk); statements.Add(new IBatisNetBatchStatement { StatementName = statementName, ParameterObject = pk, Type = SqlExecuteType.DELETE }); /***********************begin 自定义代码*******************/ var menu = BuilderFactory.DefaultBulder().Load <Menu, MenuPK>(pk); StringObjectDictionary dictionary = new { MenuId = strMenuId, Action = SqlExecuteType.DELETE.ToString().ToLower(), OldParentId = menu.ParentId }.ToStringObjectDictionary(); dictionary.Add("ErrorCode", null); dictionary.Add("ErrorMessage", null); statements.Add(new IBatisNetBatchStatement { StatementName = "SP_Sys_AdjustMenu", ParameterObject = dictionary, Type = SqlExecuteType.UPDATE }); /***********************end 自定义代码*********************/ } BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(statements); } catch (Exception ex) { result.Success = false; result.ErrorMessage = ex.Message; } return(result); }
public ModelInvokeResult <MenuPK> Delete(string strMenuId) { ModelInvokeResult <MenuPK> result = new ModelInvokeResult <MenuPK> { Success = true }; try { List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>(); string _MenuId = strMenuId; MenuPK pk = new MenuPK { MenuId = _MenuId }; DeleteCascade(statements, pk); statements.Add(new IBatisNetBatchStatement { StatementName = new Menu().GetDeleteMethodName(), ParameterObject = pk, Type = SqlExecuteType.DELETE }); /***********************begin 自定义代码*******************/ var menu = BuilderFactory.DefaultBulder().Load <Menu, MenuPK>(new MenuPK { MenuId = strMenuId }); StringObjectDictionary dictionary = new { MenuId = strMenuId, Action = SqlExecuteType.DELETE.ToString().ToLower(), OldParentId = menu.ParentId }.ToStringObjectDictionary(); dictionary.Add("ErrorCode", null); dictionary.Add("ErrorMessage", null); statements.Add(new IBatisNetBatchStatement { StatementName = "SP_Sys_AdjustMenu", ParameterObject = dictionary, Type = SqlExecuteType.UPDATE }); /***********************end 自定义代码*********************/ BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(statements); result.instance = pk; } catch (Exception ex) { result.Success = false; result.ErrorMessage = ex.Message; } return(result); }
private void DeleteCascade(List <IBatisNetBatchStatement> statements, MenuPK pk) { //此处增加级联删除代码 }