public static bool GoOn(int id, string performer, string toNodeName = null) { using (BasicWebContext context = new BasicWebContext()) { FlowInstance inst = context.FlowInstances.Find(id); FlowNode currentNode = context.FlowNodes.Include("ToNodes").Single(x => x.ID == inst.CurrentNodeID); if (currentNode.ToNodes.Count > 0) { var fromNodeID = inst.CurrentNodeID; var toNodeID = currentNode.ToNodes[0].ID; if (!string.IsNullOrEmpty(toNodeName)) { if (currentNode.ToNodes.Any(x => x.Name == toNodeName)) { toNodeID = currentNode.ToNodes.First(x => x.Name == toNodeName).ID; } } inst.CurrentNodeID = toNodeID; inst.EndTime = DateTime.Now; // newly 20130708 FlowInstanceAction action = new FlowInstanceAction(id, fromNodeID, toNodeID, performer); context.FlowInstanceActions.Add(action); context.SaveChanges(); return(true); } else { inst.Completed = true; inst.EndTime = DateTime.Now; context.SaveChanges(); } return(false); } }
public static void GoBack(int id, string performer) // newly 20130710 只支持回退一步,在最后两步之间来回跳转。 { using (BasicWebContext context = new BasicWebContext()) { FlowInstance inst = context.FlowInstances.Find(id); FlowInstanceAction action = context.FlowInstanceActions.Where(x => x.FlowInstanceID == id).ToList().LastOrDefault(); if (action != null) { var currentID = action.ToNodeID; var backToID = action.FromNodeID; inst.CurrentNodeID = backToID; inst.EndTime = DateTime.Now; FlowInstanceAction newAction = new FlowInstanceAction(id, currentID, backToID, performer); context.FlowInstanceActions.Add(newAction); context.SaveChanges(); } } }