예제 #1
0
        public void SetSelectItem(string val, Attr attr)
        {
            if (attr.UIBindKey == "BP.Port.Depts")
            {
                if (val.Contains(WebUser.FK_Dept) == false)
                {
                    return;
                }

                this.Items.Clear();
                BP.Port.Dept zsjg = new BP.Port.Dept(val);
                ListItem     li1  = new ListItem();
                li1.Text  = zsjg.GetValStrByKey(attr.UIRefKeyText);
                li1.Value = zsjg.GetValStrByKey(attr.UIRefKeyValue);
                this.Items.Add(li1);
                return;
            }
            if (attr.UIBindKey == "BP.Port.Units")
            {
                //if (val.Contains(WebUser.FK_Unit) == false)
                //    return;

                //this.Items.Clear();
                //BP.Port.Unit zsjg = new BP.Port.Unit(val);
                //ListItem li1 = new ListItem();
                //li1.Text = zsjg.GetValStrByKey(attr.UIRefKeyText);
                //li1.Value = zsjg.GetValStrByKey(attr.UIRefKeyValue);
                //this.Items.Add(li1);
                return;
            }


            if (this.SetSelectItem(val))
            {
                return;
            }

            Entity en = attr.HisFKEn; // ClassFactory.GetEn(attr.UIBindKey);

            en.PKVal = val;

            #warning edit: 2008-06-01  en.RetrieveFromDBSources();

            en.Retrieve();

            ListItem li = new ListItem();
            li.Text  = en.GetValStrByKey(attr.UIRefKeyText);
            li.Value = en.GetValStrByKey(attr.UIRefKeyValue);

            if (this.Items.Contains(li))
            {
                this.SetSelectItem(val);
                return;
            }

            ListItem liall = this.GetItemByText("请用更多...");
            ListItem myall = this.GetItemByVal("all");
            if (myall != null)
            {
                this.Items.Clear();
                this.Items.Add(li);
                this.Items.Add(myall);

                // this.Items.Remove(liall);
            }

            //  this.Items.Add(li);
            this.SetSelectItem(val);
        }
예제 #2
0
        public string DoAdd(string empNo, string orgNo)
        {
            BP.Port.Emp emp = new BP.Port.Emp();
            emp.No = empNo;
            if (emp.RetrieveFromDBSources() == 0)
            {
                return("err@管理员增加失败,ID=" + empNo + "不存在用户表,您增加的管理员必须存在与Port_Emp用户表.");
            }

            BP.Port.Dept dept = new BP.Port.Dept();
            dept.No = orgNo;
            if (dept.RetrieveFromDBSources() == 0)
            {
                return("err@orgNo错误, 不存在 Port_Dept 里面。");
            }

            BP.WF.Port.Inc inc = new BP.WF.Port.Inc();
            inc.No = orgNo;
            if (inc.RetrieveFromDBSources() == 0)
            {
                return("err@orgNo错误, 不存在 Port_Inc 里面。");
            }

            //求根目录流程树.
            BP.WF.Template.FlowSort fsRoot = new BP.WF.Template.FlowSort();
            fsRoot.Retrieve(BP.WF.Template.FlowSortAttr.ParentNo, "0");


            BP.WF.Template.FlowSort fs = new BP.WF.Template.FlowSort();
            fs.No = "Inc" + orgNo;
            if (fs.RetrieveFromDBSources() == 1)
            {
                return("err@该组织已经初始化过流程树目录.");
            }

            fs.Name     = dept.Name + "-流程树";
            fs.ParentNo = fsRoot.No;
            fs.OrgNo    = dept.No;
            fs.Insert();


            //求根目录流程树.
            BP.Sys.FrmTree frmRoot = new BP.Sys.FrmTree();
            frmRoot.Retrieve(BP.WF.Template.FlowSortAttr.ParentNo, "0");

            BP.Sys.FrmTree frmTree = new BP.Sys.FrmTree();
            frmTree.No = "Inc" + orgNo;
            if (frmTree.RetrieveFromDBSources() == 1)
            {
                return("err@该组织已经初始化过表单树目录.");
            }

            frmTree.ParentNo = frmRoot.No;
            frmTree.Name     = dept.Name + "-表单树";
            frmTree.OrgNo    = dept.No;
            frmTree.Insert();


            AdminEmp ae = new AdminEmp();

            ae.No = empNo;
            if (ae.RetrieveFromDBSources() == 1)
            {
                if (ae.IsAdmin == true)
                {
                    return("err@该管理员已经存在,请删除该管理员重新增加delete from wf_emp where no='" + empNo + "'");
                }
                ae.Delete();
            }

            ae.Copy(emp);
            ae.UserType   = 1;
            ae.UseSta     = 1;
            ae.RootOfDept = orgNo;
            ae.RootOfFlow = "Inc" + orgNo;
            ae.RootOfForm = "Inc" + orgNo;
            ae.Insert();

            return("info@管理员增加成功.");
        }
예제 #3
0
        /// <summary>
        /// 根据部门获取下一步的操作员
        /// </summary>
        /// <param name="deptNo"></param>
        /// <param name="emp1"></param>
        /// <returns></returns>
        public DataTable Func_GenerWorkerList_DiGui(string deptNo, string empNo)
        {
            string sql;

            if (BP.WF.Glo.OSModel == OSModel.BPM)
            {
                sql = "SELECT FK_Emp as No FROM Port_DeptEmpStation A, WF_NodeStation B WHERE A.FK_Station=B.FK_Station AND B.FK_Node=" + dbStr + "FK_Node AND A.FK_Dept=" + dbStr + "FK_Dept AND A.FK_Emp!=" + dbStr + "FK_Emp";
            }
            else
            {
                sql = "SELECT FK_Emp as No FROM Port_EmpStation A, WF_NodeStation B, Port_Emp C WHERE A.FK_Station=B.FK_Station AND A.FK_Emp=C.No AND B.FK_Node=" + dbStr + "FK_Node AND C.FK_Dept=" + dbStr + "FK_Dept AND A.FK_Emp!=" + dbStr + "FK_Emp";
            }
            Paras ps = new Paras();

            ps.SQL = sql;
            ps.Add("FK_Node", town.HisNode.NodeID);
            ps.Add("FK_Dept", deptNo);
            ps.Add("FK_Emp", empNo);


            DataTable dt = DBAccess.RunSQLReturnTable(ps);

            if (dt.Rows.Count == 0)
            {
                NodeStations nextStations = town.HisNode.NodeStations;
                if (nextStations.Count == 0)
                {
                    throw new Exception("@节点没有岗位:" + town.HisNode.NodeID + "  " + town.HisNode.Name);
                }

                sql  = "SELECT No FROM Port_Emp WHERE No IN ";
                sql += "(SELECT  FK_Emp  FROM " + BP.WF.Glo.EmpStation + " WHERE FK_Station IN (SELECT FK_Station FROM WF_NodeStation WHERE FK_Node=" + dbStr + "FK_Node ) )";
                sql += " AND No IN ";

                if (deptNo == "1")
                {
                    sql += "(SELECT FK_Emp FROM Port_EmpDept WHERE FK_Emp!=" + dbStr + "FK_Emp ) ";
                }
                else
                {
                    BP.Port.Dept deptP = new BP.Port.Dept(deptNo);
                    sql += "(SELECT FK_Emp FROM Port_EmpDept WHERE FK_Emp!=" + dbStr + "FK_Emp AND FK_Dept = '" + deptP.ParentNo + "')";
                }

                ps     = new Paras();
                ps.SQL = sql;
                ps.Add("FK_Node", town.HisNode.NodeID);
                ps.Add("FK_Emp", empNo);
                dt = DBAccess.RunSQLReturnTable(ps);


                if (dt.Rows.Count == 0)
                {
                    return(null);
                }
                return(dt);
            }
            else
            {
                return(dt);
            }
            return(null);
        }
예제 #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                //如果没有Port_Dept 表就可能没有安装ccflow.
                DBAccess.RunSQL("SELECT * FROM Port_Dept WHERE 1=2");
            }
            catch
            {
                /*数据库链接不通或者有异常,说明没有安装.*/
                this.Response.Redirect("../DBInstall.aspx", true);
                return;
            }

            if (this.IsCheckUpdate == false)
            {
                #region 执行admin登陆.
                Emp emp = new Emp();
                emp.No = "admin";
                if (emp.RetrieveFromDBSources() == 1)
                {
                    BP.Web.WebUser.SignInOfGener(emp, true);
                }
                else
                {
                    emp.No      = "admin";
                    emp.Name    = "admin";
                    emp.FK_Dept = "01";
                    emp.Pass    = "******";
                    emp.Insert();
                    BP.Web.WebUser.SignInOfGener(emp, true);
                    //throw new Exception("admin 用户丢失,请注意大小写。");
                }
                #endregion 执行admin登陆.
                return;
            }

            string sql = "";
            string msg = "";
            try
            {
                msg = "@登陆时错误。";
                DBAccess.RunSQL("DELETE Sys_Enum WHERE EnumKey IN ('DeliveryWay','RunModel','OutTimeDeal')");

                BP.Port.Unit u = new BP.Port.Unit();
                u.CheckPhysicsTable();

                //部门
                BP.Port.Dept d = new BP.Port.Dept();
                d.CheckPhysicsTable();

                int i = DBAccess.RunSQLReturnValInt("SELECT COUNT(*) FROM Port_Unit");
                if (i == 0)
                {
                    DBAccess.RunSQL("INSERT INTO Port_Unit (No,Name, ParentNo)VALUES('1','济南驰骋信息技术有限公司','-1')");
                }

                GenerWorkFlow gwf = new GenerWorkFlow();
                gwf.CheckPhysicsTable();

                Flow fl = new Flow();
                fl.CheckPhysicsTable();

                Node nd = new Node();
                nd.CheckPhysicsTable();

                SMS sms = new SMS();
                sms.CheckPhysicsTable();

                #region 执行admin登陆. 2012-12-25 新版本.
                Emp emp = new Emp();
                emp.No = "admin";
                if (emp.RetrieveFromDBSources() == 1)
                {
                    BP.Web.WebUser.SignInOfGener(emp, true);
                }
                else
                {
                    emp.No      = "admin";
                    emp.Name    = "admin";
                    emp.FK_Dept = "01";
                    emp.Pass    = "******";
                    emp.Insert();
                    BP.Web.WebUser.SignInOfGener(emp, true);
                    //throw new Exception("admin 用户丢失,请注意大小写。");
                }
                #endregion 执行admin登陆.
            }
            catch (Exception ex)
            {
                this.Response.Write("问题出处:" + ex.Message + "<hr>" + msg + "<br>详细信息:@" + ex.StackTrace + "<br>@<a href='../DBInstall.aspx' >点这里到系统升级界面。</a>");
                return;
            }
        }
예제 #5
0
        private DataTable FindByWorkFlowModel()
        {
            this.town = town;

            DataTable dt = new DataTable();

            dt.Columns.Add("No", typeof(string));
            string sql;
            string FK_Emp;

            // 如果执行了两次发送,那前一次的轨迹就需要被删除,这里是为了避免错误。
            ps = new Paras();
            ps.Add("WorkID", this.WorkID);
            ps.Add("FK_Node", town.HisNode.NodeID);
            ps.SQL = "DELETE FROM WF_GenerWorkerlist WHERE WorkID=" + dbStr + "WorkID AND FK_Node =" + dbStr + "FK_Node";
            DBAccess.RunSQL(ps);

            // 如果指定特定的人员处理。
            if (string.IsNullOrEmpty(JumpToEmp) == false)
            {
                string[] emps = JumpToEmp.Split(',');
                foreach (string emp in emps)
                {
                    if (string.IsNullOrEmpty(emp))
                    {
                        continue;
                    }
                    DataRow dr = dt.NewRow();
                    dr[0] = emp;
                    dt.Rows.Add(dr);
                }
                return(dt);
            }

            // 按上一节点发送人处理。
            if (town.HisNode.HisDeliveryWay == DeliveryWay.ByPreviousNodeEmp)
            {
                DataRow dr = dt.NewRow();
                dr[0] = BP.Web.WebUser.No;
                dt.Rows.Add(dr);
                return(dt);
            }

            //首先判断是否配置了获取下一步接受人员的sql.
            if (town.HisNode.HisDeliveryWay == DeliveryWay.BySQL ||
                town.HisNode.HisDeliveryWay == DeliveryWay.BySQLAsSubThreadEmpsAndData)
            {
                if (town.HisNode.DeliveryParas.Length < 4)
                {
                    throw new Exception("@您设置的当前节点按照SQL,决定下一步的接受人员,但是你没有设置sql.");
                }

                sql = town.HisNode.DeliveryParas;
                sql = sql.Clone().ToString();

                sql = Glo.DealExp(sql, this.currWn.rptGe, null);
                if (sql.Contains("@"))
                {
                    if (Glo.SendHTOfTemp != null)
                    {
                        foreach (string key in Glo.SendHTOfTemp.Keys)
                        {
                            sql = sql.Replace("@" + key, Glo.SendHTOfTemp[key].ToString());
                        }
                    }
                }

                dt = DBAccess.RunSQLReturnTable(sql);
                if (dt.Rows.Count == 0 && town.HisNode.HisWhenNoWorker != WhenNoWorker.Skip)
                {
                    throw new Exception("@没有找到可接受的工作人员。@技术信息:执行的sql没有发现人员:" + sql);
                }
                return(dt);
            }

            #region  照明细表,作为子线程的接收人.
            if (town.HisNode.HisDeliveryWay == DeliveryWay.ByDtlAsSubThreadEmps)
            {
                if (this.town.HisNode.HisRunModel != RunModel.SubThread)
                {
                    throw new Exception("@您设置的节点接收人方式为:以分流点表单的明细表数据源确定子线程的接收人,但是当前节点非子线程节点。");
                }

                BP.Sys.MapDtls dtls = new BP.Sys.MapDtls(this.currWn.HisNode.NodeFrmID);
                string         msg  = null;
                foreach (BP.Sys.MapDtl dtl in dtls)
                {
                    try
                    {
                        ps     = new Paras();
                        ps.SQL = "SELECT UserNo FROM " + dtl.PTable + " WHERE RefPK=" + dbStr + "OID ORDER BY OID";
                        ps.Add("OID", this.WorkID);
                        dt = DBAccess.RunSQLReturnTable(ps);
                        if (dt.Rows.Count == 0 && town.HisNode.HisWhenNoWorker != WhenNoWorker.Skip)
                        {
                            throw new Exception("@流程设计错误,到达的节点(" + town.HisNode.Name + ")在指定的节点中没有数据,无法找到子线程的工作人员。");
                        }
                        return(dt);
                    }
                    catch (Exception ex)
                    {
                        msg += ex.Message;
                        //if (dtls.Count == 1)
                        //    throw new Exception("@估计是流程设计错误,没有在分流节点的明细表中设置");
                    }
                }
                throw new Exception("@没有找到分流节点的明细表作为子线程的发起的数据源,流程设计错误,请确认分流节点表单中的明细表是否有UserNo约定的系统字段。" + msg);
            }
            #endregion  照明细表,作为子线程的接收人.

            #region  节点绑定的人员处理.
            if (town.HisNode.HisDeliveryWay == DeliveryWay.ByBindEmp)
            {
                ps = new Paras();
                ps.Add("FK_Node", town.HisNode.NodeID);
                ps.SQL = "SELECT FK_Emp FROM WF_NodeEmp WHERE FK_Node=" + dbStr + "FK_Node ORDER BY FK_Emp";
                dt     = DBAccess.RunSQLReturnTable(ps);
                if (dt.Rows.Count == 0)
                {
                    throw new Exception("@流程设计错误:下一个节点(" + town.HisNode.Name + ")没有绑定工作人员 . ");
                }
                return(dt);
            }
            #endregion  节点绑定的人员处理.

            #region  照选择的人员处理。
            if (town.HisNode.HisDeliveryWay == DeliveryWay.BySelected ||
                town.HisNode.HisDeliveryWay == DeliveryWay.ByFEE)
            {
                ps = new Paras();
                ps.Add("FK_Node", this.town.HisNode.NodeID);
                ps.Add("WorkID", this.currWn.HisWork.OID);
                ps.SQL = "SELECT FK_Emp FROM WF_SelectAccper WHERE FK_Node=" + dbStr + "FK_Node AND WorkID=" + dbStr + "WorkID AND AccType=0 ORDER BY IDX";
                dt     = DBAccess.RunSQLReturnTable(ps);
                if (dt.Rows.Count == 0)
                {
                    /*从上次发送设置的地方查询. */
                    SelectAccpers sas = new SelectAccpers();
                    int           i   = sas.QueryAccepterPriSetting(this.town.HisNode.NodeID);
                    if (i == 0)
                    {
                        if (town.HisNode.HisDeliveryWay == DeliveryWay.BySelected)
                        {
                            throw new Exception("@请选择下一步骤工作(" + town.HisNode.Name + ")接受人员。");
                        }
                        else
                        {
                            throw new Exception("@流程设计错误,请重写FEE,然后为节点(" + town.HisNode.Name + ")设置接受人员,详细请参考cc流程设计手册。");
                        }
                    }

                    //插入里面.
                    foreach (SelectAccper item in sas)
                    {
                        DataRow dr = dt.NewRow();
                        dr[0] = item.FK_Emp;
                        dt.Rows.Add(dr);
                    }
                    return(dt);
                }
                return(dt);
            }
            #endregion  照选择的人员处理。

            #region  照指定节点的处理人计算。
            if (town.HisNode.HisDeliveryWay == DeliveryWay.BySpecNodeEmp ||
                town.HisNode.HisDeliveryWay == DeliveryWay.ByStarter)
            {
                /* 按指定节点岗位上的人员计算 */
                string strs = town.HisNode.DeliveryParas;
                if (town.HisNode.HisDeliveryWay == DeliveryWay.ByStarter)
                {
                    /*找开始节点的处理人员. */
                    strs   = int.Parse(this.fl.No) + "01";
                    ps     = new Paras();
                    ps.SQL = "SELECT FK_Emp FROM WF_GenerWorkerList WHERE WorkID=" + dbStr + "OID AND FK_Node=" + dbStr + "FK_Node AND IsPass=1 AND IsEnable=1 ";
                    ps.Add("FK_Node", int.Parse(strs));
                    ps.Add("OID", this.WorkID);
                    dt = DBAccess.RunSQLReturnTable(ps);
                    if (dt.Rows.Count == 1)
                    {
                        return(dt);
                    }
                    else
                    {
                        /* 有可能当前节点就是第一个节点,那个时间还没有初始化数据,就返回当前人. */
                        DataRow dr = dt.NewRow();
                        dr[0] = BP.Web.WebUser.No;
                        dt.Rows.Add(dr);
                        return(dt);
                    }
                }

                // 首先从本流程里去找。
                strs = strs.Replace(";", ",");
                string[] nds = strs.Split(',');
                foreach (string nd in nds)
                {
                    if (string.IsNullOrEmpty(nd))
                    {
                        continue;
                    }

                    if (DataType.IsNumStr(nd) == false)
                    {
                        throw new Exception("流程设计错误:您设置的节点(" + town.HisNode.Name + ")的接收方式为按指定的节点岗位投递,但是您没有在访问规则设置中设置节点编号。");
                    }

                    ps     = new Paras();
                    ps.SQL = "SELECT FK_Emp FROM WF_GenerWorkerList WHERE WorkID=" + dbStr + "OID AND FK_Node=" + dbStr + "FK_Node AND IsPass=1 AND IsEnable=1 ";
                    ps.Add("FK_Node", int.Parse(nd));
                    if (this.currWn.HisNode.HisRunModel == RunModel.SubThread)
                    {
                        ps.Add("OID", this.currWn.HisWork.FID);
                    }
                    else
                    {
                        ps.Add("OID", this.WorkID);
                    }

                    DataTable dt_ND = DBAccess.RunSQLReturnTable(ps);
                    //添加到结果表
                    if (dt_ND.Rows.Count != 0)
                    {
                        foreach (DataRow row in dt_ND.Rows)
                        {
                            DataRow dr = dt.NewRow();
                            dr[0] = row[0].ToString();
                            dt.Rows.Add(dr);
                        }
                        //此节点已找到数据则不向下找,继续下个节点
                        continue;
                    }

                    //就要到轨迹表里查,因为有可能是跳过的节点.
                    ps     = new Paras();
                    ps.SQL = "SELECT " + TrackAttr.EmpFrom + " FROM ND" + int.Parse(fl.No) + "Track WHERE (ActionType=" + dbStr + "ActionType1 OR ActionType=" + dbStr + "ActionType2 OR ActionType=" + dbStr + "ActionType3 OR ActionType=" + dbStr + "ActionType4 OR ActionType=" + dbStr + "ActionType5) AND NDFrom=" + dbStr + "NDFrom AND WorkID=" + dbStr + "WorkID";
                    ps.Add("ActionType1", (int)ActionType.Skip);
                    ps.Add("ActionType2", (int)ActionType.Forward);
                    ps.Add("ActionType3", (int)ActionType.ForwardFL);
                    ps.Add("ActionType4", (int)ActionType.ForwardHL);
                    ps.Add("ActionType5", (int)ActionType.Start);

                    ps.Add("NDFrom", int.Parse(nd));
                    ps.Add("WorkID", this.WorkID);
                    dt_ND = DBAccess.RunSQLReturnTable(ps);
                    if (dt_ND.Rows.Count != 0)
                    {
                        foreach (DataRow row in dt_ND.Rows)
                        {
                            DataRow dr = dt.NewRow();
                            dr[0] = row[0].ToString();
                            dt.Rows.Add(dr);
                        }
                    }
                }

                //本流程里没有有可能该节点是配置的父流程节点,也就是说子流程的一个节点与父流程指定的节点的工作人员一致.
                GenerWorkFlow gwf = new GenerWorkFlow(this.WorkID);
                if (gwf.PWorkID != 0)
                {
                    foreach (string pnodeiD in nds)
                    {
                        if (string.IsNullOrEmpty(pnodeiD))
                        {
                            continue;
                        }

                        Node nd = new Node(int.Parse(pnodeiD));
                        if (nd.FK_Flow != gwf.PFlowNo)
                        {
                            continue; // 如果不是父流程的节点,就不执行.
                        }
                        ps     = new Paras();
                        ps.SQL = "SELECT FK_Emp FROM WF_GenerWorkerList WHERE WorkID=" + dbStr + "OID AND FK_Node=" + dbStr + "FK_Node AND IsPass=1 AND IsEnable=1 ";
                        ps.Add("FK_Node", nd.NodeID);
                        if (this.currWn.HisNode.HisRunModel == RunModel.SubThread)
                        {
                            ps.Add("OID", gwf.PFID);
                        }
                        else
                        {
                            ps.Add("OID", gwf.PWorkID);
                        }

                        DataTable dt_PWork = DBAccess.RunSQLReturnTable(ps);
                        if (dt_PWork.Rows.Count != 0)
                        {
                            foreach (DataRow row in dt_PWork.Rows)
                            {
                                DataRow dr = dt.NewRow();
                                dr[0] = row[0].ToString();
                                dt.Rows.Add(dr);
                            }
                            //此节点已找到数据则不向下找,继续下个节点
                            continue;
                        }

                        //就要到轨迹表里查,因为有可能是跳过的节点.
                        ps     = new Paras();
                        ps.SQL = "SELECT " + TrackAttr.EmpFrom + " FROM ND" + int.Parse(fl.No) + "Track WHERE (ActionType=" + dbStr + "ActionType1 OR ActionType=" + dbStr + "ActionType2 OR ActionType=" + dbStr + "ActionType3 OR ActionType=" + dbStr + "ActionType4 OR ActionType=" + dbStr + "ActionType5) AND NDFrom=" + dbStr + "NDFrom AND WorkID=" + dbStr + "WorkID";
                        ps.Add("ActionType1", (int)ActionType.Start);
                        ps.Add("ActionType2", (int)ActionType.Forward);
                        ps.Add("ActionType3", (int)ActionType.ForwardFL);
                        ps.Add("ActionType4", (int)ActionType.ForwardHL);
                        ps.Add("ActionType5", (int)ActionType.Skip);

                        ps.Add("NDFrom", nd.NodeID);

                        if (this.currWn.HisNode.HisRunModel == RunModel.SubThread)
                        {
                            ps.Add("OID", gwf.PFID);
                        }
                        else
                        {
                            ps.Add("OID", gwf.PWorkID);
                        }

                        dt_PWork = DBAccess.RunSQLReturnTable(ps);
                        if (dt_PWork.Rows.Count != 0)
                        {
                            foreach (DataRow row in dt_PWork.Rows)
                            {
                                DataRow dr = dt.NewRow();
                                dr[0] = row[0].ToString();
                                dt.Rows.Add(dr);
                            }
                        }
                    }
                }
                //返回指定节点的处理人
                if (dt.Rows.Count != 0)
                {
                    return(dt);
                }

                throw new Exception("@流程设计错误,到达的节点(" + town.HisNode.Name + ")在指定的节点(" + strs + ")中没有数据,无法找到工作的人员。 @技术信息如下: 投递方式:BySpecNodeEmp sql=" + ps.SQLNoPara);
            }
            #endregion  照节点绑定的人员处理。

            #region  照上一个节点表单指定字段的人员处理。
            if (town.HisNode.HisDeliveryWay == DeliveryWay.ByPreviousNodeFormEmpsField)
            {
                // 检查接受人员规则,是否符合设计要求.
                string specEmpFields = town.HisNode.DeliveryParas;
                if (string.IsNullOrEmpty(specEmpFields))
                {
                    specEmpFields = "SysSendEmps";
                }

                if (this.currWn.HisWork.EnMap.Attrs.Contains(specEmpFields) == false)
                {
                    throw new Exception("@您设置的当前节点按照指定的人员,决定下一步的接受人员,但是你没有在节点表单中设置该表单" + specEmpFields + "字段。");
                }

                //获取接受人并格式化接受人,
                string emps = this.currWn.HisWork.GetValStringByKey(specEmpFields);
                emps = emps.Replace(" ", "");
                if (emps.Contains(",") && emps.Contains(";"))
                {
                    /*如果包含,; 例如 zhangsan,张三;lisi,李四;*/
                    string[] myemps1 = emps.Split(';');
                    foreach (string str in myemps1)
                    {
                        if (string.IsNullOrEmpty(str))
                        {
                            continue;
                        }

                        string[] ss = str.Split(',');
                        DataRow  dr = dt.NewRow();
                        dr[0] = ss[0];
                        dt.Rows.Add(dr);
                    }
                    if (dt.Rows.Count == 0)
                    {
                        throw new Exception("@输入的接受人员信息错误;[" + emps + "]。");
                    }
                    else
                    {
                        return(dt);
                    }
                }

                emps = emps.Replace(";", ",");
                emps = emps.Replace(";", ",");
                emps = emps.Replace(",", ",");
                emps = emps.Replace("、", ",");
                emps = emps.Replace("@", ",");

                if (string.IsNullOrEmpty(emps))
                {
                    throw new Exception("@没有在字段[" + this.currWn.HisWork.EnMap.Attrs.GetAttrByKey(specEmpFields).Desc + "]中指定接受人,工作无法向下发送。");
                }

                // 把它加入接受人员列表中.
                string[] myemps = emps.Split(',');
                foreach (string s in myemps)
                {
                    if (string.IsNullOrEmpty(s))
                    {
                        continue;
                    }

                    //if (BP.DA.DBAccess.RunSQLReturnValInt("SELECT COUNT(NO) AS NUM FROM Port_Emp WHERE NO='" + s + "' or name='"+s+"'", 0) == 0)
                    //    continue;

                    DataRow dr = dt.NewRow();
                    dr[0] = s;
                    dt.Rows.Add(dr);
                }
                return(dt);
            }
            #endregion  照上一个节点表单指定字段的人员处理。

            string      prjNo       = "";
            FlowAppType flowAppType = this.currWn.HisNode.HisFlow.HisFlowAppType;
            sql = "";
            if (this.currWn.HisNode.HisFlow.HisFlowAppType == FlowAppType.PRJ)
            {
                prjNo = "";
                try
                {
                    prjNo = this.currWn.HisWork.GetValStrByKey("PrjNo");
                }
                catch (Exception ex)
                {
                    throw new Exception("@当前流程是工程类流程,但是在节点表单中没有PrjNo字段(注意区分大小写),请确认。@异常信息:" + ex.Message);
                }
            }

            #region  部门与岗位的交集计算.
            if (town.HisNode.HisDeliveryWay == DeliveryWay.ByDeptAndStation)
            {
                //added by liuxc,2015.6.29.
                //区别集成与BPM模式
                if (BP.WF.Glo.OSModel == OSModel.WorkFlow)
                {
                    sql  = "SELECT No FROM Port_Emp WHERE No IN ";
                    sql += "(SELECT FK_Emp FROM Port_EmpDept WHERE FK_Dept IN ";
                    sql += "( SELECT FK_Dept FROM WF_NodeDept WHERE FK_Node=" + dbStr + "FK_Node1)";
                    sql += ")";
                    sql += "AND No IN ";
                    sql += "(";
                    sql += "SELECT FK_Emp FROM " + BP.WF.Glo.EmpStation + " WHERE FK_Station IN ";
                    sql += "( SELECT FK_Station FROM WF_NodeStation WHERE FK_Node=" + dbStr + "FK_Node2 )";
                    sql += ") ORDER BY No ";

                    ps = new Paras();
                    ps.Add("FK_Node1", town.HisNode.NodeID);
                    ps.Add("FK_Node2", town.HisNode.NodeID);
                    ps.SQL = sql;
                    dt     = DBAccess.RunSQLReturnTable(ps);
                }
                else
                {
                    sql = "SELECT pdes.FK_Emp AS No"
                          + " FROM   Port_DeptEmpStation pdes"
                          + " INNER JOIN WF_NodeDept wnd ON wnd.FK_Dept = pdes.FK_Dept"
                          + " AND wnd.FK_Node = " + town.HisNode.NodeID
                          + " INNER JOIN WF_NodeStation wns ON  wns.FK_Station = pdes.FK_Station"
                          + " AND wns.FK_Node =" + town.HisNode.NodeID
                          + " ORDER BY pdes.FK_Emp";

                    dt = DBAccess.RunSQLReturnTable(sql);
                }

                if (dt.Rows.Count > 0)
                {
                    return(dt);
                }
                else
                {
                    throw new Exception("@节点访问规则错误:节点(" + town.HisNode.NodeID + "," + town.HisNode.Name + "), 按照岗位与部门的交集确定接受人的范围错误,没有找到人员:SQL=" + sql);
                }
            }
            #endregion  部门与岗位的交集计算.


            #region 判断节点部门里面是否设置了部门,如果设置了,就按照它的部门处理。
            if (town.HisNode.HisDeliveryWay == DeliveryWay.ByDept)
            {
                ps = new Paras();
                ps.Add("FK_Node", this.town.HisNode.NodeID);
                ps.Add("WorkID", this.currWn.HisWork.OID);
                ps.SQL = "SELECT FK_Emp FROM WF_SelectAccper WHERE FK_Node=" + dbStr + "FK_Node AND WorkID=" + dbStr + "WorkID AND AccType=0 ORDER BY IDX";
                dt     = DBAccess.RunSQLReturnTable(ps);
                if (dt.Rows.Count > 0)
                {
                    return(dt);
                }
                if (flowAppType == FlowAppType.Normal)
                {
                    ps      = new Paras();
                    ps.SQL  = "SELECT No,Name FROM Port_Emp WHERE FK_Dept IN (SELECT FK_Dept FROM WF_NodeDept WHERE FK_Node=" + dbStr + "FK_Node1)";
                    ps.SQL += " OR ";
                    ps.SQL += " No IN (SELECT FK_Emp FROM Port_EmpDept WHERE FK_Dept IN ( SELECT FK_Dept FROM WF_NodeDept WHERE FK_Node=" + dbStr + "FK_Node2 ) )";
                    ps.SQL += " ORDER BY No";
                    ps.Add("FK_Node1", town.HisNode.NodeID);
                    ps.Add("FK_Node2", town.HisNode.NodeID);

                    dt = DBAccess.RunSQLReturnTable(ps);
                    if (dt.Rows.Count > 0 && town.HisNode.HisWhenNoWorker != WhenNoWorker.Skip)
                    {
                        return(dt);
                    }
                    else
                    {
                        //IsFindWorker = false;
                        //  ps.SQL = "SELECT No,Name FROM Port_Emp WHERE FK_Dept IN ( SELECT FK_Dept FROM WF_NodeDept WHERE FK_Node=" + dbStr + "FK_Node )";
                        throw new Exception("@按部门确定接受人的范围,没有找到人员.");
                    }
                }

                if (flowAppType == FlowAppType.PRJ)
                {
                    sql  = "SELECT No FROM Port_Emp WHERE No IN ";
                    sql += "(SELECT FK_Emp FROM Port_EmpDept WHERE FK_Dept IN ";
                    sql += "( SELECT FK_Dept FROM WF_NodeDept WHERE FK_Node=" + dbStr + "FK_Node1)";
                    sql += ")";
                    sql += "AND NO IN ";
                    sql += "(";
                    sql += "SELECT FK_Emp FROM Prj_EmpPrjStation WHERE FK_Station IN ";
                    sql += "( SELECT FK_Station FROM WF_NodeStation WHERE FK_Node=" + dbStr + "FK_Node2) AND FK_Prj=" + dbStr + "FK_Prj ";
                    sql += ")";
                    sql += " ORDER BY No";

                    ps = new Paras();
                    ps.Add("FK_Node1", town.HisNode.NodeID);
                    ps.Add("FK_Node2", town.HisNode.NodeID);
                    ps.Add("FK_Prj", prjNo);
                    ps.SQL = sql;

                    dt = DBAccess.RunSQLReturnTable(ps);
                    if (dt.Rows.Count == 0)
                    {
                        /* 如果项目组里没有工作人员就提交到公共部门里去找。*/
                        sql  = "SELECT NO FROM Port_Emp WHERE NO IN ";
                        sql += "(SELECT FK_Emp FROM Port_EmpDept WHERE FK_Dept IN ";
                        sql += "( SELECT FK_Dept FROM WF_NodeDept WHERE FK_Node=" + dbStr + "FK_Node1)";
                        sql += ")";
                        sql += "AND NO IN ";
                        sql += "(";
                        sql += "SELECT FK_Emp FROM " + BP.WF.Glo.EmpStation + " WHERE FK_Station IN ";
                        sql += "( SELECT FK_Station FROM WF_NodeStation WHERE FK_Node=" + dbStr + "FK_Node2)";
                        sql += ")";
                        sql += " ORDER BY No";

                        ps = new Paras();
                        ps.Add("FK_Node1", town.HisNode.NodeID);
                        ps.Add("FK_Node2", town.HisNode.NodeID);
                        ps.SQL = sql;
                    }
                    else
                    {
                        return(dt);
                    }

                    dt = DBAccess.RunSQLReturnTable(ps);
                    if (dt.Rows.Count > 0)
                    {
                        return(dt);
                    }
                }
            }
            #endregion 判断节点部门里面是否设置了部门,如果设置了,就按照它的部门处理。

            #region 仅按岗位计算
            if (town.HisNode.HisDeliveryWay == DeliveryWay.ByStationOnly)
            {
                sql = "SELECT A.FK_Emp FROM " + BP.WF.Glo.EmpStation + " A, WF_NodeStation B WHERE A.FK_Station=B.FK_Station AND B.FK_Node=" + dbStr + "FK_Node ORDER BY A.FK_Emp";
                ps  = new Paras();
                ps.Add("FK_Node", town.HisNode.NodeID);
                ps.SQL = sql;
                dt     = DBAccess.RunSQLReturnTable(ps);
                if (dt.Rows.Count > 0)
                {
                    return(dt);
                }
                else
                {
                    throw new Exception("@节点访问规则错误:节点(" + town.HisNode.NodeID + "," + town.HisNode.Name + "), 按节点岗位与人员部门集合两个纬度计算,没有找到人员:SQL=" + sql);
                }
            }
            #endregion


            #region  岗位计算(以部门集合为纬度).
            if (town.HisNode.HisDeliveryWay == DeliveryWay.ByStationAndEmpDept)
            {
                sql = "SELECT No FROM Port_Emp WHERE NO IN "
                      + "(SELECT  FK_Emp  FROM " + BP.WF.Glo.EmpStation + " WHERE FK_Station IN (SELECT FK_Station FROM WF_NodeStation WHERE FK_Node=" + dbStr + "FK_Node) )"
                      + " AND  FK_Dept IN "
                      + "(SELECT  FK_Dept  FROM Port_EmpDept WHERE FK_Emp =" + dbStr + "FK_Emp)";

                sql += " ORDER BY No";

                ps = new Paras();
                ps.Add("FK_Node", town.HisNode.NodeID);
                ps.Add("FK_Emp", WebUser.No);
                ps.SQL = sql;
                //2012.7.16李健修改
                //+" AND  NO IN "
                //+ "(SELECT  FK_Emp  FROM Port_EmpDept WHERE FK_Emp = '" + WebUser.No + "')";
                dt = DBAccess.RunSQLReturnTable(ps);
                if (dt.Rows.Count > 0)
                {
                    return(dt);
                }
                else
                {
                    throw new Exception("@节点访问规则错误:节点(" + town.HisNode.NodeID + "," + town.HisNode.Name + "), 按节点岗位与人员部门集合两个纬度计算,没有找到人员:SQL=" + sql);
                }
            }
            #endregion

            string empNo   = WebUser.No;
            string empDept = WebUser.FK_Dept;

            #region  指定的节点的人员岗位,做为下一步骤的流程接受人。
            if (town.HisNode.HisDeliveryWay == DeliveryWay.BySpecNodeEmpStation)
            {
                /* 按指定的节点的人员岗位 */
                string fk_node = town.HisNode.DeliveryParas;
                if (DataType.IsNumStr(fk_node) == false)
                {
                    throw new Exception("流程设计错误:您设置的节点(" + town.HisNode.Name + ")的接收方式为按指定的节点人员岗位投递,但是您没有在访问规则设置中设置节点编号。");
                }

                ps     = new Paras();
                ps.SQL = "SELECT Rec,FK_Dept FROM ND" + fk_node + " WHERE OID=" + dbStr + "OID";
                ps.Add("OID", this.WorkID);
                dt = DBAccess.RunSQLReturnTable(ps);
                if (dt.Rows.Count != 1)
                {
                    throw new Exception("@流程设计错误,到达的节点(" + town.HisNode.Name + ")在指定的节点中没有数据,无法找到工作的人员。");
                }

                empNo   = dt.Rows[0][0].ToString();
                empDept = dt.Rows[0][1].ToString();
            }
            #endregion  指定的节点人员,做为下一步骤的流程接受人。

            #region 最后判断 - 按照岗位来执行。
            if (this.currWn.HisNode.IsStartNode == false)
            {
                ps = new Paras();
                if (flowAppType == FlowAppType.Normal || flowAppType == FlowAppType.DocFlow)
                {
                    // 如果当前的节点不是开始节点, 从轨迹里面查询。
                    sql = "SELECT DISTINCT FK_Emp  FROM " + BP.WF.Glo.EmpStation + " WHERE FK_Station IN "
                          + "(SELECT FK_Station FROM WF_NodeStation WHERE FK_Node=" + town.HisNode.NodeID + ") "
                          + "AND FK_Emp IN (SELECT FK_Emp FROM WF_GenerWorkerlist WHERE WorkID=" + dbStr + "WorkID AND FK_Node IN (" + DataType.PraseAtToInSql(town.HisNode.GroupStaNDs, true) + ") )";

                    sql += " ORDER BY FK_Emp ";

                    ps.SQL = sql;
                    ps.Add("WorkID", this.WorkID);
                }

                if (flowAppType == FlowAppType.PRJ)
                {
                    // 如果当前的节点不是开始节点, 从轨迹里面查询。
                    sql = "SELECT DISTINCT FK_Emp  FROM Prj_EmpPrjStation WHERE FK_Station IN "
                          + "(SELECT FK_Station FROM WF_NodeStation WHERE FK_Node=" + dbStr + "FK_Node ) AND FK_Prj=" + dbStr + "FK_Prj "
                          + "AND FK_Emp IN (SELECT FK_Emp FROM WF_GenerWorkerlist WHERE WorkID=" + dbStr + "WorkID AND FK_Node IN (" + DataType.PraseAtToInSql(town.HisNode.GroupStaNDs, true) + ") )";
                    sql += " ORDER BY FK_Emp ";

                    ps     = new Paras();
                    ps.SQL = sql;
                    ps.Add("FK_Node", town.HisNode.NodeID);
                    ps.Add("FK_Prj", prjNo);
                    ps.Add("WorkID", this.WorkID);

                    dt = DBAccess.RunSQLReturnTable(ps);
                    if (dt.Rows.Count == 0)
                    {
                        /* 如果项目组里没有工作人员就提交到公共部门里去找。*/
                        sql = "SELECT DISTINCT FK_Emp  FROM " + BP.WF.Glo.EmpStation + " WHERE FK_Station IN "
                              + "(SELECT FK_Station FROM WF_NodeStation WHERE FK_Node=" + dbStr + "FK_Node ) "
                              + "AND FK_Emp IN (SELECT FK_Emp FROM WF_GenerWorkerlist WHERE WorkID=" + dbStr + "WorkID AND FK_Node IN (" + DataType.PraseAtToInSql(town.HisNode.GroupStaNDs, true) + ") )";
                        sql += " ORDER BY FK_Emp ";

                        ps     = new Paras();
                        ps.SQL = sql;
                        ps.Add("FK_Node", town.HisNode.NodeID);
                        ps.Add("WorkID", this.WorkID);
                    }
                    else
                    {
                        return(dt);
                    }
                }

                dt = DBAccess.RunSQLReturnTable(ps);
                // 如果能够找到.
                if (dt.Rows.Count >= 1)
                {
                    if (dt.Rows.Count == 1)
                    {
                        /*如果人员只有一个的情况,说明他可能要 */
                    }
                    return(dt);
                }
            }

            /* 如果执行节点 与 接受节点岗位集合一致 */
            if (this.currWn.HisNode.GroupStaNDs == town.HisNode.GroupStaNDs)
            {
                /* 说明,就把当前人员做为下一个节点处理人。*/
                DataRow dr = dt.NewRow();
                dr[0] = WebUser.No;
                dt.Rows.Add(dr);
                return(dt);
            }

            /* 如果执行节点 与 接受节点岗位集合不一致 */
            if (this.currWn.HisNode.GroupStaNDs != town.HisNode.GroupStaNDs)
            {
                /* 没有查询到的情况下, 先按照本部门计算。*/
                if (flowAppType == FlowAppType.Normal)
                {
                    if (BP.WF.Glo.OSModel == OSModel.BPM)
                    {
                        sql = "SELECT FK_Emp as No FROM Port_DeptEmpStation A, WF_NodeStation B         WHERE A.FK_Station=B.FK_Station AND B.FK_Node=" + dbStr + "FK_Node AND A.FK_Dept=" + dbStr + "FK_Dept";
                    }
                    else
                    {
                        sql = "SELECT FK_Emp as No FROM Port_EmpStation A, WF_NodeStation B, Port_Emp C WHERE A.FK_Station=B.FK_Station AND A.FK_Emp=C.No  AND B.FK_Node=" + dbStr + "FK_Node AND C.FK_Dept=" + dbStr + "FK_Dept";
                    }
                    ps     = new Paras();
                    ps.SQL = sql;
                    ps.Add("FK_Node", town.HisNode.NodeID);
                    ps.Add("FK_Dept", empDept);
                }

                if (flowAppType == FlowAppType.PRJ)
                {
                    sql = "SELECT  FK_Emp  FROM Prj_EmpPrjStation WHERE FK_Prj=" + dbStr + "FK_Prj1 AND FK_Station IN (SELECT FK_Station FROM WF_NodeStation WHERE FK_Node=" + dbStr + "FK_Node)"
                          + " AND  FK_Prj=" + dbStr + "FK_Prj2 ";
                    sql += " ORDER BY FK_Emp ";

                    ps     = new Paras();
                    ps.SQL = sql;
                    ps.Add("FK_Prj1", prjNo);
                    ps.Add("FK_Node", town.HisNode.NodeID);
                    ps.Add("FK_Prj2", prjNo);
                    dt = DBAccess.RunSQLReturnTable(ps);
                    if (dt.Rows.Count == 0)
                    {
                        /* 如果项目组里没有工作人员就提交到公共部门里去找。 */
                        sql = "SELECT No FROM Port_Emp WHERE NO IN "
                              + "(SELECT  FK_Emp  FROM " + BP.WF.Glo.EmpStation + " WHERE FK_Station IN (SELECT FK_Station FROM WF_NodeStation WHERE FK_Node=" + dbStr + "FK_Node))"
                              + " AND  NO IN "
                              + "(SELECT FK_Emp FROM Port_EmpDept WHERE FK_Dept =" + dbStr + "FK_Dept)";

                        sql += " ORDER BY No ";

                        ps     = new Paras();
                        ps.SQL = sql;
                        ps.Add("FK_Node", town.HisNode.NodeID);
                        ps.Add("FK_Dept", empDept);
                        //  dt = DBAccess.RunSQLReturnTable(ps);
                    }
                    else
                    {
                        return(dt);
                    }
                }

                dt = DBAccess.RunSQLReturnTable(ps);
                if (dt.Rows.Count == 0)
                {
                    NodeStations nextStations = town.HisNode.NodeStations;
                    if (nextStations.Count == 0)
                    {
                        throw new Exception("节点没有岗位:" + town.HisNode.NodeID + "  " + town.HisNode.Name);
                    }
                }
                else
                {
                    bool isInit = false;
                    foreach (DataRow dr in dt.Rows)
                    {
                        if (dr[0].ToString() == BP.Web.WebUser.No)
                        {
                            /* 如果岗位分组不一样,并且结果集合里还有当前的人员,就说明了出现了当前操作员,拥有本节点上的岗位也拥有下一个节点的工作岗位
                             * 导致:节点的分组不同,传递到同一个人身上。 */
                            isInit = true;
                        }
                    }

#warning edit by peng, 用来确定不同岗位集合的传递包含同一个人的处理方式。


                    //  if (isInit == false || isInit == true)
                    return(dt);
                }
            }

            /*这里去掉了向下级别寻找的算法. */


            /* 没有查询到的情况下, 按照最大匹配数 提高一个级别计算,递归算法未完成。
             * 因为:以上已经做的岗位的判断,就没有必要在判断其它类型的节点处理了。
             * */
            string nowDeptID = empDept.Clone() as string;
            while (true)
            {
                BP.Port.Dept myDept = new BP.Port.Dept(nowDeptID);
                nowDeptID = myDept.ParentNo;
                if (nowDeptID == "-1" || nowDeptID.ToString() == "0")
                {
                    break; /*一直找到了最高级仍然没有发现,就跳出来循环从当前操作员人部门向下找。*/
                    throw new Exception("@按岗位计算没有找到(" + town.HisNode.Name + ")接受人.");
                }

                //检查指定的部门下面是否有该人员.
                DataTable mydtTemp = this.Func_GenerWorkerList_DiGui(nowDeptID, empNo);
                if (mydtTemp == null)
                {
                    /*如果父亲级没有,就找父级的平级. */
                    BP.Port.Depts myDepts = new BP.Port.Depts();
                    myDepts.Retrieve(BP.Port.DeptAttr.ParentNo, myDept.ParentNo);
                    foreach (BP.Port.Dept item in myDepts)
                    {
                        if (item.No == nowDeptID)
                        {
                            continue;
                        }
                        mydtTemp = this.Func_GenerWorkerList_DiGui(item.No, empNo);
                        if (mydtTemp == null)
                        {
                            continue;
                        }
                        else
                        {
                            return(mydtTemp);
                        }
                    }

                    continue; /*如果平级也没有,就continue.*/
                }
                else
                {
                    return(mydtTemp);
                }
            }

            /*如果向上找没有找到,就考虑从本级部门上向下找。 */
            nowDeptID = empDept.Clone() as string;
            BP.Port.Depts subDepts = new BP.Port.Depts(nowDeptID);

            //递归出来子部门下有该岗位的人员
            DataTable mydt = Func_GenerWorkerList_DiGui_ByDepts(subDepts, empNo);
            if (mydt == null)
            {
                throw new Exception("@按岗位计算没有找到(" + town.HisNode.Name + ")接受人.");
            }
            return(mydt);

            #endregion   照岗位来执行。
        }