Exemplo n.º 1
0
        public IHttpActionResult GetScriptWorkflow(int id)
        {
            ScriptWorkflow scriptworkflow = db.ScriptWorkflows.Find(id);

            if (scriptworkflow == null)
            {
                return(NotFound());
            }

            return(Ok(scriptworkflow));
        }
Exemplo n.º 2
0
        public IHttpActionResult PostScriptWorkflow(ScriptWorkflow scriptworkflow)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.ScriptWorkflows.Add(scriptworkflow);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = scriptworkflow.ScriptWorkflowID }, scriptworkflow));
        }
Exemplo n.º 3
0
        public IHttpActionResult DeleteScriptWorkflow(int id)
        {
            ScriptWorkflow scriptworkflow = db.ScriptWorkflows.Find(id);

            if (scriptworkflow == null)
            {
                return(NotFound());
            }

            db.ScriptWorkflows.Remove(scriptworkflow);
            db.SaveChanges();

            return(Ok(scriptworkflow));
        }
        private bool IsNextNode(ScriptWorkflow scriptWorkflow, int currentNode)
        {
            // Local Variables
            XmlSerializer xmlSerializer = null;
            StringReader  stringReader  = null;
            WorkflowNodes workflowNodes = null;
            WFNodeInfo    nextNode      = null;

            try
            {
                // Instantiate local variables
                stringReader = new StringReader(scriptWorkflow.WorkflowXML);
                WFHistArray  = new ArrayList();

                // Deserialize the WorkFlow Nodes
                xmlSerializer = new XmlSerializer(typeof(WorkflowNodes));
                workflowNodes = (WorkflowNodes)xmlSerializer.Deserialize(stringReader);

                foreach (WFNodeInfo WFN in workflowNodes.Nodes)
                {
                    if (WFN.NodeUniqueID == currentNode)
                    {
                        Int32 ProcNode = DetermineNextSection(WFN);
                        foreach (WFNodeInfo WFN2 in workflowNodes.Nodes)
                        {
                            if ((WFN2.NodeUniqueID == ProcNode) || (WFN.Conditions != null && WFN.Conditions.Count() > 0))
                            {
                                nextNode = WFN2;
                                break;
                            }
                        }
                        break;
                    }
                }

                return(nextNode != null);
            }
            catch
            {
                return(false);
            }
            finally
            {
                xmlSerializer = null;
                stringReader  = null;
                workflowNodes = null;
            }
        }
        private WFNodeInfo DetermineNextNode(ScriptWorkflow scriptWorkflow, int currentNode, MoveDirection direction)
        {
            // Local Variables
            XmlSerializer xmlSerializer = null;
            StringReader  stringReader  = null;
            WorkflowNodes workflowNodes = null;
            WFNodeInfo    nextNode      = null;
            //wfHistory[] WorkflowHistory = null;
            ArrayList WFHistArray = null;

            try
            {
                // Instantiate local variables
                stringReader = new StringReader(scriptWorkflow.WorkflowXML);
                WFHistArray  = new ArrayList();

                // Deserialize the WorkFlow Nodes
                xmlSerializer = new XmlSerializer(typeof(WorkflowNodes));
                workflowNodes = (WorkflowNodes)xmlSerializer.Deserialize(stringReader);

                // Determin by direction
                switch (direction)
                {
                case MoveDirection.Forward:
                    foreach (WFNodeInfo WFN in workflowNodes.Nodes)
                    {
                        if (WFN.NodeUniqueID == currentNode)     //WorkflowObject.CurrentNode
                        {
                            Int32 ProcNode = DetermineNextSection(WFN);
                            foreach (WFNodeInfo WFN2 in workflowNodes.Nodes)
                            {
                                if (WFN2.NodeUniqueID == ProcNode)
                                {
                                    nextNode = WFN2;
                                    break;
                                }
                            }
                            break;
                        }
                    }
                    break;

                case MoveDirection.Back:

                    if (SessionManager.GetWorkflowHistory(HttpContext.Session) != null)
                    {
                        foreach (wfHistory wfhis in SessionManager.GetWorkflowHistory(HttpContext.Session))
                        {
                            WFHistArray.Add(wfhis);
                        }
                        if (WFHistArray.Count < 2)
                        {
                            return(null);
                        }
                        wfHistory lastone = (wfHistory)WFHistArray[WFHistArray.Count - 2];

                        if (lastone.WorkFlowID == scriptWorkflow.ScriptWorkflowID && lastone.NodeID == currentNode)
                        {
                            return(null);
                        }

                        if (lastone.WorkFlowID == scriptWorkflow.ScriptWorkflowID)
                        {
                            currentNode = lastone.NodeID;

                            WFHistArray.RemoveAt(WFHistArray.Count - 1);
                            WFHistArray.RemoveAt(WFHistArray.Count - 1);
                            SessionManager.StoreWorkflowHistory(HttpContext.Session, (wfHistory[])WFHistArray.ToArray(typeof(wfHistory)));
                            nextNode = DetermineNextNode(scriptWorkflow, currentNode, MoveDirection.Current);
                        }
                        else
                        {
                            nextNode = new WFNodeInfo();
                            nextNode.NodeUniqueID = lastone.WorkFlowID;
                            nextNode.nodeName     = lastone.WorkFlowName;
                            nextNode.nodeType     = NodeType.PreviousWorkflow;
                            nextNode.DocUID       = lastone.NodeID; // Use DocUID parameter as  NodeId
                            WFHistArray.RemoveAt(WFHistArray.Count - 1);
                            WFHistArray.RemoveAt(WFHistArray.Count - 1);
                            SessionManager.StoreWorkflowHistory(HttpContext.Session, (wfHistory[])WFHistArray.ToArray(typeof(wfHistory)));
                            return(nextNode);
                        }
                    }
                    else
                    {
                        return(null);
                    }
                    break;

                case MoveDirection.Current:
                    foreach (WFNodeInfo WFN in workflowNodes.Nodes)
                    {
                        if (WFN.NodeUniqueID == currentNode)
                        {
                            nextNode = WFN;
                            break;
                        }
                    }
                    break;

                case MoveDirection.Start:
                    foreach (WFNodeInfo wFNodeInfo in workflowNodes.Nodes)
                    {
                        Int32 ProcNode = DetermineNextSection(wFNodeInfo);
                        foreach (WFNodeInfo wFNodeInfo2 in workflowNodes.Nodes)
                        {
                            if (wFNodeInfo2.NodeUniqueID == ProcNode)
                            {
                                nextNode = wFNodeInfo2;
                                break;
                            }
                        }
                        break;
                    }
                    break;

                default:
                    break;
                }

                if (nextNode == null) //&& nextNode.nodeType.Equals(NodeType.SignPost)
                {
                    nextNode = DetermineNextNode(scriptWorkflow, nextNode.NodeUniqueID, MoveDirection.Forward);
                }

                return(nextNode);
            }
            catch
            {
                return(null);
            }
            finally
            {
                xmlSerializer = null;
                stringReader  = null;
                workflowNodes = null;
                WFHistArray   = null;
            }
        }