/// <summary> /// 执行 /// </summary> /// <returns>返回执行结果</returns> public override object Do() { string sql = "SELECT * FROM WF_GENERWORKFLOW WHERE WFState=2 "; DataTable dt = DBAccess.RunSQLReturnTable(sql); string msg = ""; foreach (DataRow dr in dt.Rows) { Int64 workid = Int64.Parse(dr["WorkID"].ToString()); string todoEmps = dr["TODOEMPS"].ToString(); string nodeID = dr["FK_NODE"].ToString(); GenerWorkerLists gwls = new GenerWorkerLists(); gwls.Retrieve(GenerWorkerListAttr.WorkID, workid, GenerWorkerListAttr.IsPass, 0); foreach (GenerWorkerList gwl in gwls) { if (todoEmps.Contains(gwl.FK_Emp + ",") == false) { if (nodeID.ToString().EndsWith("01") == true) { continue; } GenerWorkFlow gwf = new GenerWorkFlow(workid); msg += "<br>@流程:" + gwf.FlowName + "节点:" + gwf.FK_Node + "," + gwf.NodeName + " workid: " + workid + "title:" + gwf.Title + " todoEmps:" + gwf.TodoEmps; msg += "不包含:" + gwl.FK_Emp + "," + gwl.FK_EmpText; gwf.TodoEmps += gwl.FK_Emp + "," + gwl.FK_EmpText + ";"; gwf.Update(); } } } return(msg); }
public void DealWithFHLFlow(ArrayList al, GenerWorkerLists wlSeles) { GenerWorkerLists wls = new GenerWorkerLists(); wls.Retrieve(GenerWorkerListAttr.FID, this.FID); DBAccess.RunSQL("UPDATE WF_GenerWorkerlist SET IsEnable=0 WHERE FID=" + this.FID); string emps = ""; string myemp = ""; foreach (Object obj in al) { emps += obj.ToString() + ","; myemp = obj.ToString(); DBAccess.RunSQL("UPDATE WF_GenerWorkerlist SET IsEnable=1 WHERE FID=" + this.FID + " AND FK_Emp='" + obj + "'"); } //BP.WF.Node nd = new BP.WF.Node(NodeID); //Work wk = nd.HisWork; //wk.OID = this.WorkID; //wk.Retrieve(); //wk.Emps = emps; //wk.Update(); }
/// <summary> /// 执行修复 /// </summary> /// <returns></returns> public string DoRepare() { if (this.DoSelfTestInfo() == "没有发现异常。") { return("没有发现异常。"); } string sql = "SELECT FK_Node FROM WF_GenerWorkerlist WHERE WORKID='" + this.WorkID + "' ORDER BY FK_Node desc"; DataTable dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count == 0) { /*如果是开始工作节点,就删除它。*/ WorkFlow wf = new WorkFlow(new Flow(this.FK_Flow), this.WorkID, this.FID); wf.DoDeleteWorkFlowByReal(true); return("此流程是因为发起工作失败被系统删除。"); } int FK_Node = int.Parse(dt.Rows[0][0].ToString()); Node nd = new Node(FK_Node); if (nd.IsStartNode) { /*如果是开始工作节点,就删除它。*/ WorkFlow wf = new WorkFlow(new Flow(this.FK_Flow), this.WorkID, this.FID); wf.DoDeleteWorkFlowByReal(true); return("此流程是因为发起工作失败被系统删除。"); } this.FK_Node = nd.NodeID; this.NodeName = nd.Name; this.Update(); string str = ""; GenerWorkerLists wls = new GenerWorkerLists(); wls.Retrieve(GenerWorkerListAttr.FK_Node, FK_Node, GenerWorkerListAttr.WorkID, this.WorkID); foreach (GenerWorkerList wl in wls) { str += wl.FK_Emp + wl.FK_EmpText + ","; } return("此流程是因为[" + nd.Name + "]工作发送失败被回滚到当前位置,请转告[" + str + "]流程修复成功。"); }
/// <summary> /// 绑定 /// </summary> public void BindLB() { // 当前用的员工权限。 string sql = ""; // sql = " SELECT No,Name FROM Port_Emp WHERE NO IN (SELECT FK_EMP FROM Port_EmpDept WHERE FK_Dept IN (SELECT FK_Dept FROM Port_EmpDept WHERE fk_emp='" + BP.Web.WebUser.No + "') ) or FK_Dept Like '" + BP.Web.WebUser.FK_Dept + "%'"; sql = " SELECT No,Name FROM Port_Emp WHERE FK_Dept='" + this.FK_Dept + "'"; DataTable dt = DBAccess.RunSQLReturnTable(sql); int colIdx = -1; this.Top.AddTable(); foreach (DataRow dr in dt.Rows) { if (dr["No"].ToString() == WebUser.No) { continue; } colIdx++; if (colIdx == 0) { this.Top.AddTR(); } string no = dr["No"].ToString(); string name = dr["Name"].ToString(); RadioButton rb = new RadioButton(); rb.ID = "RB_" + no; rb.Text = no + " " + name; rb.GroupName = "s"; this.Top.AddTD(rb); if (colIdx == 2) { colIdx = -1; this.Top.AddTREnd(); } } this.Top.AddTableEnd(); // 已经非配或者自动分配的任务。 GenerWorkerLists wls = new GenerWorkerLists(); wls.Retrieve(GenerWorkerListAttr.WorkID, this.WorkID, GenerWorkerListAttr.IsEnable, 1, GenerWorkerListAttr.IsPass, 0); int nodeID = 0; foreach (GenerWorkerList wl in wls) { RadioButton cb = this.Top.GetRadioButtonByID("RB_" + wl.FK_Emp); if (cb != null) { cb.Checked = true; } nodeID = wl.FK_Node; } TextBox tb = new TextBox(); tb.TextMode = TextBoxMode.MultiLine; tb.Rows = 10; tb.Columns = 70; tb.ID = "TB_Doc"; BP.WF.Node nd = new BP.WF.Node(nodeID); if (nd.FocusField != "") { Work wk = nd.HisWork; wk.OID = this.WorkID; wk.RetrieveFromDBSources(); tb.Text = wk.GetValStringByKey(nd.FocusField); } this.Pub1.Add(tb); }
/// <summary> /// 创建流程,发送分流点第1步. /// </summary> public void Step1() { // 让zhanghaicheng 登录. BP.WF.Dev2Interface.Port_Login(userNo); //创建空白工作, 发起开始节点. workid = BP.WF.Dev2Interface.Node_CreateBlankWork(fk_flow); #region 检查 创建流程后的数据是否完整 ? // "检查创建这个空白是否有数据完整?; sql = "SELECT * FROM " + fl.PTable + " WHERE OID=" + workid; DataTable dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count == 0) { throw new Exception("@发起流程出错误,不应该找不到报表数据."); } // 检查节点表单表是否有数据?; sql = "SELECT * FROM ND501 WHERE OID=" + workid; dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count == 0) { throw new Exception("@不应该在开始节点表单表中找不到数据,"); } if (dt.Rows[0]["Rec"].ToString() != WebUser.No) { throw new Exception("@记录人应该是当前人员."); } // 检查创建这个空白是否有数据完整?; sql = "SELECT * FROM WF_EmpWorks WHERE WorkID=" + workid + " AND FK_Emp='" + WebUser.No + "'"; dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count != 0) { throw new Exception("@找到当前人员的待办就是错误的."); } #endregion 检查发起流程后的数据是否完整? //开始节点:执行发送,并获取发送对象. 主线程向子线程发送. SendReturnObjs objs = BP.WF.Dev2Interface.Node_SendWork(fk_flow, workid); #region 第1步: 检查【开始节点】发送对象返回的信息是否完整? //从获取的发送对象里获取到下一个工作者. zhangyifan(张一帆)、zhoushengyu(周升雨). if (objs.VarAcceptersID != "zhangyifan,zhoushengyu,") { throw new Exception("@下一步的接受人不正确, zhangyifan,zhoushengyu, 现在是:" + objs.VarAcceptersID); } if (objs.VarToNodeID != 502) { throw new Exception("@应该是 502节点. 现在是:" + objs.VarToNodeID); } if (objs.VarWorkID != workid) { throw new Exception("@主线程的workid不应该变化:" + objs.VarWorkID); } if (objs.VarCurrNodeID != 501) { throw new Exception("@当前节点的编号不能变化:" + objs.VarCurrNodeID); } if (objs.VarTreadWorkIDs == null) { throw new Exception("@没有获取到两条子线程ID."); } if (objs.VarTreadWorkIDs.Contains(",") == false) { throw new Exception("@没有获取到两条子线程的WorkID:" + objs.VarTreadWorkIDs); } #endregion 检查【开始节点】发送对象返回的信息是否完整? #region 第2步: 检查流程引擎控制系统表是否符合预期. gwf = new GenerWorkFlow(workid); if (gwf.FK_Node != 501) { throw new Exception("@主线程向子线程发送时,主线程的FK_Node应该不变化,现在:" + gwf.FK_Node); } if (gwf.WFState != WFState.Runing) { throw new Exception("@主线程向子线程发送时,主线程的 WFState 应该 WFState.Runing :" + gwf.WFState.ToString()); } if (gwf.Starter != WebUser.No) { throw new Exception("@应该是发起人员,现在是:" + gwf.Starter); } //找出发起人的工作列表. gwl = new GenerWorkerList(workid, 501, WebUser.No); if (gwl.IsPass == true) { throw new Exception("@干流上的pass状态应该是通过,此人已经没有他的待办工作了."); } //找出子线程上的工作人员. GenerWorkFlows gwfs = new GenerWorkFlows(); gwfs.Retrieve(GenerWorkerListAttr.FID, workid); if (gwfs.Count != 2) { throw new Exception("@应该有两个流程注册,现在是:" + gwfs.Count + "个."); } //检查它们的注册数据是否完整. foreach (GenerWorkFlow item in gwfs) { if (item.Starter != WebUser.No) { throw new Exception("@当前的人员应当是发起人,现在是:" + item.Starter); } if (item.FK_Node != 502) { throw new Exception("@当前节点应当是 502 ,现在是:" + item.FK_Node); } if (item.WFState != WFState.Runing) { throw new Exception("@当前 WFState 应当是 Runing ,现在是:" + item.WFState.ToString()); } } //找出子线程工作处理人员的工作列表. GenerWorkerLists gwls = new GenerWorkerLists(); gwls.Retrieve(GenerWorkerListAttr.FID, workid); if (gwls.Count != 2) { throw new Exception("@应该在子线程上查询出来两个待办,现在只有(" + gwls.Count + ")个。"); } //检查子线程的待办完整性. foreach (GenerWorkerList item in gwls) { if (item.IsPass) { throw new Exception("@不应该是已经通过,因为他们没有处理。"); } if (item.IsEnable == false) { throw new Exception("@应该是:IsEnable "); } //if (item.Sender.Contains(WebUser.No) == false) // throw new Exception("@发送人,应该是当前人员。现在是:" + item.Sender); if (item.FK_Flow != "005") { throw new Exception("@应该是 005 现在是:" + item.FK_Flow); } if (item.FK_Node != 502) { throw new Exception("@应该是 502 现在是:" + item.FK_Node); } } //取主线程的待办工作. sql = "SELECT * FROM WF_EmpWorks WHERE WorkID=" + workid; dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count != 0) { throw new Exception("@不应当出现主线程的待办在 WF_EmpWorks 视图中. " + sql); } //取待办子线程的待办工作. sql = "SELECT * FROM WF_EmpWorks WHERE FID=" + workid; dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count != 2) { throw new Exception("@应该取出来两个子线程的 WF_EmpWorks 视图中. " + sql); } #endregion end 检查流程引擎控制系统表是否符合预期. #region 第3步: 检查【开始节点】发送节点表单-数据信息否完整? //检查节点表单表是否有数据? sql = "SELECT * FROM ND501 WHERE OID=" + workid; dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count != 1) { throw new Exception("@应该找到开始节点表单数据,但是没有。"); } if (dt.Rows[0]["Rec"].ToString() != WebUser.No) { throw new Exception("@没有向主线程开始节点表里写入Rec字段,现在是:" + dt.Rows[0]["Rec"].ToString() + "应当是:" + WebUser.No); } //检查节点表单表是否有数据,以及数据是否正确? sql = "SELECT * FROM ND502 WHERE FID=" + workid; dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count != 2) { throw new Exception("@应该在第一个子线程节点上找到两个数据。"); } foreach (DataRow dr in dt.Rows) { if (dr["Rec"].ToString() == "zhangyifan") { continue; } if (dr["Rec"].ToString() == "zhoushengyu") { continue; } throw new Exception("@子线程表单数据没有正确的写入Rec字段."); } sql = "SELECT * FROM ND5Rpt WHERE OID=" + workid; dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows[0][GERptAttr.FlowEnder].ToString() != "zhanghaicheng") { throw new Exception("@应该是 zhanghaicheng 是 FlowEnder ."); } if (dt.Rows[0][GERptAttr.FlowStarter].ToString() != "zhanghaicheng") { throw new Exception("@应该是 zhanghaicheng 是 FlowStarter ."); } if (dt.Rows[0][GERptAttr.FlowEndNode].ToString() != "502") { throw new Exception("@应该是 502 是 FlowEndNode ."); } if (int.Parse(dt.Rows[0][GERptAttr.WFState].ToString()) != (int)WFState.Runing) { throw new Exception("@应该是 WFState.Runing 是当前的状态。"); } if (int.Parse(dt.Rows[0][GERptAttr.FID].ToString()) != 0) { throw new Exception("@应该是 FID =0 "); } if (dt.Rows[0]["FK_NY"].ToString() != DataType.CurrentYearMonth) { throw new Exception("@ FK_NY 字段填充错误. "); } #endregion 检查【开始节点】发送数据信息否完整? }
/// <summary> /// 每个子线程向下发送 /// </summary> public void Step2_2() { // 让子线程中的一个人 zhoushengyu 登录, 然后执行向下发起, BP.WF.Dev2Interface.Port_Login("zhangyifan"); //获得此人的 005 的待办工作. dt = BP.WF.Dev2Interface.DB_GenerEmpWorksOfDataTable(WebUser.No, WFState.Runing, "005"); if (dt.Rows.Count == 0) { throw new Exception("@不应该获取不到它的待办数据."); } //获取子线程的workID. int threahWorkID = 0; foreach (DataRow dr in dt.Rows) { if (int.Parse(dr["FID"].ToString()) == workid) { threahWorkID = int.Parse(dr["WorkID"].ToString()); break; } } if (threahWorkID == 0) { throw new Exception("@不应当找不到它的待办。"); } // 执行 子线程向合流点发送. Hashtable ht = new Hashtable(); ht.Add("FuWuQi", 100); ht.Add("ShuMaXiangJi", 30);//把数据放里面去,让它保存到子线程的主表,以检查数据是否汇总到合流节点上。 // 执行 子线程向合流点发送. objs = BP.WF.Dev2Interface.Node_SendWork(fk_flow, threahWorkID, ht); #region 第1步: 检查发送后的变量. if (objs.VarWorkID != threahWorkID) { throw new Exception("@应当是 VarWorkID=" + threahWorkID + " ,现在是:" + objs.VarWorkID); } if (objs.VarCurrNodeID != 502) { throw new Exception("@应当是 VarCurrNodeID=502 是,现在是:" + objs.VarCurrNodeID); } if (objs.VarToNodeID != 599) { throw new Exception("@应当是 VarToNodeID= 599 是,现在是:" + objs.VarToNodeID); } if (objs.VarAcceptersID != "zhanghaicheng") { throw new Exception("@应当是 VarAcceptersID= zhanghaicheng 是,现在是:" + objs.VarAcceptersID); } #endregion 第1步: 检查发送后的变量. #region 第2步: 检查引擎控制系统表. //先检查干流数据. gwf = new GenerWorkFlow(workid); if (gwf.WFState != WFState.Runing) { throw new Exception("@应当是 Runing, 现在是:" + gwf.WFState); } if (gwf.FID != 0) { throw new Exception("@应当是 0, 现在是:" + gwf.FID); } if (gwf.FK_Node != 599) { throw new Exception("@应当是 599, 现在是:" + gwf.FK_Node); } if (gwf.Starter != "zhanghaicheng") { throw new Exception("@应当是 zhanghaicheng, 现在是:" + gwf.Starter); } // 干流的工作人员表是否有变化? GenerWorkerLists gwls = new GenerWorkerLists(); gwls.Retrieve(GenerWorkerListAttr.WorkID, workid); foreach (GenerWorkerList item in gwls) { if (item.FK_Emp != "zhanghaicheng") { throw new Exception("@应当是 zhanghaicheng, 现在是:" + item.FK_Emp); } //如果是开始节点. if (item.FK_Node == 501) { if (item.IsPass == false) { throw new Exception("@pass状态错误了,应该是已通过。"); } } //如果是结束节点. if (item.FK_Node == 599) { //检查子线程完成率. Node nd = new Node(599); if (nd.PassRate > 50) { if (item.IsPassInt != 0) { throw new Exception("@因为完成率大于 50, 现在两个都通过了,所以这合流点上也应该是通过的状态。"); } } else { if (item.IsPassInt != 0) { throw new Exception("@因为小于50,所以只要有一个通过了,主线程的zhanghaicheng 工作人员应该可以看到待办,但是没有查到。 "); } } } } //检查子线程的工作人员列表表。 gwls = new GenerWorkerLists(); gwls.Retrieve(GenerWorkerListAttr.FID, workid); if (gwls.Count != 2) { throw new Exception("@不是期望的两条子线程上的工作人员列表数据."); } foreach (GenerWorkerList item in gwls) { if (item.FK_Emp == "zhoushengyu") { if (item.IsPass == false) { throw new Exception("@此人应该是处理通过了,现在没有通过。"); } } if (item.FK_Emp == "zhangyifan") { if (item.IsPass == false) { throw new Exception("@此人应该是处理通过了,现在没有通过。"); } } } #endregion 第2步: 检查引擎控制系统表. #region 第3步: 检查 节点表单表数据. sql = "SELECT * FROM ND501 WHERE OID=" + workid; dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows[0]["Rec"].ToString() != "zhanghaicheng") { throw new Exception("@开始节点的Rec 字段写入错误。"); } //检查节点表单表是否有数据,以及数据是否正确? sql = "SELECT * FROM ND502 WHERE FID=" + workid; dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count != 2) { throw new Exception("@应该在第一个子线程节点上找到两个数据。"); } foreach (DataRow dr in dt.Rows) { if (dr["Rec"].ToString() == "zhangyifan") { continue; } if (dr["Rec"].ToString() == "zhoushengyu") { continue; } throw new Exception("@子线程表单数据没有正确的写入Rec字段."); } //检查参数是否存储到子线程的主表上了? sql = "SELECT * FROM ND502 WHERE OID=" + threahWorkID; dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count != 1) { throw new Exception("@没有找到子线程期望的数据。"); } if (dt.Rows[0]["FuWuQi"].ToString() != "100") { throw new Exception("没有存储到指定的位置."); } if (dt.Rows[0]["ShuMaXiangJi"].ToString() != "30") { throw new Exception("没有存储到指定的位置."); } // 检查汇总的明细表数据是否copy正确? sql = "SELECT * FROM ND599Dtl1 WHERE OID=" + threahWorkID; dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count != 1) { throw new Exception("@子线程的数据没有copy到汇总的明细表里."); } dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count != 1) { throw new Exception("@没有找到子线程期望的数据。"); } if (dt.Rows[0]["FuWuQi"].ToString() != "100") { throw new Exception("没有存储到指定的位置."); } if (dt.Rows[0]["ShuMaXiangJi"].ToString() != "30") { throw new Exception("没有存储到指定的位置."); } //检查报表数据是否正确? sql = "SELECT * FROM ND5Rpt WHERE OID=" + workid; dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows[0][GERptAttr.FlowEnder].ToString() != "zhanghaicheng") { throw new Exception("@应该是 zhanghaicheng 是 FlowEnder ."); } if (dt.Rows[0][GERptAttr.FlowStarter].ToString() != "zhanghaicheng") { throw new Exception("@应该是 zhanghaicheng 是 FlowStarter ."); } if (dt.Rows[0][GERptAttr.FlowEndNode].ToString() != "502") { throw new Exception("@应该是 502 是 FlowEndNode ."); } if (int.Parse(dt.Rows[0][GERptAttr.WFState].ToString()) != (int)WFState.Runing) { throw new Exception("@应该是 WFState.Runing 是 WFState ."); } if (int.Parse(dt.Rows[0][GERptAttr.FID].ToString()) != 0) { throw new Exception("@应该是 FID =0 "); } if (dt.Rows[0]["FK_NY"].ToString() != DataType.CurrentYearMonth) { throw new Exception("@ FK_NY 字段填充错误. "); } #endregion 第3步: 检查 节点表单表数据. }
/// <summary> /// 时间轴 /// </summary> /// <returns></returns> public string TimeBase_Init() { DataSet ds = new DataSet(); //获取track. DataTable dt = BP.WF.Dev2Interface.DB_GenerTrackTable(this.FK_Flow, this.WorkID, this.FID); ds.Tables.Add(dt); #region 父子流程数据存储到这里. Hashtable ht = new Hashtable(); foreach (DataRow dr in dt.Rows) { ActionType at = (ActionType)int.Parse(dr[TrackAttr.ActionType].ToString()); string tag = dr[TrackAttr.Tag].ToString(); //标识. string mypk = dr[TrackAttr.MyPK].ToString(); //主键. string msg = ""; if (at == ActionType.CallChildenFlow) { //被调用父流程吊起。 if (DataType.IsNullOrEmpty(tag) == false) { AtPara ap = new AtPara(tag); GenerWorkFlow mygwf = new GenerWorkFlow(); mygwf.WorkID = ap.GetValInt64ByKey("PWorkID"); if (mygwf.RetrieveFromDBSources() == 1) { msg = "<p>操作员:{" + dr[TrackAttr.EmpFromT].ToString() + "}在当前节点上,被父流程{" + mygwf.FlowName + "},<a target=b" + ap.GetValStrByKey("PWorkID") + " href='Track.aspx?WorkID=" + ap.GetValStrByKey("PWorkID") + "&FK_Flow=" + ap.GetValStrByKey("PFlowNo") + "' >" + msg + "</a></p>"; } else { msg = "<p>操作员:{" + dr[TrackAttr.EmpFromT].ToString() + "}在当前节点上,被父流程调用{" + mygwf.FlowName + "},但是该流程被删除了.</p>" + tag; } msg = "<a target=b" + ap.GetValStrByKey("PWorkID") + " href='Track.aspx?WorkID=" + ap.GetValStrByKey("PWorkID") + "&FK_Flow=" + ap.GetValStrByKey("PFlowNo") + "' >" + msg + "</a>"; } //放入到ht里面. ht.Add(mypk, msg); } if (at == ActionType.StartChildenFlow) { if (DataType.IsNullOrEmpty(tag) == false) { if (tag.Contains("Sub")) { tag = tag.Replace("Sub", "C"); } AtPara ap = new AtPara(tag); GenerWorkFlow mygwf = new GenerWorkFlow(); mygwf.WorkID = ap.GetValInt64ByKey("CWorkID"); if (mygwf.RetrieveFromDBSources() == 1) { msg = "<p>操作员:{" + dr[TrackAttr.EmpFromT].ToString() + "}在当前节点上调用了子流程{" + mygwf.FlowName + "}, <a target=b" + ap.GetValStrByKey("CWorkID") + " href='Track.aspx?WorkID=" + ap.GetValStrByKey("CWorkID") + "&FK_Flow=" + ap.GetValStrByKey("CFlowNo") + "' >" + msg + "</a></p>"; msg += "<p>当前子流程状态:{" + mygwf.WFStateText + "},运转到:{" + mygwf.NodeName + "},最后处理人{" + mygwf.TodoEmps + "},最后处理时间{" + mygwf.RDT + "}。</p>"; } else { msg = "<p>操作员:{" + dr[TrackAttr.EmpFromT].ToString() + "}在当前节点上调用了子流程{" + mygwf.FlowName + "},但是该流程被删除了.</p>" + tag; } } //放入到ht里面. ht.Add(mypk, msg); } } #endregion //获取 WF_GenerWorkFlow GenerWorkFlow gwf = new GenerWorkFlow(); gwf.WorkID = this.WorkID; gwf.RetrieveFromDBSources(); ds.Tables.Add(gwf.ToDataTableField("WF_GenerWorkFlow")); if (gwf.WFState != WFState.Complete) { GenerWorkerLists gwls = new GenerWorkerLists(); gwls.Retrieve(GenerWorkerListAttr.WorkID, this.WorkID); ds.Tables.Add(gwls.ToDataTableField("WF_GenerWorkerList")); } //把节点审核配置信息. FrmWorkCheck fwc = new FrmWorkCheck(gwf.FK_Node); ds.Tables.Add(fwc.ToDataTableField("FrmWorkCheck")); //返回结果. return(BP.Tools.Json.DataSetToJson(ds, false)); }
/// <summary> /// 创建流程,发送分流点第1步. /// </summary> public void Step1() { // 让zhoupeng 登录. BP.WF.Dev2Interface.Port_Login(userNo); //创建空白工作, 发起开始节点. workid = BP.WF.Dev2Interface.Node_CreateBlankWork(fk_flow, null, null, WebUser.No, null, 0, null); #region 检查 创建流程后的数据是否完整 ? // "检查创建这个空白是否有数据完整?; sql = "SELECT * FROM " + fl.PTable + " WHERE OID=" + workid; DataTable dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count == 0) { throw new Exception("@发起流程出错误,不应该找不到报表数据."); } // 检查节点表单表是否有数据?; sql = "SELECT * FROM ND901 WHERE OID=" + workid; dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count == 0) { throw new Exception("@不应该在开始节点表单表中找不到数据,"); } if (dt.Rows[0]["Rec"].ToString() != WebUser.No) { throw new Exception("@记录人应该是当前人员."); } // 检查创建这个空白是否有数据完整?; sql = "SELECT * FROM WF_EmpWorks WHERE WorkID=" + workid + " AND FK_Emp='" + WebUser.No + "'"; dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count != 0) { throw new Exception("@找到当前人员的待办就是错误的."); } #endregion 检查发起流程后的数据是否完整? //组织参数. Hashtable ht = new Hashtable(); ht.Add("KeFuBu", 1); ht.Add("ShiChangBu", 1); ht.Add("YanFaBu", 1); //开始节点:执行发送,并获取发送对象. 主线程向子线程发送. SendReturnObjs objs = BP.WF.Dev2Interface.Node_SendWork(fk_flow, workid, ht); #region 第1步: 检查【开始节点】发送对象返回的信息是否完整? //从获取的发送对象里获取到下一个工作者: zhanghaicheng,qifenglin,guoxiangbin . if (objs.VarAcceptersID != "zhanghaicheng,qifenglin,guoxiangbin,") { throw new Exception("@下一步的接受人不正确, zhanghaicheng,qifenglin,guoxiangbin, .现在是:" + objs.VarAcceptersID); } if (objs.VarToNodeID != 901) { throw new Exception("@应该是 901节点. 现在是:" + objs.VarToNodeID); } if (objs.VarWorkID != workid) { throw new Exception("@主线程的workid不应该变化:" + objs.VarWorkID); } if (objs.VarCurrNodeID != 901) { throw new Exception("@当前节点的编号不能变化:" + objs.VarCurrNodeID); } if (objs.VarTreadWorkIDs == null) { throw new Exception("@没有获取到三条子线程ID."); } if (objs.VarTreadWorkIDs.Contains(",") == false) { throw new Exception("@没有获取到三条子线程的WorkID:" + objs.VarTreadWorkIDs); } #endregion 检查【开始节点】发送对象返回的信息是否完整? #region 第2步: 检查流程引擎控制系统表是否符合预期. gwf = new GenerWorkFlow(workid); if (gwf.FK_Node != 901) { throw new Exception("@主线程向子线程发送时,主线程的FK_Node应该不变化,现在:" + gwf.FK_Node); } if (gwf.WFState != WFState.Runing) { throw new Exception("@主线程向子线程发送时,主线程的 WFState 应该 WFState.Runing :" + gwf.WFState.ToString()); } if (gwf.Starter != WebUser.No) { throw new Exception("@应该是发起人员,现在是:" + gwf.Starter); } //找出发起人的工作列表. gwl = new GenerWorkerList(workid, 901, WebUser.No); if (gwl.IsPass == true) { throw new Exception("@干流上的pass状态应该是通过,此人已经没有他的待办工作了."); } //找出子线程上的工作人员. GenerWorkFlows gwfs = new GenerWorkFlows(); gwfs.Retrieve(GenerWorkerListAttr.FID, workid); if (gwfs.Count != 3) { throw new Exception("@应该有两个流程注册,现在是:" + gwfs.Count + "个."); } //检查它们的注册数据是否完整. foreach (GenerWorkFlow item in gwfs) { if (item.Starter != WebUser.No) { throw new Exception("@当前的人员应当是发起人,现在是:" + item.Starter); } //Node nd = new Node(item.FK_Node); //if (nd.iss //if (item.FK_Node == 901) // throw new Exception("@当前节点应当是 902 ,现在是:" + item.FK_Node); if (item.WFState != WFState.Runing) { throw new Exception("@当前 WFState 应当是 Runing ,现在是:" + item.WFState.ToString()); } } //找出子线程工作处理人员的工作列表. GenerWorkerLists gwls = new GenerWorkerLists(); gwls.Retrieve(GenerWorkerListAttr.FID, workid); if (gwls.Count != 3) { throw new Exception("@应该在子线程上查询出来 3 个待办,现在只有(" + gwls.Count + ")个。"); } //检查子线程的待办完整性. foreach (GenerWorkerList item in gwls) { if (item.IsPass) { throw new Exception("@不应该是已经通过,因为他们没有处理。"); } if (item.IsEnable == false) { throw new Exception("@应该是:IsEnable "); } if (item.Sender.Contains(WebUser.No) == false) { throw new Exception("@发送人,应该是当前人员。现在是:" + item.Sender); } if (item.FK_Flow != "009") { throw new Exception("@应该是 009 现在是:" + item.FK_Flow); } //if (item.FK_Node != 902) // throw new Exception("@应该是 902 现在是:" + item.FK_Node); } //取主线程的待办工作. sql = "SELECT * FROM WF_EmpWorks WHERE WorkID=" + workid; dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count != 0) { throw new Exception("@不应当出现主线程的待办在 WF_EmpWorks 视图中. " + sql); } //取待办子线程的待办工作. sql = "SELECT * FROM WF_EmpWorks WHERE FID=" + workid; dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count != 3) { throw new Exception("@应该取出来两个子线程的 WF_EmpWorks 视图中. " + sql); } #endregion end 检查流程引擎控制系统表是否符合预期. #region 第3步: 检查【开始节点】发送节点表单-数据信息否完整? //检查节点表单表是否有数据? sql = "SELECT * FROM ND901 WHERE OID=" + workid; dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count != 1) { throw new Exception("@应该找到开始节点表单数据,但是没有。"); } if (dt.Rows[0]["Rec"].ToString() != WebUser.No) { throw new Exception("@没有向主线程开始节点表里写入Rec字段,现在是:" + dt.Rows[0]["Rec"].ToString() + "应当是:" + WebUser.No); } //找出子线程工作处理人员的工作列表. gwls = new GenerWorkerLists(); gwls.Retrieve(GenerWorkerListAttr.FID, workid); //检查子线程节点数据表是否正确。 foreach (GenerWorkerList item in gwls) { sql = "SELECT * FROM ND" + item.FK_Node + " WHERE OID=" + item.WorkID; dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count != 1) { throw new Exception("@不应该发现不到子线程节点数据。"); } foreach (DataColumn dc in dt.Columns) { string val = dt.Rows[0][dc.ColumnName].ToString(); switch (dc.ColumnName) { case WorkAttr.FID: if (val != workid.ToString()) { throw new Exception("@不应当不等于workid."); } break; case WorkAttr.Rec: if (val != item.FK_Emp) { throw new Exception("@不应当不等于:" + item.FK_Emp); } break; case WorkAttr.MyNum: if (string.IsNullOrEmpty(val)) { throw new Exception("@不应当为空:" + dc.ColumnName); } break; case WorkAttr.RDT: if (string.IsNullOrEmpty(val)) { throw new Exception("@ RDT 不应当为空:" + dc.ColumnName); } break; case WorkAttr.CDT: if (string.IsNullOrEmpty(val)) { throw new Exception("@ CDT 不应当为空:" + dc.ColumnName); } break; case WorkAttr.Emps: if (string.IsNullOrEmpty(val) || val.Contains(WebUser.No) == false) { throw new Exception("@ Emps 不应当为空,或者不包含发起人。"); } break; default: break; } //结束列的col判断。 } } // 检查报表数据是否完整。 sql = "SELECT * FROM ND9Rpt WHERE OID=" + workid; dt = DBAccess.RunSQLReturnTable(sql); foreach (DataColumn dc in dt.Rows) { string val = (string)dt.Rows[0][dc.ColumnName]; switch (dc.ColumnName) { case GERptAttr.FID: if (int.Parse(val) != 0) { throw new Exception("@应该是 FID =0 "); } break; case GERptAttr.FK_Dept: if (val != WebUser.FK_Dept) { throw new Exception("@ FK_Dept 字段填充错误,应当是:" + WebUser.FK_Dept + ",现在是:" + val); } break; case GERptAttr.FK_NY: if (val != DataType.CurrentYearMonth) { throw new Exception("@ FK_NY 字段填充错误. "); } break; case GERptAttr.FlowDaySpan: if (val != "0") { throw new Exception("@ FlowDaySpan 应当是 0 . "); } break; case GERptAttr.FlowEmps: if (val.Contains(WebUser.No) == false) { throw new Exception("@ 应该包含 zhoupeng , 现在是: " + val); } break; case GERptAttr.FlowEnder: if (val != "zhoupeng") { throw new Exception("@应该是 zhoupeng 是 FlowEnder ."); } break; case GERptAttr.FlowEnderRDT: break; case GERptAttr.FlowEndNode: if (val != "901") { throw new Exception("@应该是 901 是 FlowEndNode ."); } break; case GERptAttr.FlowStarter: if (val != "zhoupeng") { throw new Exception("@应该是 zhoupeng 是 FlowStarter ."); } break; case GERptAttr.MyNum: if (val != "1") { throw new Exception("@ MyNum 应当是1 . "); } break; case GERptAttr.PFlowNo: if (val != "") { throw new Exception("@ PFlowNo 应当是 '' 现在是:" + val); } break; case GERptAttr.PWorkID: if (val != "0") { throw new Exception("@ PWorkID 应当是 '0' 现在是:" + val); } break; case GERptAttr.Title: if (string.IsNullOrEmpty(val)) { throw new Exception("@ Title 不应当是空 " + val); } break; case GERptAttr.WFState: if (int.Parse(val) != (int)WFState.Runing) { throw new Exception("@应该是 WFState.Runing 是当前的状态。"); } break; default: break; } } #endregion 检查【开始节点】发送数据信息否完整? }
/// <summary> /// 执行 /// </summary> /// <returns>返回执行结果</returns> public override object Do() { #region 找到要逾期的数据. DataTable generTab = null; string sql = "SELECT a.FK_Flow,a.WorkID,a.Title,a.FK_Node,a.SDTOfNode,a.Starter,a.TodoEmps "; sql += "FROM WF_GenerWorkFlow a, WF_Node b"; sql += " WHERE a.SDTOfNode<='" + DataType.CurrentDataTime + "' "; sql += " AND WFState=2 and b.OutTimeDeal!=0"; sql += " AND a.FK_Node=b.NodeID"; generTab = DBAccess.RunSQLReturnTable(sql); #endregion 找到要逾期的数据. // 遍历循环,逾期表进行处理. string msg = ""; string info = ""; foreach (DataRow row in generTab.Rows) { string fk_flow = row["FK_Flow"] + ""; int fk_node = int.Parse(row["FK_Node"] + ""); long workid = long.Parse(row["WorkID"] + ""); string title = row["Title"] + ""; string compleateTime = row["SDTOfNode"] + ""; string starter = row["Starter"] + ""; GenerWorkerLists gwls = new GenerWorkerLists(); gwls.Retrieve(GenerWorkerListAttr.WorkID, workid, GenerWorkerListAttr.FK_Node, fk_node); bool isLogin = false; foreach (GenerWorkerList item in gwls) { if (item.IsEnable == false) { continue; } BP.Port.Emp emp = new Emp(item.FK_Emp); BP.Web.WebUser.SignInOfGener(emp); isLogin = true; } if (isLogin == false) { BP.Port.Emp emp = new Emp("admin"); BP.Web.WebUser.SignInOfGener(emp); } try { Node node = new Node(fk_node); if (node.IsStartNode) { continue; } //获得该节点的处理内容. string doOutTime = node.GetValStrByKey(NodeAttr.DoOutTime); switch (node.HisOutTimeDeal) { case OutTimeDeal.None: //逾期不处理. continue; case OutTimeDeal.AutoJumpToSpecNode: //跳转到指定的节点. try { //if (doOutTime.Contains(",") == false) // throw new Exception("@系统设置错误,不符合设置规范,格式为: NodeID,EmpNo 现在设置的为:"+doOutTime); int jumpNode = int.Parse(doOutTime); Node jumpToNode = new Node(jumpNode); //设置默认同意. BP.WF.Dev2Interface.WriteTrackWorkCheck(jumpToNode.FK_Flow, node.NodeID, workid, 0, "同意(预期自动审批)", null); //执行发送. info = BP.WF.Dev2Interface.Node_SendWork(fk_flow, workid, null, null, jumpToNode.NodeID, null).ToMsgOfText(); // info = BP.WF.Dev2Interface.Flow_Schedule(workid, jumpToNode.NodeID, emp.No); msg = "流程 '" + node.FlowName + "',标题: '" + title + "'的应该完成时间为'" + compleateTime + "',当前节点'" + node.Name + "'超时处理规则为'自动跳转'," + info; SetText(msg); BP.DA.Log.DefaultLogWriteLine(LogType.Info, msg); } catch (Exception ex) { msg = "流程 '" + node.FlowName + "',WorkID=" + workid + ",标题: '" + title + "'的应该完成时间为'" + compleateTime + "',当前节点'" + node.Name + "'超时处理规则为'自动跳转',跳转异常:" + ex.Message; SetText(msg); BP.DA.Log.DefaultLogWriteLine(LogType.Error, msg); } break; case OutTimeDeal.AutoShiftToSpecUser: //走动移交给. // 判断当前的处理人是否是. Emp empShift = new Emp(doOutTime); try { BP.WF.Dev2Interface.Node_Shift(fk_flow, fk_node, workid, 0, empShift.No, "流程节点已经逾期,系统自动移交"); msg = "流程 '" + node.FlowName + "',标题: '" + title + "'的应该完成时间为'" + compleateTime + "',当前节点'" + node.Name + "'超时处理规则为'移交到指定的人',已经自动移交给'" + empShift.Name + "."; SetText(msg); BP.DA.Log.DefaultLogWriteLine(LogType.Info, msg); } catch (Exception ex) { msg = "流程 '" + node.FlowName + "' ,标题:'" + title + "'的应该完成时间为'" + compleateTime + "',当前节点'" + node.Name + "'超时处理规则为'移交到指定的人',移交异常:" + ex.Message; SetText(msg); BP.DA.Log.DefaultLogWriteLine(LogType.Error, msg); } break; case OutTimeDeal.AutoTurntoNextStep: try { GenerWorkerList workerList = new GenerWorkerList(); workerList.RetrieveByAttrAnd(GenerWorkerListAttr.WorkID, workid, GenerWorkFlowAttr.FK_Node, fk_node); BP.Web.WebUser.SignInOfGener(workerList.HisEmp); WorkNode firstwn = new WorkNode(workid, fk_node); string sendIfo = firstwn.NodeSend().ToMsgOfText(); msg = "流程 '" + node.FlowName + "',标题: '" + title + "'的应该完成时间为'" + compleateTime + "',当前节点'" + node.Name + "'超时处理规则为'自动发送到下一节点',发送消息为:" + sendIfo; SetText(msg); BP.DA.Log.DefaultLogWriteLine(LogType.Info, msg); } catch (Exception ex) { msg = "流程 '" + node.FlowName + "',标题: '" + title + "'的应该完成时间为'" + compleateTime + "',当前节点'" + node.Name + "'超时处理规则为'自动发送到下一节点',发送异常:" + ex.Message; SetText(msg); BP.DA.Log.DefaultLogWriteLine(LogType.Error, msg); } break; case OutTimeDeal.DeleteFlow: info = BP.WF.Dev2Interface.Flow_DoDeleteFlowByReal(fk_flow, workid, true); msg = "流程 '" + node.FlowName + "',标题: '" + title + "'的应该完成时间为'" + compleateTime + "',当前节点'" + node.Name + "'超时处理规则为'删除流程'," + info; SetText(msg); BP.DA.Log.DefaultLogWriteLine(LogType.Info, msg); break; case OutTimeDeal.RunSQL: try { BP.WF.Work wk = node.HisWork; wk.OID = workid; wk.Retrieve(); doOutTime = BP.WF.Glo.DealExp(doOutTime, wk, null); //替换字符串 doOutTime.Replace("@OID", workid + ""); doOutTime.Replace("@FK_Flow", fk_flow); doOutTime.Replace("@FK_Node", fk_node.ToString()); doOutTime.Replace("@Starter", starter); if (doOutTime.Contains("@")) { msg = "流程 '" + node.FlowName + "',标题: '" + title + "'的应该完成时间为'" + compleateTime + "',当前节点'" + node.Name + "'超时处理规则为'执行SQL'.有未替换的SQL变量."; SetText(msg); BP.DA.Log.DefaultLogWriteLine(LogType.Info, msg); break; } //执行sql. DBAccess.RunSQL(doOutTime); } catch (Exception ex) { msg = "流程 '" + node.FlowName + "',标题: '" + title + "'的应该完成时间为'" + compleateTime + "',当前节点'" + node.Name + "'超时处理规则为'执行SQL'.运行SQL出现异常:" + ex.Message; SetText(msg); BP.DA.Log.DefaultLogWriteLine(LogType.Error, msg); } break; case OutTimeDeal.SendMsgToSpecUser: try { Emp myemp = new Emp(doOutTime); bool boo = BP.WF.Dev2Interface.WriteToSMS(myemp.No, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "系统发送逾期消息", "您的流程:'" + title + "'的完成时间应该为'" + compleateTime + "',流程已经逾期,请及时处理!", "系统消息"); if (boo) { msg = "'" + title + "'逾期消息已经发送给:'" + myemp.Name + "'"; } else { msg = "'" + title + "'逾期消息发送未成功,发送人为:'" + myemp.Name + "'"; } SetText(msg); BP.DA.Log.DefaultLogWriteLine(LogType.Info, msg); } catch (Exception ex) { msg = "流程 '" + node.FlowName + "',标题: '" + title + "'的应该完成时间为'" + compleateTime + "',当前节点'" + node.Name + "'超时处理规则为'执行SQL'.运行SQL出现异常:" + ex.Message; SetText(msg); BP.DA.Log.DefaultLogWriteLine(LogType.Error, msg); } break; default: msg = "流程 '" + node.FlowName + "',标题: '" + title + "'的应该完成时间为'" + compleateTime + "',当前节点'" + node.Name + "'没有找到相应的超时处理规则."; SetText(msg); BP.DA.Log.DefaultLogWriteLine(LogType.Error, msg); break; } } catch (Exception ex) { SetText("流程逾期出现异常:" + ex.Message); BP.DA.Log.DefaultLogWriteLine(LogType.Error, ex.ToString()); } } return(generInfo); }
/// <summary> /// 绑定 /// </summary> public void BindLB() { // 当前用的员工权限。 string sql = ""; // sql = " SELECT No,Name FROM Port_Emp WHERE NO IN (SELECT FK_EMP FROM Port_EmpDept WHERE FK_Dept IN (SELECT FK_Dept FROM Port_EmpDept WHERE fk_emp='" + BP.Web.WebUser.No + "') ) or FK_Dept Like '" + BP.Web.WebUser.FK_Dept + "%'"; sql = " SELECT No,Name FROM Port_Emp WHERE FK_Dept='" + this.FK_Dept + "'"; DataTable dt = DBAccess.RunSQLReturnTable(sql); int colIdx = -1; this.Top.AddTable("style='border:0px;'"); foreach (DataRow dr in dt.Rows) { if (dr["No"].ToString() == WebUser.No) { continue; } colIdx++; if (colIdx == 0) { this.Top.AddTR(); } string no = dr["No"].ToString(); string name = dr["Name"].ToString(); RadioButton rb = new RadioButton(); rb.ID = "RB_" + no; rb.Text = no + " " + name; rb.GroupName = "s"; this.Top.AddTD("style='border:0px;'", rb); if (colIdx == 2) { colIdx = -1; this.Top.AddTREnd(); } } this.Top.AddTableEnd(); // 已经非配或者自动分配的任务。 GenerWorkerLists wls = new GenerWorkerLists(); wls.Retrieve(GenerWorkerListAttr.WorkID, this.WorkID, GenerWorkerListAttr.IsEnable, 1, GenerWorkerListAttr.IsPass, 0); int nodeID = 0; foreach (GenerWorkerList wl in wls) { RadioButton cb = this.Top.GetRadioButtonByID("RB_" + wl.FK_Emp); if (cb != null) { cb.Checked = true; } nodeID = wl.FK_Node; } TextBox tb = new TextBox(); tb.TextMode = TextBoxMode.MultiLine; tb.Rows = 10; tb.Columns = 70; tb.ID = "TB_Doc"; BP.WF.Node nd = new BP.WF.Node(nodeID); if (nd.FocusField != "") { tb.Text = this.Request.QueryString["Info"]; //Work wk = nd.HisWork; //wk.OID = this.WorkID; //wk.RetrieveFromDBSources(); //tb.Text = wk.GetValStringByKey(nd.FocusField); } this.Top.Add(tb); //新增 Label lb = new Label(); lb.Text = "<div style='float:left;display:block;width:100%'><a href=javascript:TBHelp('Forward_Doc','" + "ND" + FK_Node + "'" + ")><img src='" + BP.WF.Glo.CCFlowAppPath + "WF/Img/Emps.gif' align='middle' border=0 />选择词汇</a> </div>"; this.Top.Add(lb); }
/// <summary> /// 让子线程中的一个人 zhoushengyu 登录, 然后执行向下发起. /// 检查业务逻辑是否正确? /// </summary> public void Step2_1() { //子线程中的接受人员, 分别是 zhanghaicheng,qifenglin,guoxiangbin // 让子线程中的一个人 zhanghaicheng 登录, 然后执行向下发起, BP.WF.Dev2Interface.Port_Login("zhanghaicheng"); //获得此人的 009 的待办工作. dt = BP.WF.Dev2Interface.DB_GenerEmpWorksOfDataTable(WebUser.No, WFState.Runing, "009"); if (dt.Rows.Count == 0) { throw new Exception("@不应该获取不到它的待办数据."); } //获取子线程的workID. int threahWorkID = 0; foreach (DataRow dr in dt.Rows) { if (int.Parse(dr["FID"].ToString()) == workid) { threahWorkID = int.Parse(dr["WorkID"].ToString()); break; } } if (threahWorkID == 0) { throw new Exception("@不应当找不到它的待办。"); } // 执行 子线程向合流点发送. Hashtable ht = new Hashtable(); ht.Add("XianYouRenShu", 90); ht.Add("XinZengRenShu", 20);//把数据放里面去,让它保存到子线程的主表,以检查数据是否汇总到合流节点上。 objs = BP.WF.Dev2Interface.Node_SendWork(fk_flow, threahWorkID, ht); #region 第1步: 检查发送后的变量. if (objs.VarWorkID != threahWorkID) { throw new Exception("@应当是 VarWorkID=" + threahWorkID + " ,现在是:" + objs.VarWorkID); } if (objs.VarCurrNodeID != 902) { throw new Exception("@应当是 VarCurrNodeID=902 是,现在是:" + objs.VarCurrNodeID); } if (objs.VarToNodeID != 999) { throw new Exception("@应当是 VarToNodeID= 999 是,现在是:" + objs.VarToNodeID); } if (objs.VarAcceptersID != "zhoupeng") { throw new Exception("@应当是 VarAcceptersID= zhoupeng 是,现在是:" + objs.VarAcceptersID); } #endregion 第1步: 检查发送后的变量. #region 第2步: 检查引擎控制系统表. //先检查干流数据. gwf = new GenerWorkFlow(workid); if (gwf.WFState != WFState.Runing) { throw new Exception("@应当是 Runing, 现在是:" + gwf.WFState); } if (gwf.FID != 0) { throw new Exception("@应当是 0, 现在是:" + gwf.FID); } if (gwf.FK_Node != 901) { throw new Exception("@应当是 901, 现在是:" + gwf.FK_Node); } if (gwf.Starter != "zhoupeng") { throw new Exception("@应当是 zhoupeng, 现在是:" + gwf.Starter); } // 干流的工作人员表是否有变化? GenerWorkerLists gwls = new GenerWorkerLists(); gwls.Retrieve(GenerWorkerListAttr.WorkID, workid); foreach (GenerWorkerList item in gwls) { if (item.FK_Emp != "zhoupeng") { throw new Exception("@应当是 zhoupeng, 现在是:" + item.FK_Emp); } //如果是开始节点. if (item.FK_Node == 901) { if (item.IsPass == false) { throw new Exception("@pass状态错误了,应该是已通过。"); } } //如果是结束节点. if (item.FK_Node == 999) { //检查子线程完成率. Node nd = new Node(999); if (nd.PassRate > 50) { // 检查主线程数据是否正确. sql = "SELECT COUNT(*) FROM WF_EmpWorks WHERE WorkID=" + workid; if (DBAccess.RunSQLReturnValInt(sql) != 0) { throw new Exception("@因为完成率大于 50, 所以一个通过了,主线程的工作人员不能看到."); } //if (item.IsPassInt != 3) // throw new Exception("@因为完成率大于 50, 所以一个通过了,主线程的工作人员不能看到,现在是:"+item.IsPassInt); } else { if (item.IsPassInt != 0) { throw new Exception("@因为小于50,所以只要有一个通过了,主线程的zhoupeng 工作人员应该可以看到待办,但是没有查到。 "); } } } } //检查子线程的工作人员列表表 。 gwls = new GenerWorkerLists(); gwls.Retrieve(GenerWorkerListAttr.FID, workid); if (gwls.Count != 3) { throw new Exception("@不是期望的两条子线程上的工作人员列表数据."); } foreach (GenerWorkerList item in gwls) { if (item.FK_Emp == "zhanghaicheng") { if (item.IsPass == false) { throw new Exception("@此人应该是处理通过了,现在没有通过。"); } } if (item.FK_Emp == "qifenglin") { if (item.IsPass == true) { throw new Exception("@此人应该有待办,结果不符合预期。"); } } if (item.FK_Emp == "guoxiangbin") { if (item.IsPass == true) { throw new Exception("@此人应该有待办,结果不符合预期。"); } } } #endregion 第2步: 检查引擎控制系统表. #region 第3步: 检查 节点表单表数据. sql = "SELECT * FROM ND901 WHERE OID=" + workid; dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows[0]["Rec"].ToString() != "zhoupeng") { throw new Exception("@开始节点的Rec 字段写入错误。"); } ////检查节点表单表是否有数据,以及数据是否正确? //sql = "SELECT * FROM ND902 WHERE FID=" + workid; //dt = DBAccess.RunSQLReturnTable(sql); //if (dt.Rows.Count != 2) // throw new Exception("@应该在第一个子线程节点上找到两个数据"); //foreach (DataRow dr in dt.Rows) //{ // if (dr["Rec"].ToString() == "zhangyifan") // continue; // if (dr["Rec"].ToString() == "zhoushengyu") // continue; // throw new Exception("@子线程表单数据没有正确的写入Rec字段."); //} ////检查参数是否存储到子线程的主表上了? //sql = "SELECT * FROM ND902 WHERE OID=" + threahWorkID; //dt = DBAccess.RunSQLReturnTable(sql); //if (dt.Rows.Count != 1) // throw new Exception("@没有找到子线程期望的数据。"); //if (dt.Rows[0]["FuWuQi"].ToString() != "90") // throw new Exception("没有存储到指定的位置."); //if (dt.Rows[0]["ShuMaXiangJi"].ToString() != "20") // throw new Exception("没有存储到指定的位置."); //// 检查汇总的明细表数据是否copy正确? // sql = "SELECT * FROM ND999Dtl1 WHERE OID=" + threahWorkID; // dt = DBAccess.RunSQLReturnTable(sql); // if (dt.Rows.Count != 1) // throw new Exception("@子线程的数据没有copy到汇总的明细表里."); // dt = DBAccess.RunSQLReturnTable(sql); // if (dt.Rows.Count != 1) // throw new Exception("@没有找到子线程期望的数据。"); // if (dt.Rows[0]["FuWuQi"].ToString() != "90") // throw new Exception("没有存储到指定的位置."); // if (dt.Rows[0]["ShuMaXiangJi"].ToString() != "20") // throw new Exception("没有存储到指定的位置."); //检查报表数据是否正确? sql = "SELECT * FROM ND9Rpt WHERE OID=" + workid; dt = DBAccess.RunSQLReturnTable(sql); string val = dt.Rows[0][GERptAttr.FlowEnder].ToString(); //if (dt.Rows[0][GERptAttr.FlowEnder].ToString() != "zhoupeng") // throw new Exception("@应该是 zhoupeng 是 FlowEnder, 现在是:"+val); if (dt.Rows[0][GERptAttr.FlowStarter].ToString() != "zhoupeng") { throw new Exception("@应该是 zhoupeng 是 FlowStarter ."); } if (dt.Rows[0][GERptAttr.FlowEndNode].ToString() != "999") { throw new Exception("@应该是 999 是 FlowEndNode,而现在是:" + dt.Rows[0][GERptAttr.FlowEndNode].ToString()); } if (int.Parse(dt.Rows[0][GERptAttr.WFState].ToString()) != (int)WFState.Runing) { throw new Exception("@应该是 WFState.Runing 是 WFState ."); } if (int.Parse(dt.Rows[0][GERptAttr.FID].ToString()) != 0) { throw new Exception("@应该是 FID =0 "); } if (dt.Rows[0]["FK_NY"].ToString() != DataType.CurrentYearMonth) { throw new Exception("@ FK_NY 字段填充错误. "); } #endregion 第3步: 检查 节点表单表数据. }
/// <summary> /// 发送测试 /// </summary> public override void Do() { //初始化变量. fk_flow = "023"; userNo = "zhanghaicheng"; fl = new Flow(fk_flow); //执行登录. BP.WF.Dev2Interface.Port_Login(userNo); //执行第1步检查,创建工作与发送. this.workid = BP.WF.Dev2Interface.Node_CreateBlankWork(fk_flow, null, null, userNo, null); //下一步骤的接受人员定义多个. string toEmps = "zhoushengyu,zhangyifan,"; //向发送多个人. objs = BP.WF.Dev2Interface.Node_SendWork(this.fk_flow, this.workid, null, null, 0, toEmps); #region 检查发送变量是否正确? if (objs.VarAcceptersID != toEmps) { throw new Exception("@应该是接受者ID多人,现在是:" + objs.VarAcceptersID); } if (objs.VarAcceptersName != "周升雨,张一帆,") { throw new Exception("@应该是接受者Name多人,现在是:" + objs.VarAcceptersID); } if (objs.VarCurrNodeID != 2301) { throw new Exception("@当前节点应该是 2301 ,现在是:" + objs.VarCurrNodeID); } if (objs.VarToNodeID != 2302) { throw new Exception("@到达节点应该是 2302 ,现在是:" + objs.VarToNodeID); } #endregion 检查发送变量是否正确? #region 检查流程引擎表是否正确? GenerWorkFlow gwf = new GenerWorkFlow(); gwf.WorkID = this.workid; if (gwf.RetrieveFromDBSources() != 1) { throw new Exception("@丢失了流程引擎注册表数据"); } if (gwf.FK_Dept != WebUser.FK_Dept) { throw new Exception("@隶属部门错误应当是:" + WebUser.FK_Dept + ",现在是:" + gwf.FK_Dept); } if (gwf.FK_Flow != fk_flow) { throw new Exception("@流程编号错误应当是:" + fk_flow + ",现在是:" + gwf.FK_Flow); } if (gwf.FK_Node != 2302) { throw new Exception("@当前节点错误应当是:" + 2302 + ",现在是:" + gwf.FK_Node); } if (gwf.Starter != userNo) { throw new Exception("@当前 Starter 错误应当是:" + userNo + ",现在是:" + gwf.Starter); } if (gwf.StarterName != WebUser.Name) { throw new Exception("@当前 StarterName 错误应当是:" + WebUser.Name + ",现在是:" + gwf.StarterName); } if (string.IsNullOrEmpty(gwf.Title)) { throw new Exception("@ Title 错误, 不能为空. "); } GenerWorkerLists wls = new GenerWorkerLists(); wls.Retrieve(GenerWorkerListAttr.WorkID, this.workid); if (wls.Count != 3) { throw new Exception("@应当有三个数据,现在是:" + wls.Count); } foreach (GenerWorkerList wl in wls) { if (wl.FID != 0) { throw new Exception("@ FID 错误,应该是" + 0 + ",现在是:" + wl.FID); } if (wl.FK_Emp == "zhanghaicheng") { if (wl.FK_Dept1 != WebUser.FK_Dept) { throw new Exception("@部门错误,应该是" + WebUser.FK_Dept + ",现在是:" + wl.FK_Dept1); } if (wl.FK_Flow != fk_flow) { throw new Exception("@ FK_Flow 错误,应该是" + fk_flow + ",现在是:" + wl.FK_Flow); } if (wl.FK_Node != 2301) { throw new Exception("@ FK_Node 错误,应该是" + 2301 + ",现在是:" + wl.FK_Node); } if (wl.IsEnable == false) { throw new Exception("@ IsEnable 错误,应该是true,现在是:" + wl.IsEnable); } if (wl.IsRead == true) { throw new Exception("@ IsRead 错误,应该是false,现在是:" + wl.IsEnable); } if (wl.IsPass == false) { throw new Exception("@ IsPass 错误,应该是true,现在是:" + wl.IsEnable); } if (wl.Sender != WebUser.No + ",张海成") { throw new Exception("@ Sender 错误,应该是" + WebUser.No + ",张海成 ,现在是:" + wl.Sender); } } if (wl.FK_Emp == "zhoushengyu" || wl.FK_Emp == "zhangyifan") { BP.Port.Emp emp = new Port.Emp(wl.FK_Emp); if (wl.FK_Dept1 != emp.FK_Dept) { throw new Exception("@部门错误,应该是" + emp.FK_Dept + ",现在是:" + wl.FK_Dept1); } if (wl.FK_Flow != fk_flow) { throw new Exception("@ FK_Flow 错误,应该是" + fk_flow + ",现在是:" + wl.FK_Flow); } if (wl.FK_Node != 2302) { throw new Exception("@ FK_Node 错误,应该是" + 2302 + ",现在是:" + wl.FK_Node); } if (wl.IsEnable == false) { throw new Exception("@ IsEnable 错误,应该是true,现在是:" + wl.IsEnable); } if (wl.IsRead == true) { throw new Exception("@ IsRead 错误,应该是false,现在是:" + wl.IsEnable); } if (wl.IsPass == true) { throw new Exception("@ IsPass 错误,应该是false,现在是:" + wl.IsEnable); } if (wl.Sender != "zhanghaicheng") { throw new Exception("@ Sender 错误,应该是" + WebUser.No + ",现在是:" + wl.Sender); } } } string sql = "SELECT COUNT(*) FROM WF_EmpWorks WHERE WorkID=" + this.workid + " AND FK_Emp='zhoushengyu'"; if (DBAccess.RunSQLReturnValInt(sql) != 1) { throw new Exception("@不应该查询不到 zhoushengyu 的待办."); } sql = "SELECT COUNT(*) FROM WF_EmpWorks WHERE WorkID=" + this.workid + " AND FK_Emp='zhangyifan'"; if (DBAccess.RunSQLReturnValInt(sql) != 1) { throw new Exception("@不应该查询不到 zhangyifan 的待办."); } #endregion 检查流程引擎表是否正确? // 让其中的一个人登录. BP.WF.Dev2Interface.Port_Login("zhoushengyu"); //让他发送. BP.WF.Dev2Interface.Node_SendWork(this.fk_flow, this.workid); #region 检查流程引擎表是否正确? sql = "SELECT COUNT(*) FROM WF_EmpWorks WHERE WorkID=" + this.workid + " AND FK_Emp='zhoushengyu'"; if (DBAccess.RunSQLReturnValInt(sql) != 0) { throw new Exception("@不应该在查询到 zhoushengyu 的待办."); } sql = "SELECT COUNT(*) FROM WF_EmpWorks WHERE WorkID=" + this.workid + " AND FK_Emp='zhangyifan'"; if (DBAccess.RunSQLReturnValInt(sql) != 0) { throw new Exception("@不应该在查询到 zhangyifan 的待办."); } #endregion 检查流程引擎表是否正确? //删除该测试数据. BP.WF.Dev2Interface.Flow_DoDeleteFlowByReal(this.fk_flow, workid, true); }
void ReturnWork_Click(object sender, EventArgs e) { Button btn = sender as Button; switch (btn.ID) { case "Btn_Cancel": BP.WF.Node curNd = new BP.WF.Node(this.FK_Node); if (curNd.FormType == NodeFormType.SheetTree) { this.WinClose(); } else { if (this.FID == 0) { this.Response.Redirect("../MyFlow.aspx?FK_Flow=" + this.FK_Flow + "&WorkID=" + this.WorkID + "&FK_Node=" + this.FK_Node + "&FID=" + this.FID, true); } else { string from = this.Request.QueryString["FromUrl"]; if (from == "FHLFlow") { this.Response.Redirect("FHLFlow.aspx?FK_Flow=" + this.FK_Flow + "&WorkID=" + this.WorkID + "&FK_Node=" + this.FK_Node + "&FID=" + this.FID, true); } else { this.Response.Redirect("../MyFlow.aspx?FK_Flow=" + this.FK_Flow + "&WorkID=" + this.WorkID + "&FK_Node=" + this.FK_Node + "&FID=" + this.FID, true); } } } return; default: break; } try { string returnInfo = this.TB1.Text; string reNodeEmp = this.DDL1.SelectedItemStringVal; bool IsBackTracking = false; try { IsBackTracking = this.ToolBar1.GetCBByID("CB_IsBackTracking").Checked; } catch { } string[] strs = reNodeEmp.Split('@'); //执行退回api. string rInfo = BP.WF.Dev2Interface.Node_ReturnWork(this.FK_Flow, this.WorkID, this.FID, this.FK_Node, int.Parse(strs[0]), strs[1], returnInfo, IsBackTracking); //删除其他子线程中的待办信息 GenerWorkerLists gwls = new GenerWorkerLists(); gwls.Retrieve(GenerWorkFlowAttr.FID, this.WorkID); foreach (GenerWorkerList item in gwls) { /* 删除 子线程数据 */ DBAccess.RunSQL("DELETE FROM ND" + item.FK_Node + " WHERE OID=" + item.WorkID); } //删除流程控制数据。 DBAccess.RunSQL("DELETE FROM WF_GenerWorkFlow WHERE FID=" + this.WorkID); DBAccess.RunSQL("DELETE FROM WF_GenerWorkerList WHERE FID=" + this.WorkID); DBAccess.RunSQL("DELETE FROM WF_GenerFH WHERE FID=" + this.WorkID); this.ToMsg(rInfo, "info"); return; } catch (Exception ex) { this.ToMsg(ex.Message, "info"); } }