zoukankan      html  css  js  c++  java
  • 递归在算法在工作流程引擎中的应用

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

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

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

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

    /// <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);

                }

            }

     

     

     


    类别:工作流开发 查看评论
  • 相关阅读:
    【CentOS 6.5】QtCreator启动时关于dbus-1的错误解决方法
    【CentOS 6.5】 Qt Creator 启动失败
    C# mvc3 mvc4 伪静态及IIS7.5配置
    【水果大全】快看,你属于哪种水果身材?
    一首《放下》最近火了!
    【情感励志】不必仰望别人,自己亦是风景
    java JDBC连接 Sqlserver 非默认的实例名问题
    后台:酒店客服订单管理.把订单编号:1290939 从取消状态恢复确认有房状态(待发单状态)
    PHP安装环境搭建
    表操作汇总(复制,删除,修改,插入,查询及数据库的复制)
  • 原文地址:https://www.cnblogs.com/ccflow/p/2040008.html
Copyright © 2011-2022 走看看