做最好用的工作流引擎,奉献社会.http://ccflow.org

递归在算法在工作流程引擎中的应用

递归在算法在工作流程引擎中的应用

递归做为一种算法在程序设计语言中广泛应用.是指函数/过程/子程序在运行过程中直接或间接调用自身而产生的重入现象.递归是计算机科学的一个重要概念,递归的方法是程序设计中有效的方法,采用递归编写程序能使程序变得简洁和清晰.

递归在工作流程引擎中有广泛的应用,以以下事例来说明:

应用一:退回到指定的节点,要把当前节电与退回节点之间的节点数据清空。

/// <summary>

        /// ÌY¨¦¦?y¢??¨²Ì???Ì?ºyY

        /// </summary>

        /// <param name="nds">Ì?ä?Ì?¨²Ì?¡¥?</param>

        publicvoid DeleteToNodesData(Nodes nds)

        {

            /*aº?À¨¦¤¨²Ì?ä?Ì?¨²Ì?¡¥?*/

            foreach (Node nd in nds)

            {

                Work wk = nd.HisWork;

                wk.OID = this.WorkID;

                if (wk.Delete() == 0)

                {

                    wk.FID = this.WorkID;

                    if (wk.Delete(WorkAttr.FID, this.WorkID) == 0)

                        continue;

                }

 

                /*¦Ì¡Â:°?-¦?y?¨²Ì?ºyY¡ê*/

                DBAccess.RunSQL("DELETE WF_GenerWorkerList WHERE (WorkID=" + this.WorkID + " OR FID=" + this.WorkID + ") AND FK_Node=" + nd.NodeID);

 

                //¦?yy¡êÌ?¤??ºyY¡ê

                DBAccess.RunSQL("DELETE WF_GenerWorkFlow WHERE WorkID NOT IN (SELECT WorkID FROM WF_GenerWorkerList )");

                DBAccess.RunSQL("DELETE WF_GenerFH WHERE FID NOT IN (SELECT FID FROM WF_GenerWorkerList)");

 

                

                DeleteToNodesData(nd.HisToNodes);

            }

        }

 

 

 



应用二:在分合流程过程中,流程结束时,要根据用户的需要判断并杀掉没有完成的进程。

 

/// <summary>

        /// ¨¢º?¢¡Â¨¬

        /// </summary>

        /// <returns></returns>

        publicstring DoFlowOver()

        {

            // ¡§¢¡é¢¡Â¨¬º?¤y¡ê

            GenerWorkFlow gwf = newGenerWorkFlow(this.WorkID);

            Node nd = newNode(gwf.FK_Node);

            string msg = this.BeforeFlowOver();

 

            //¨¨¨?¨¹Ì?Á¨®¢¡Â¨¬¨¢º?¡ê

            WorkerLists wls = newWorkerLists();

            wls.Retrieve(WorkerListAttr.FID, this.WorkID);

            foreach (WorkerList wl in wls)

            {

                WorkFlow wf = newWorkFlow(wl.FK_Flow, wl.WorkID);

                wf.DoFlowOver();

            }

    。。。。。。。。。。。。。。

   }

 

 

 

应用三:根据当前节点的ID,向上追溯一个分流节点。

/// <summary>

        /// ?¨?¨¹Ì?¦?°??Ì?¤?¢¡ÂÌ?

        /// </summary>

        privateNode _GetHisPriFLNode(Nodes nds)

        {

            foreach (Node mynd in nds)

            {

                if (mynd.IsHL)

                    return mynd;

                else

                    return _GetHisPriFLNode(mynd.HisFromNodes);

            }

            returnnull;

        }

        /// <summary>

        /// ¨¹Ì?¦?°??¤?¢¡Â¨²Ì?

        /// </summary>

        publicNode HisPriFLNode

        {

            get

            {

                return _GetHisPriFLNode(this.HisFromNodes);

            }

        }

 

 

 


类别:工作流开发 查看评论
posted on 2011-03-26 09:31  驰骋工作流  阅读(288)  评论(0编辑  收藏  举报

做最好用的工作流引擎,奉献社会.http://ccflow.org