public Node GetNode(Node entry)
 {
     entry.Transitions   = TransitionService.Query(entry.InstanceID).Where(t => t.RelationshipID == entry.NID).ToList();
     entry.Groups        = GroupService.Query(entry.InstanceID).Where(e => e.RelationshipID == entry.NID).ToList();
     entry.Actors        = ActorService.Query(entry.InstanceID).Where(e => e.RelationshipID == entry.NID).ToList();
     entry.Actions       = ActionService.Query(entry.InstanceID).Where(e => e.RelationshipID == entry.NID).ToList();
     entry.Carbons       = CarbonService.Query(entry.InstanceID).Where(e => e.RelationshipID == entry.NID).ToList();
     entry.Organizations = OrganizationService.Query(entry.InstanceID).Where(e => e.RelationshipID == entry.NID).ToList();
     entry.Command       = CommandService.Query(entry.InstanceID).Where(e => e.RelationshipID == entry.NID).FirstOrDefault();
     entry.Rules         = RuleService.Query(entry.InstanceID).Where(e => e.RelationshipID == entry.NID).ToList();
     entry.Previous      = GetPrevious(entry);
     return(entry);
 }
        public void Persistent(Element entry, Action <string, object> callback)
        {
            Node n = (entry as Node);

            entry.NID = Guid.NewGuid().ToString();
            callback(ResourceManage.SQL_WORKFLOW_NODE_INSERT, new { entry.NID, entry.ID, entry.Name, NodeType = n.NodeType.ToString(), entry.InstanceID, n.Cooperation, n.Assistant, n.Veto, n.Back, n.Url });

            foreach (Transition transition in n.Transitions)
            {
                transition.RelationshipID = entry.NID;
                transition.Origin         = entry.ID;
                transition.InstanceID     = entry.InstanceID;
                TransitionService.Persistent(transition, callback);
            }

            foreach (Elements.Action a in n.Actions)
            {
                a.RelationshipID = entry.NID;
                a.InstanceID     = entry.InstanceID;
                ActionService.Persistent(a, callback);
            }

            foreach (Group r in n.Groups)
            {
                r.RelationshipID = entry.NID;
                r.InstanceID     = entry.InstanceID;
                GroupService.Persistent(r, callback);
            }

            foreach (Organization o in n.Organizations)
            {
                o.RelationshipID = entry.NID;
                o.InstanceID     = entry.InstanceID;
                OrganizationService.Persistent(o, callback);
            }

            foreach (Actor a in n.Actors)
            {
                a.RelationshipID = entry.NID;
                a.InstanceID     = entry.InstanceID;
                ActorService.Persistent(a, callback);
            }

            foreach (Carbon c in n.Carbons)
            {
                c.RelationshipID = entry.NID;
                c.InstanceID     = entry.InstanceID;
                CarbonService.Persistent(c, callback);
            }

            foreach (Elements.Rule r in n.Rules)
            {
                r.RelationshipID = entry.NID;
                r.InstanceID     = entry.InstanceID;
                RuleService.Persistent(r, callback);
            }

            if (n.Command != null)
            {
                n.Command.InstanceID     = entry.InstanceID;
                n.Command.RelationshipID = entry.NID;
                CommandService.Persistent(n.Command, callback);
            }
        }