public ModelInvokeResult <ServerPK> Delete(string strServerId) { ModelInvokeResult <ServerPK> result = new ModelInvokeResult <ServerPK> { Success = true }; try { List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>(); string _ServerId = strServerId; ServerPK pk = new ServerPK { ServerId = _ServerId }; DeleteCascade(statements, pk); statements.Add(new IBatisNetBatchStatement { StatementName = new Server().GetDeleteMethodName(), ParameterObject = pk, Type = SqlExecuteType.DELETE }); /***********************begin 自定义代码*******************/ /***********************此处添加自定义代码*****************/ /***********************end 自定义代码*********************/ BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(statements); result.instance = new ServerPK { ServerId = _ServerId }; } catch (Exception ex) { result.Success = false; result.ErrorMessage = ex.Message; } return(result); }
private void DeleteCascade(List <IBatisNetBatchStatement> statements, ServerPK pk) { //此处增加级联删除代码 DatabaseConnectPK param = new DatabaseConnectPK { ConnectId = "Job-" + pk.ServerId }; statements.Add(new IBatisNetBatchStatement { StatementName = new DatabaseConnect().GetDeleteMethodName(), ParameterObject = param, Type = SqlExecuteType.DELETE }); }
public InvokeResult DeleteSelected(string strServerIds) { InvokeResult result = new InvokeResult { Success = true }; try { List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>(); string[] arrServerIds = strServerIds.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (arrServerIds.Length == 0) { result.Success = false; result.ErrorCode = 59996; return(result); } string statementName = new Server().GetDeleteMethodName(); foreach (string strServerId in arrServerIds) { ServerPK pk = new ServerPK { ServerId = strServerId }; DeleteCascade(statements, pk); statements.Add(new IBatisNetBatchStatement { StatementName = statementName, ParameterObject = pk, Type = SqlExecuteType.DELETE }); } BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(statements); } catch (Exception ex) { result.Success = false; result.ErrorMessage = ex.Message; } return(result); }