Пример #1
0
 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);
     }
 }
Пример #2
0
 public static void SetCurrentNode(int id, Guid nodeId)
 {
     using (BasicWebContext context = new BasicWebContext())
     {
         FlowInstance inst = context.FlowInstances.Find(id);
         inst.CurrentNodeID = nodeId;
         context.SaveChanges();
     }
 }
Пример #3
0
 public static int NewInstance(Guid id, string instName, string number, string comment)
 {
     using (BasicWebContext context = new BasicWebContext())
     {
         var          startNodeID = context.FlowNodes.Where(x => x.WorkflowID == id).Include("FromNodes").First(x => x.FromNodes.Count == 0).ID;
         FlowInstance inst        = new FlowInstance(instName, id, startNodeID)
         {
             Number = number, Comment = comment
         };
         context.FlowInstances.Add(inst);
         context.SaveChanges();
         return(context.FlowInstances.Max(x => x.ID));
     }
 }
Пример #4
0
 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();
         }
     }
 }