Beispiel #1
0
        public static wfHistory[] GetWorkflowHistory(HttpSessionStateBase Session)
        {
            object viewState = Session["workflowhistory"];

            if (viewState == null)
            {
                wfHistory[] arrayList = new wfHistory[1];
                return(arrayList);
            }
            else
            {
                return((wfHistory[])viewState);
            }
        }
        private void AddtoWFHistory(Int32 WFID, Int32 NodeID, string wfname, string sectionname)
        {
            if (AddHistory == false)
            {
                return;
            }

            if (WFHistArray == null)
            {
                WFHistArray = new ArrayList();
            }

            if (SessionManager.GetWorkflowHistory(HttpContext.Session) != null)
            {
                WFHistArray.Clear();
                foreach (wfHistory wf in SessionManager.GetWorkflowHistory(HttpContext.Session))
                {
                    if (wf.WorkFlowID > 0)
                    {
                        WFHistArray.Add(wf);
                    }
                }
            }

            wfHistory wfh = new wfHistory();

            wfh.WorkFlowID   = WFID;
            wfh.NodeID       = NodeID;
            wfh.WorkFlowName = wfname;
            wfh.SectionName  = sectionname;

            if (WFHistArray.Count > 0)
            {
                wfHistory whist = (wfHistory)WFHistArray[WFHistArray.Count - 1];
                if (wfh.NodeID == whist.NodeID && wfh.WorkFlowID == whist.WorkFlowID)
                {
                    return;
                }
            }
            WFHistArray.Add(wfh);
            SessionManager.StoreWorkflowHistory(HttpContext.Session, (wfHistory[])WFHistArray.ToArray(typeof(wfHistory)));
        }
        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;
            }
        }