public bool StopTask(int taskId, List <int> nodeids) { var taskandbinds = TaskBll.ToRightTaskNodes(taskId, nodeids, false); if (taskandbinds.Item2.Count() == 0) { throw new MException("没有节点,无法停止!"); } using (RLib.DB.DbConn dbconn = Pub.GetConn()) { dbconn.BeginTransaction(); try { var cmdmodel = new Model.Cmd() { CmdArgs = RLib.Utils.DataSerialize.SerializeJson(new Ruanal.Core.CmdTaskArg() { TaskId = taskId }), CmdState = 0, CmdType = Ruanal.Core.ConfigConst.CmdType_StopTask, NodeId = 0 }; List <string> clientIds = new List <string>(); foreach (var a in taskandbinds.Item2) { cmdmodel.NodeId = a.NodeId; cmddal.AddCmd(dbconn, cmdmodel); taskdal.UpdateBindLocalState(dbconn, a.BindId, 0); clientIds.Add(a.Node.ClientId); } dbconn.Commit(); NotifyNewCmd(clientIds); return(true); } catch (Exception ex) { dbconn.Rollback(); throw ex; } } }