public static MyDbContext MoveToNext(this WorkFlowBag bag, MyDbContext db, string nextNodeId, string operatorId, string reason, string endNodeId) { //创建转移日志 db.CreateInstanceChangeLog(bag.Instance, "3", operatorId, reason, nextNodeId); bag.Move(nextNodeId); db.WorkFlowInstance.AddOrUpdate(bag.Instance); var isFinish = endNodeId == bag.Instance.CurrentNodeID; //如果为结束节点 if (isFinish) { //记录实例日志 db.CreateInstanceHistory(bag.Instance, "2", bag.Instance.Note + "\n" + DateTime.Now + "流程已结束"); //创建转移日志 db.CreateInstanceChangeLog(bag.Instance, "2", "system", "[sytem]流程自动结束", null); //删除示例 db.WorkFlowInstance.Remove(db.WorkFlowInstance.Find(bag.Instance.WorkFlowInstanceID)); } return(db); }