/// <summary> /// 测试子流程只有一个人 /// </summary> private void Test1() { string fk_flow = "023"; string userNo = "zhanghaicheng"; Flow fl = new Flow(fk_flow); // zhanghaicheng 登录. BP.WF.Dev2Interface.Port_Login(userNo); //创建空白工作, 发起开始节点. Int64 workid = BP.WF.Dev2Interface.Node_CreateBlankWork(fk_flow, null, null, WebUser.No, null, 0, null); SendReturnObjs objs = BP.WF.Dev2Interface.Node_SendWork(fk_flow, workid); //创建第一个子流程,调用只有一个人的接口. Emp empSubFlowStarter = new Emp("zhoupeng"); Int64 subFlowWorkID = BP.WF.Dev2Interface.Node_CreateStartNodeWork("024", null, null, empSubFlowStarter.No, "子流程发起测试", workid, "023"); #region 检查发起的子流程 流程引擎表 是否完整? GenerWorkFlow gwf = new GenerWorkFlow(subFlowWorkID); if (gwf.PFlowNo != "023") { throw new Exception("@父流程编号错误,应当是023现在是" + gwf.PFlowNo); } if (gwf.PWorkID != workid) { throw new Exception("@父流程WorkID错误,应当是" + workid + "现在是" + gwf.PWorkID); } if (gwf.Starter != empSubFlowStarter.No) { throw new Exception("@流程发起人编号错误,应当是" + empSubFlowStarter.No + "现在是" + gwf.Starter); } if (gwf.StarterName != empSubFlowStarter.Name) { throw new Exception("@流程发起人 Name 错误,应当是" + empSubFlowStarter.Name + "现在是" + gwf.StarterName); } if (gwf.FK_Dept != empSubFlowStarter.FK_Dept) { throw new Exception("@流程隶属部门错误,应当是" + empSubFlowStarter.FK_Dept + "现在是" + gwf.FK_Dept); } if (gwf.Title != "子流程发起测试") { throw new Exception("@流程标题 子流程发起测试 错误,应当是 子流程发起测试 现在是" + gwf.Title); } if (gwf.WFState != WFState.Runing) { throw new Exception("@流程 WFState 错误,应当是 Runing 现在是" + gwf.WFState); } if (gwf.FID != 0) { throw new Exception("@FID错误,应当是0现在是" + gwf.FID); } if (gwf.FK_Flow != "024") { throw new Exception("@FK_Flow错误,应当是024现在是" + gwf.FK_Flow); } if (gwf.FK_Node != 2401) { throw new Exception("@停留的当前节点错误,应当是2401现在是" + gwf.FK_Flow); } GenerWorkerLists gwls = new GenerWorkerLists(subFlowWorkID, 2401); if (gwls.Count != 1) { throw new Exception("@待办列表个数应当1,现在是" + gwls.Count); } // 检查发起人列表是否完整? GenerWorkerList gwl = (GenerWorkerList)gwls[0]; if (gwl.FK_Emp != empSubFlowStarter.No) { throw new Exception("@处理人错误,现在是:" + empSubFlowStarter.No); } if (gwl.IsPassInt != 0) { throw new Exception("@通过状态应当是未通过,现在是:" + gwl.IsPassInt); } if (gwl.FID != 0) { throw new Exception("@流程ID 应当是0 ,现在是:" + gwl.FID); } if (gwl.FK_EmpText != empSubFlowStarter.Name) { throw new Exception("@FK_EmpText 错误, 现在是:" + gwl.FK_EmpText); } #endregion 检查发起的子流程 流程引擎表 是否完整? #region 检查发起的子流程数据是否完整? //检查报表数据是否完整? sql = "SELECT * FROM ND24Rpt WHERE OID=" + subFlowWorkID; DataTable dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count == 0) { throw new Exception("@发起流程出错误,不应该找不到子流程的报表数据."); } foreach (DataColumn dc in dt.Columns) { string val = dt.Rows[0][dc.ColumnName].ToString(); switch (dc.ColumnName) { case GERptAttr.FID: if (val != "0") { throw new Exception("@应当是0"); } break; case GERptAttr.FK_Dept: if (val != empSubFlowStarter.FK_Dept) { throw new Exception("@应当是" + empSubFlowStarter.FK_Dept + ", 现在是:" + val); } break; case GERptAttr.FK_NY: if (val != DataType.CurrentYearMonth) { throw new Exception("@应当是" + DataType.CurrentYearMonth + ", 现在是:" + val); } break; case GERptAttr.FlowDaySpan: if (val != "0") { throw new Exception("@应当是 0 , 现在是:" + val); } break; case GERptAttr.FlowEmps: if (val.Contains(empSubFlowStarter.No) == false) { throw new Exception("@应当是包含当前人员, 现在是:" + val); } break; case GERptAttr.FlowEnder: if (val != empSubFlowStarter.No) { throw new Exception("@应当是 empSubFlowStarter.No, 现在是:" + val); } break; case GERptAttr.FlowEnderRDT: if (val.Contains(DataType.CurrentData) == false) { throw new Exception("@应当是 当前日期, 现在是:" + val); } break; case GERptAttr.FlowEndNode: if (val != "2401") { throw new Exception("@应当是 2401, 现在是:" + val); } break; case GERptAttr.FlowStarter: if (val != empSubFlowStarter.No) { throw new Exception("@应当是 WebUser.No, 现在是:" + val); } break; case GERptAttr.FlowStartRDT: if (string.IsNullOrEmpty(val)) { throw new Exception("@应当不能为空,现在是:" + val); } break; case GERptAttr.Title: if (string.IsNullOrEmpty(val)) { throw new Exception("@不能为空title" + val); } break; case GERptAttr.WFState: WFState sta = (WFState)int.Parse(val); if (sta != WFState.Runing) { throw new Exception("@应当是 WFState.Runing 现在是" + sta.ToString()); } break; default: break; } } #endregion 检查是否完整? // 测试以子流程向下发送,是否成功? BP.WF.Dev2Interface.Port_Login(empSubFlowStarter.No); objs = BP.WF.Dev2Interface.Node_SendWork("024", subFlowWorkID); if (objs.VarToNodeID != 2402) { throw new Exception("@子流程向下发送时不成功."); } }
/// <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> /// 步骤1 让 zhoupeng 登录去处理. /// </summary> public void Step2() { //让 zhouepng 登录. BP.WF.Dev2Interface.Port_Login("zhoupeng"); //让他向下发送. objs = BP.WF.Dev2Interface.Node_SendWork(fk_flow, workID); #region 第1步: 检查发送对象. //从获取的发送对象里获取到下一个工作者. zhangyifan(张一帆)、zhoushengyu(周升雨). if (objs.VarAcceptersID != "zhanghaicheng") { throw new Exception("@下一步的接受人不正确, 应当是: zhanghaicheng.现在是:" + objs.VarAcceptersID); } if (objs.VarToNodeID != 2399) { throw new Exception("@应该是 2399 节点. 现在是:" + objs.VarToNodeID); } if (objs.VarWorkID != workID) { throw new Exception("@主线程的workid不应该变化:" + objs.VarWorkID); } if (objs.VarCurrNodeID != 2302) { throw new Exception("@当前节点的编号不能变化,现在是:" + objs.VarCurrNodeID); } if (objs.VarTreadWorkIDs != null) { throw new Exception("@不应当获得子线程WorkID."); } #endregion 第1步: 检查发送对象. #region 第2步: 检查流程引擎表. //检查待办是否存在。 sql = "SELECT * FROM WF_EmpWorks WHERE WorkID=" + workID + " AND FK_Emp='" + objs.VarAcceptersID + "'"; dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count == 0) { throw new Exception("@不应该找不到当前人员的待办."); } gwf = new GenerWorkFlow(workID); if (gwf.FK_Dept != starterEmp.FK_Dept) { throw new Exception("@发起人的部门有变化,应当是" + starterEmp.FK_Dept + ",现在是:" + gwf.FK_Dept); } if (gwf.Starter != starterEmp.No) { throw new Exception("@发起人的 No 有变化,应当是" + starterEmp.No + ",现在是:" + gwf.Starter); } //判断当前点. if (gwf.FK_Node != 2399) { throw new Exception("@当前点应该是 2399 现在是:" + gwf.FK_Node); } //判断当前点. if (gwf.FID != 0) { throw new Exception("@当前点应该是 FID=0 现在是:" + gwf.FID); } //判断PWorkID,没有谁调用它,应当是 0. if (gwf.PWorkID != 0) { throw new Exception("@没有谁调用它, 当前点应该是 PWorkID=0 现在是:" + gwf.PWorkID); } //判断 WFState . if (gwf.WFState != WFState.Runing) { throw new Exception("@应当是 WFState=Runing 现在是:" + gwf.WFState.ToString()); } //检查开始节点 发送人的WF_GenerWorkerList 的. gwl = new GenerWorkerList(); gwl.FK_Emp = Web.WebUser.No; gwl.FK_Node = 2302; gwl.WorkID = workID; gwl.Retrieve(); // 没有分合流应当是 0 . if (gwl.FID != 0) { throw new Exception("@没有分合流应当是 0."); } if (gwl.IsEnable == false) { throw new Exception("@应该是启用的状态 "); } if (gwl.IsPass == false) { throw new Exception("@应该是通过的状态 "); } //if (gwl.Sender.Contains("zhanghaicheng")==false) // throw new Exception("@应该是 包含当前状态 . "); //检查接受人的 WF_GenerWorkerList 的. gwl = new GenerWorkerList(); gwl.FK_Emp = objs.VarAcceptersID; gwl.FK_Node = 2399; gwl.WorkID = workID; gwl.Retrieve(); // 没有分合流应当是 0 . if (gwl.FID != 0) { throw new Exception("@没有分合流应当是 0."); } if (gwl.IsEnable == false) { throw new Exception("@应该是启用的状态 "); } if (gwl.IsPass == true) { throw new Exception("@应该是未通过的状态 "); } //if (gwl.Sender.Contains(WebUser.No)==false) // throw new Exception("@应该是 当前人发送的,现在是: " + gwl.Sender); #endregion 第2步: 检查流程引擎表. #region 第3步: 检查节点数据表. sql = "SELECT * FROM ND2301 WHERE OID=" + 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.CDT: if (val.Contains(DataType.CurrentData) == false) { throw new Exception("CDT,日期错误."); } break; case WorkAttr.RDT: if (val.Contains(DataType.CurrentData) == false) { throw new Exception("RDT,日期错误."); } break; case WorkAttr.Emps: if (val.Contains("zhanghaicheng") == false) { throw new Exception("应当包含当前人员,现在是:" + val); } break; case WorkAttr.FID: if (val != "0") { throw new Exception("应当 = 0,现在是:" + val); } break; case WorkAttr.MyNum: if (val != "1") { throw new Exception("应当 = 1,现在是:" + val); } break; case WorkAttr.Rec: if (val != objs.VarAcceptersID) { throw new Exception("应当 Rec=zhanghaicheng,现在是:" + val); } break; default: break; } } //检查节点2的数据. sql = "SELECT * FROM ND2302 WHERE OID=" + workID; dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count != 1) { throw new Exception("@发起流程出错误,不应该找不到 ND2302 的数据."); } foreach (DataColumn dc in dt.Columns) { string val = dt.Rows[0][dc.ColumnName].ToString(); switch (dc.ColumnName) { case WorkAttr.CDT: if (val.Contains(DataType.CurrentData) == false) { throw new Exception("CDT,日期错误."); } break; case WorkAttr.RDT: if (val.Contains(DataType.CurrentData) == false) { throw new Exception("RDT,日期错误."); } break; case WorkAttr.Emps: if (val.Contains(WebUser.No) == false) { throw new Exception("应当包含当前人员,现在是:" + val); } break; case WorkAttr.FID: if (val != "0") { throw new Exception("应当 = 0,现在是:" + val); } break; case WorkAttr.MyNum: if (val != "1") { throw new Exception("应当 = 1,现在是:" + val); } break; case WorkAttr.Rec: if (val != "zhoupeng") { throw new Exception("应当 Rec= zhoupeng,现在是:" + val); } break; default: break; } } //检查节点3的数据. sql = "SELECT * FROM ND2399 WHERE OID=" + workID; dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count != 1) { throw new Exception("@发起流程出错误,不应该找不到 ND2399 的数据."); } foreach (DataColumn dc in dt.Columns) { string val = dt.Rows[0][dc.ColumnName].ToString(); switch (dc.ColumnName) { case WorkAttr.CDT: if (val.Contains(DataType.CurrentData) == false) { throw new Exception("CDT,日期错误."); } break; case WorkAttr.RDT: if (val.Contains(DataType.CurrentData) == false) { throw new Exception("RDT,日期错误."); } break; case WorkAttr.Emps: if (val.Contains("zhanghaicheng") == false) { throw new Exception("应当包含当前人员,现在是:" + val); } break; case WorkAttr.FID: if (val != "0") { throw new Exception("应当 = 0,现在是:" + val); } break; case WorkAttr.MyNum: if (val != "1") { throw new Exception("应当 = 1,现在是:" + val); } break; case WorkAttr.Rec: if (val != objs.VarAcceptersID) { throw new Exception("应当 Rec= " + objs.VarAcceptersID + ",现在是:" + val); } break; default: break; } } //检查流程表的数据. sql = "SELECT * FROM " + fl.PTable + " WHERE OID=" + 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 GERptAttr.FID: if (val != "0") { throw new Exception("@应当是0"); } break; case GERptAttr.FK_Dept: BP.Port.Emp emp = new Port.Emp("zhanghaicheng"); if (val != emp.FK_Dept) { throw new Exception("@应当是" + emp.FK_Dept + ", 现在是:" + val); } break; case GERptAttr.FK_NY: if (val != DataType.CurrentYearMonth) { throw new Exception("@应当是" + DataType.CurrentYearMonth + ", 现在是:" + val); } break; case GERptAttr.FlowDaySpan: if (val != "0") { throw new Exception("@应当是 0 , 现在是:" + val); } break; case GERptAttr.FlowEmps: if (BP.WF.Glo.UserInfoShowModel != UserInfoShowModel.UserNameOnly) { if (val.Contains(WebUser.No) == false) { throw new Exception("@应当是包含当前人员, 现在是:" + val); } } break; case GERptAttr.FlowEnder: if (val != WebUser.No) { throw new Exception("@应当是 当前人员, 现在是:" + val); } break; case GERptAttr.FlowEnderRDT: if (val.Contains(DataType.CurrentData) == false) { throw new Exception("@应当是 当前日期, 现在是:" + val); } break; case GERptAttr.FlowEndNode: if (val != "2399") { throw new Exception("@应当是 2399, 现在是:" + val); } break; case GERptAttr.FlowStarter: if (val == WebUser.No) { throw new Exception("@应当是 WebUser.No, 现在是:" + val); } break; case GERptAttr.FlowStartRDT: if (DataType.IsNullOrEmpty(val)) { throw new Exception("@应当不能为空,现在是:" + val); } break; case GERptAttr.Title: if (DataType.IsNullOrEmpty(val)) { throw new Exception("@不能为空title" + val); } break; case GERptAttr.WFState: if (int.Parse(val) != (int)WFState.Runing) { throw new Exception("@应当是 WFState.Runing 现在是" + val); } break; default: break; } } #endregion 第3步: 检查节点数据表. }
/// <summary> /// 步骤1 让zhanghaicheng 发起流程. /// </summary> public void Step1() { //给发起人赋值. starterEmp = new Port.Emp(userNo); //让 userNo 登录. BP.WF.Dev2Interface.Port_Login(userNo); //创建空白工作, 发起开始节点. workID = BP.WF.Dev2Interface.Node_CreateBlankWork(fk_flow); #region 检查创建工作是否符合预期. //检查开始节点写入的数据是否正确? sql = "SELECT * FROM ND2301 WHERE OID=" + 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.CDT: if (val.Contains(DataType.CurrentData) == false) { throw new Exception("CDT,日期错误.现在的日期是:" + val); } break; case WorkAttr.RDT: if (val.Contains(DataType.CurrentData) == false) { throw new Exception("RDT,日期错误.现在的日期是:" + val); } break; case WorkAttr.Emps: if (val.Contains(WebUser.No) == false) { throw new Exception("应当包含当前人员,现在是:" + val); } break; case WorkAttr.FID: if (val != "0") { throw new Exception("应当 = 0,现在是:" + val); } break; case WorkAttr.MD5: break; case WorkAttr.MyNum: if (val != "1") { throw new Exception("应当 = 1,现在是:" + val); } break; case WorkAttr.Rec: if (val != WebUser.No) { throw new Exception("应当 Rec= " + WebUser.No + ",现在是:" + val); } break; default: break; } } //检查流程表的数据. sql = "SELECT * FROM " + fl.PTable + " WHERE OID=" + 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 GERptAttr.FID: if (val != "0") { throw new Exception("@应当是0"); } break; case GERptAttr.FK_Dept: if (val != WebUser.FK_Dept) { throw new Exception("@应当是" + WebUser.FK_Dept + ", 现在是:" + val); } break; case GERptAttr.FK_NY: if (val != DataType.CurrentYearMonth) { throw new Exception("@应当是" + DataType.CurrentYearMonth + ", 现在是:" + val); } break; case GERptAttr.FlowDaySpan: if (val != "0") { throw new Exception("@应当是 0 , 现在是:" + val); } break; case GERptAttr.FlowEmps: if (BP.WF.Glo.UserInfoShowModel != UserInfoShowModel.UserNameOnly) { if (val.Contains(WebUser.No) == false) { throw new Exception("@应当是包含当前人员, 现在是:" + val); } } break; case GERptAttr.FlowEnder: if (val != WebUser.No) { throw new Exception("@应当是 当前人员, 现在是:" + val); } break; case GERptAttr.FlowEnderRDT: if (val.Contains(DataType.CurrentData) == false) { throw new Exception("@应当是 当前日期, 现在是:" + val); } break; case GERptAttr.FlowEndNode: if (val != "2301") { throw new Exception("@应当是 2301, 现在是:" + val); } break; case GERptAttr.FlowStarter: if (val != WebUser.No) { throw new Exception("@应当是 WebUser.No, 现在是:" + val); } break; case GERptAttr.FlowStartRDT: if (DataType.IsNullOrEmpty(val)) { throw new Exception("@应当不能为空,现在是:" + val); } break; case GERptAttr.Title: if (DataType.IsNullOrEmpty(val)) { throw new Exception("@不能为空title" + val); } break; case GERptAttr.WFState: WFState sta = (WFState)int.Parse(val); if (sta != WFState.Blank) { throw new Exception("@应当是 WFState.Blank 现在是" + sta.ToString()); } break; default: break; } } #endregion 检查创建工作是否符合预期 //定义一个参数. Hashtable ht = new System.Collections.Hashtable(); ht.Add("GoTo", 1); ht.Add("MyPara", "TestPara"); //执行发送. objs = BP.WF.Dev2Interface.Node_SendWork(fk_flow, workID, ht); #region 第1步: 检查发送对象. //从获取的发送对象里获取到下一个工作者. zhangyifan(张一帆)、zhoushengyu(周升雨). if (objs.VarAcceptersID != "zhoupeng") { throw new Exception("@下一步的接受人不正确, 应当是: zhoupeng.现在是:" + objs.VarAcceptersID); } if (objs.VarToNodeID != 2302) { throw new Exception("@应该是 2302 节点. 现在是:" + objs.VarToNodeID); } if (objs.VarWorkID != workID) { throw new Exception("@主线程的workid不应该变化:" + objs.VarWorkID); } if (objs.VarCurrNodeID != 2301) { throw new Exception("@当前节点的编号不能变化:" + objs.VarCurrNodeID); } if (objs.VarTreadWorkIDs != null) { throw new Exception("@不应当获得子线程WorkID."); } #endregion 第1步: 检查发送对象. #region 第2步: 检查流程引擎表. //检查创建这个空白是否有数据完整? sql = "SELECT * FROM WF_EmpWorks WHERE WorkID=" + workID + " AND FK_Emp='" + objs.VarAcceptersID + "'"; dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count == 0) { throw new Exception("@不应该找不到当前人员的待办."); } gwf = new GenerWorkFlow(workID); if (gwf.Starter != WebUser.No || gwf.StarterName != WebUser.Name) { throw new Exception("没有写入发起人的信息."); } if (gwf.FK_Dept != starterEmp.FK_Dept) { throw new Exception("@发起人的部门有变化,应当是" + starterEmp.FK_Dept + ",现在是:" + gwf.FK_Dept); } if (gwf.Starter != starterEmp.No) { throw new Exception("@发起人的 No 有变化,应当是" + starterEmp.No + ",现在是:" + gwf.Starter); } //判断当前点. if (gwf.FK_Node != 2302) { throw new Exception("@当前点应该是 2302 现在是:" + gwf.FK_Node); } //判断TodoEmpsNum. if (gwf.TodoEmpsNum != 1) { throw new Exception("@当前点应该是 TodoEmpsNum=0 现在是:" + gwf.TodoEmpsNum); } //判断TodoEmps. if (gwf.TodoEmps != "zhoupeng,周朋;") { throw new Exception("@当前点应该是 TodoEmps=zhoupeng,周朋; 现在是:" + gwf.TodoEmps); } //判断FID. if (gwf.FID != 0) { throw new Exception("@当前点应该是 FID=0 现在是:" + gwf.FID); } //判断PWorkID,没有谁调用它,应当是 0. if (gwf.PWorkID != 0) { throw new Exception("@没有谁调用它, 当前点应该是 PWorkID=0 现在是:" + gwf.PWorkID); } //判断 WFState . if (gwf.WFState != WFState.Runing) { throw new Exception("@应当是 WFState=Runing 现在是:" + gwf.WFState.ToString()); } //检查开始节点 发送人的WF_GenerWorkerList的. gwl = new GenerWorkerList(); gwl.CheckPhysicsTable(); gwl.FK_Emp = Web.WebUser.No; gwl.FK_Node = 2301; gwl.WorkID = workID; gwl.Retrieve(); // 没有分合流应当是 0 . if (gwl.FID != 0) { throw new Exception("@没有分合流应当是 0."); } if (gwl.IsEnable == false) { throw new Exception("@应该是启用的状态 "); } if (gwl.IsPass == false) { throw new Exception("@应该是通过的状态 "); } //if (gwl.Sender.Contains(WebUser.No)==false) // throw new Exception("@应该是 包含当前状态 . "); //if (gwl. != "@MyPara=TestPara@GoTo=1") // throw new Exception("@参数应当是:@MyPara=TestPara@GoTo=1 .现在是:" + gwl.Paras); //检查接受人的 WF_GenerWorkerList 的. gwl = new GenerWorkerList(); gwl.FK_Emp = objs.VarAcceptersID; gwl.FK_Node = 2302; gwl.WorkID = workID; gwl.Retrieve(); // 没有分合流应当是 0 . if (gwl.FID != 0) { throw new Exception("@没有分合流应当是 0."); } if (gwl.IsEnable == false) { throw new Exception("@应该是启用的状态 "); } if (gwl.IsPass == true) { throw new Exception("@应该是未通过的状态 "); } //if (gwl.Sender.Contains(WebUser.No)==false) // throw new Exception("@应该是 当前人发送的,现在是: " + gwl.Sender); #endregion 第2步: 检查流程引擎表. #region 第3步: 检查节点数据表. sql = "SELECT * FROM ND2301 WHERE OID=" + 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.CDT: if (val.Contains(DataType.CurrentData) == false) { throw new Exception("CDT,日期错误."); } break; case WorkAttr.RDT: if (val.Contains(DataType.CurrentData) == false) { throw new Exception("RDT,日期错误."); } break; case WorkAttr.Emps: if (val.Contains(WebUser.No) == false) { throw new Exception("应当包含当前人员,现在是:" + val); } break; case WorkAttr.FID: if (val != "0") { throw new Exception("应当 = 0,现在是:" + val); } break; case WorkAttr.MD5: //if (Glo.ism //if (val !="0") // throw new Exception("应当 = 0,现在是:"+val); break; case WorkAttr.MyNum: if (val != "1") { throw new Exception("应当 = 1,现在是:" + val); } break; case WorkAttr.Rec: if (val != WebUser.No) { throw new Exception("应当 Rec= " + WebUser.No + ",现在是:" + val); } break; //case WorkAttr.Sender: // if (val != WebUser.No) // throw new Exception("应当 Sender= " + WebUser.No + ",现在是:" + val); // break; default: break; } } //检查节点2的数据. sql = "SELECT * FROM ND2302 WHERE OID=" + workID; dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count != 1) { throw new Exception("@发起流程出错误,不应该找不到 ND2302 的数据."); } foreach (DataColumn dc in dt.Columns) { string val = dt.Rows[0][dc.ColumnName].ToString(); switch (dc.ColumnName) { case WorkAttr.CDT: if (val.Contains(DataType.CurrentData) == false) { throw new Exception("CDT,日期错误."); } break; case WorkAttr.RDT: if (val.Contains(DataType.CurrentData) == false) { throw new Exception("RDT,日期错误."); } break; case WorkAttr.Emps: if (val.Contains("zhoupeng") == false) { throw new Exception("第二步骤的处理人员,应当zhoupeng ,现在是:" + val); } break; case WorkAttr.FID: if (val != "0") { throw new Exception("应当 = 0,现在是:" + val); } break; case WorkAttr.MD5: //if (Glo.ism //if (val !="0") // throw new Exception("应当 = 0,现在是:"+val); break; case WorkAttr.MyNum: if (val != "1") { throw new Exception("应当 = 1,现在是:" + val); } break; case WorkAttr.Rec: if (val != "zhoupeng") { throw new Exception("应当 Rec=zhoupeng,现在是:" + val); } break; default: break; } } //检查流程表的数据. sql = "SELECT * FROM " + fl.PTable + " WHERE OID=" + 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 GERptAttr.FID: if (val != "0") { throw new Exception("@应当是0"); } break; case GERptAttr.FK_Dept: if (val != WebUser.FK_Dept) { throw new Exception("@应当是" + WebUser.FK_Dept + ", 现在是:" + val); } break; case GERptAttr.FK_NY: if (val != DataType.CurrentYearMonth) { throw new Exception("@应当是" + DataType.CurrentYearMonth + ", 现在是:" + val); } break; case GERptAttr.FlowDaySpan: if (val != "0") { throw new Exception("@应当是 0 , 现在是:" + val); } break; case GERptAttr.FlowEmps: if (BP.WF.Glo.UserInfoShowModel != UserInfoShowModel.UserNameOnly) { if (val.Contains(WebUser.No) == false) { throw new Exception("@应当是包含当前人员, 现在是:" + val); } } break; case GERptAttr.FlowEnder: if (val != WebUser.No) { throw new Exception("@应当是 当前人员, 现在是:" + val); } break; case GERptAttr.FlowEnderRDT: if (val.Contains(DataType.CurrentData) == false) { throw new Exception("@应当是 当前日期, 现在是:" + val); } break; case GERptAttr.FlowEndNode: if (val != "2302") { throw new Exception("@应当是 2302, 现在是:" + val); } break; case GERptAttr.FlowStarter: if (val != WebUser.No) { throw new Exception("@应当是 WebUser.No, 现在是:" + val); } break; case GERptAttr.FlowStartRDT: if (DataType.IsNullOrEmpty(val)) { throw new Exception("@应当不能为空,现在是:" + val); } break; case GERptAttr.Title: if (DataType.IsNullOrEmpty(val)) { throw new Exception("@不能为空title" + val); } break; case GERptAttr.WFState: WFState sta = (WFState)int.Parse(val); if (sta != WFState.Runing) { throw new Exception("@应当是 WFState.Runing 现在是" + sta.ToString()); } break; default: break; } } #endregion 第3步: 检查节点数据表. }
/// <summary> /// dd /// </summary> public void BindLB() { // 当前用的员工权限。 this.Clear(); GenerWorkerLists wls = new GenerWorkerLists(this.WorkID, this.NodeID, true); string sql = "SELECT * FROM WF_RememberMe WHERE FK_Emp='" + WebUser.No + "' AND FK_Node=" + this.NodeID; DataTable dt = DBAccess.RunSQLReturnTable(sql); if (WebUser.IsWap) { this.AddFieldSet("<a href='./WAP/Home.aspx' ><img src='/WF/Img/Home.gif' border=0/>主页</a> - 工作分配"); } else { this.AddFieldSet("工作分配"); } if (dt.Rows.Count == 0) { throw new Exception("@系统错误..." + sql); } string[] objs = dt.Rows[0]["Objs"].ToString().Split('@'); string[] emps = dt.Rows[0]["Emps"].ToString().Split('@'); string ids = ""; this.AddUL(); foreach (string fk_emp in emps) { if (fk_emp == null || fk_emp == "") { continue; } Emp emp = new Emp(fk_emp); CheckBox cb = new CheckBox(); cb.ID = "CB_" + fk_emp; ids += "," + cb.ID; if (Glo.IsShowUserNoOnly) { cb.Text = emp.No; } else { cb.Text = emp.No + " , " + emp.Name; } GenerWorkerList wl = wls.GetEntityByKey(GenerWorkerListAttr.FK_Emp, fk_emp) as GenerWorkerList; if (wl == null) { cb.Checked = false; } else { cb.Checked = wl.IsEnable; } this.Add("<li>"); this.Add(cb); this.Add("</li>"); //this.AddBR(); } this.AddULEnd(); this.AddHR(); Btn btn = new Btn(); btn.ID = "Btn_Do"; btn.Text = " 确定 "; btn.Click += new EventHandler(BPToolBar1_ButtonClick); this.Add(btn); CheckBox cbx = new CheckBox(); cbx.ID = "seleall"; cbx.Text = "选择全部"; cbx.Checked = true; cbx.Attributes["onclick"] = "SetSelected(this,'" + ids + "')"; this.Add(cbx); //this.Add("<input type=button value='取消' onclick='window.close();' />"); this.Add("<br><br>帮助:系统会记住本次的工作指定,下次您在发送时间它会自动把工作投递给您本次指定的人。"); this.AddFieldSetEnd(); }
protected void Page_Load(object sender, System.EventArgs e) { Response.AddHeader("P3P", "CP=CAO PSA OUR"); Response.AddHeader("Cache-Control", "no-store"); Response.AddHeader("Expires", "0"); Response.AddHeader("Pragma", "no-cache"); string url = this.Request.RawUrl; if (url.Contains("DTT=") == false) { //this.Response.Redirect(url + "&DTT=" + DateTime.Now.ToString("mmDDhhmmss"), true); //return; } try { switch (this.ActionType) { case "Focus": //把任务放入任务池. BP.WF.Dev2Interface.Flow_Focus(Int64.Parse(this.Request.QueryString["WorkID"])); this.WinClose("ss"); break; case "PutOne": //把任务放入任务池. Int64 workid42 = Int64.Parse(this.Request.QueryString["WorkID"]); BP.WF.Dev2Interface.Node_TaskPoolPutOne(workid42); this.WinClose("ss"); break; case "DoAppTask": // 申请任务. Int64 workid2 = Int64.Parse(this.Request.QueryString["WorkID"]); BP.WF.Dev2Interface.Node_TaskPoolTakebackOne(workid2); this.WinClose("ss"); return; case "DoOpenCC": string fk_flow1 = this.Request.QueryString["FK_Flow"]; string fk_node1 = this.Request.QueryString["FK_Node"]; string workid1 = this.Request.QueryString["WorkID"]; string fid1 = this.Request.QueryString["FID"]; string Sta = this.Request.QueryString["Sta"]; if (Sta == "0") { BP.WF.Template.CCList cc1 = new BP.WF.Template.CCList(); cc1.MyPK = this.Request.QueryString["MyPK"]; cc1.Retrieve(); cc1.HisSta = CCSta.Read; cc1.Update(); } this.Response.Redirect("./WorkOpt/OneWork/Track.aspx?FK_Flow=" + fk_flow1 + "&FK_Node=" + fk_node1 + "&WorkID=" + workid1 + "&FID=" + fid1, false); return; case "DelCC": //删除抄送. CCList cc = new CCList(); cc.MyPK = this.MyPK; cc.Retrieve(); cc.HisSta = CCSta.Del; cc.Update(); this.WinClose(); break; case "DelSubFlow": //删除进程。 try { BP.WF.Dev2Interface.Flow_DeleteSubThread(this.FK_Flow, this.WorkID, "手工删除"); this.WinClose(); } catch (Exception ex) { this.WinCloseWithMsg(ex.Message); } break; case "DownBill": Bill b = new Bill(this.MyPK); b.DoOpen(); break; case "DelDtl": GEDtls dtls = new GEDtls(this.EnsName); GEDtl dtl = (GEDtl)dtls.GetNewEntity; dtl.OID = this.RefOID; if (dtl.RetrieveFromDBSources() == 0) { this.WinClose(); break; } FrmEvents fes = new FrmEvents(this.EnsName); //获得事件. // 处理删除前事件. try { fes.DoEventNode(BP.WF.XML.EventListDtlList.DtlItemDelBefore, dtl); } catch (Exception ex) { this.WinCloseWithMsg(ex.Message); break; } dtl.Delete(); // 处理删除后事件. try { fes.DoEventNode(BP.WF.XML.EventListDtlList.DtlItemDelAfter, dtl); } catch (Exception ex) { this.WinCloseWithMsg(ex.Message); break; } this.WinClose(); break; case "EmpDoUp": BP.WF.Port.WFEmp ep = new BP.WF.Port.WFEmp(this.RefNo); ep.DoUp(); BP.WF.Port.WFEmps emps111 = new BP.WF.Port.WFEmps(); // emps111.RemoveCash(); emps111.RetrieveAll(); this.WinClose(); break; case "EmpDoDown": BP.WF.Port.WFEmp ep1 = new BP.WF.Port.WFEmp(this.RefNo); ep1.DoDown(); BP.WF.Port.WFEmps emps11441 = new BP.WF.Port.WFEmps(); // emps11441.RemoveCash(); emps11441.RetrieveAll(); this.WinClose(); break; case "Track": //通过一个串来打开一个工作. string mySid = this.Request.QueryString["SID"]; string[] mystrs = mySid.Split('_'); Int64 myWorkID = int.Parse(mystrs[1]); string fk_emp = mystrs[0]; int fk_node = int.Parse(mystrs[2]); Node mynd = new Node(); mynd.NodeID = fk_node; mynd.RetrieveFromDBSources(); string fk_flow = mynd.FK_Flow; string myurl = "./WorkOpt/OneWork/Track.aspx?FK_Node=" + mynd.NodeID + "&WorkID=" + myWorkID + "&FK_Flow=" + fk_flow; Web.WebUser.SignInOfGener(new BP.Port.Emp(fk_emp), true); this.Response.Write("<script> window.location.href='" + myurl + "'</script> *^_^* <br><br>正在进入系统请稍后,如果长时间没有反应,请<a href='" + myurl + "'>点这里进入。</a>"); return; case "OF": //通过一个串来打开一个工作. string sid = this.Request.QueryString["SID"]; string[] strs = sid.Split('_'); GenerWorkerList wl = new GenerWorkerList(); int i = wl.Retrieve(GenerWorkerListAttr.FK_Emp, strs[0], GenerWorkerListAttr.WorkID, strs[1], GenerWorkerListAttr.FK_Node, strs[2]); if (i == 0) { this.Response.Write("<h2>提示</h2>此工作已经被别人处理或者此流程已删除。"); return; } BP.Port.Emp empOF = new BP.Port.Emp(wl.FK_Emp); Web.WebUser.SignInOfGener(empOF, true); string u = "MyFlow.aspx?FK_Flow=" + wl.FK_Flow + "&WorkID=" + wl.WorkID + "&FK_Node=" + wl.FK_Node + "&FID=" + wl.FID; this.Response.Write("<script> window.location.href='" + u + "'</script> *^_^* <br><br>正在进入系统请稍后,如果长时间没有反应,请<a href='" + u + "'>点这里进入。</a>"); return; case "ExitAuth": BP.Port.Emp emp = new BP.Port.Emp(this.FK_Emp); //首先退出,再进行登录 BP.Web.WebUser.Exit(); BP.Web.WebUser.SignInOfGenerLang(emp, WebUser.SysLang); this.WinClose(); return; case "LogAs": BP.WF.Port.WFEmp wfemp = new BP.WF.Port.WFEmp(this.FK_Emp); if (wfemp.AuthorIsOK == false) { this.WinCloseWithMsg("授权失败"); return; } BP.Port.Emp emp1 = new BP.Port.Emp(this.FK_Emp); BP.Web.WebUser.SignInOfGener(emp1, WebUser.SysLang, WebUser.No, true, false); this.WinClose(); return; case "TakeBack": // 取消授权。 BP.WF.Port.WFEmp myau = new BP.WF.Port.WFEmp(WebUser.No); BP.DA.Log.DefaultLogWriteLineInfo("取消授权:" + WebUser.No + "取消了对(" + myau.Author + ")的授权。"); myau.Author = ""; myau.AuthorWay = 0; myau.Update(); this.WinClose(); return; case "AutoTo": // 执行授权。 BP.WF.Port.WFEmp au = new BP.WF.Port.WFEmp(); au.No = WebUser.No; au.RetrieveFromDBSources(); au.AuthorDate = BP.DA.DataType.CurrentData; au.Author = this.FK_Emp; au.AuthorWay = 1; au.Save(); BP.DA.Log.DefaultLogWriteLineInfo("执行授权:" + WebUser.No + "执行了对(" + au.Author + ")的授权。"); this.WinClose(); return; case "UnSend": //执行撤消发送。 this.Response.Redirect("./WorkOpt/UnSend.aspx?WorkID=" + this.WorkID + "&FK_Flow=" + this.FK_Flow, false); return; case "SetBillState": break; case "WorkRpt": Bill bk1 = new Bill(this.Request.QueryString["OID"]); Node nd = new Node(bk1.FK_Node); this.Response.Redirect("WFRpt.aspx?WorkID=" + bk1.WorkID + "&FID=" + bk1.FID + "&FK_Flow=" + nd.FK_Flow + "&NodeId=" + bk1.FK_Node, false); //this.WinOpen(); //this.WinClose(); break; case "PrintBill": //Bill bk2 = new Bill(this.Request.QueryString["OID"]); //Node nd2 = new Node(bk2.FK_Node); //this.Response.Redirect("NodeRefFunc.aspx?NodeId=" + bk2.FK_Node + "&FlowNo=" + nd2.FK_Flow + "&NodeRefFuncOID=" + bk2.FK_NodeRefFunc + "&WorkFlowID=" + bk2.WorkID); ////this.WinClose(); break; //删除流程中第一个节点的数据,包括待办工作 case "DeleteFlow": string fk_flowDel = this.Request.QueryString["FK_Flow"]; Int64 workid = Int64.Parse(this.Request.QueryString["WorkID"]); //调用DoDeleteWorkFlowByReal方法 WorkFlow wf = new WorkFlow(new Flow(fk_flowDel), workid); wf.DoDeleteWorkFlowByReal(true); // Glo.ToMsg("流程删除成功"); BP.WF.Glo.ToMsg("流程删除成功"); //this.ToWFMsgPage("流程删除成功"); break; default: throw new Exception("ActionType error" + this.ActionType); } } catch (Exception ex) { this.ToErrorPage("执行其间如下异常:<BR>" + ex.Message); } }
/// <summary> /// 创建流程,发送分流点第1步. /// </summary> public void Step1() { // 让zhoupeng 登录. 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 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.VarToNodeIDs != "902,903,904,") { throw new Exception("@应该是 902,903,904, 现在是:" + objs.VarToNodeIDs); } 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(item.FK_Emp) == 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.Columns) { string val = dt.Rows[0][dc.ColumnName].ToString(); 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 (BP.WF.Glo.UserInfoShowModel != UserInfoShowModel.UserNameOnly) { if (val.Contains(WebUser.No) == false) { throw new Exception("@ 应该包含 zhoupeng , 现在是: " + val); } } break; case GERptAttr.FlowEnder: if (val != "zhoupeng") { throw new Exception("@应该是 zhoupeng 是 FlowEnder ,现在是:" + val); } break; case GERptAttr.FlowEnderRDT: break; case GERptAttr.FlowEndNode: if (val != "901") { throw new Exception("@应该是 901 是 FlowEndNode,现在是:" + val); } break; case GERptAttr.FlowStarter: if (val != "zhoupeng") { throw new Exception("@应该是 zhoupeng 是 FlowStarter, 现在是:" + val); } break; case GERptAttr.MyNum: if (val != "1") { throw new Exception("@ MyNum 应当是1, 现在是:" + val); } 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 是当前的状态,现在是:" + val); } break; default: break; } } #endregion 检查【开始节点】发送数据信息否完整? }
public void Confirm() { GenerWorkerLists wls = new GenerWorkerLists(this.WorkID, this.NodeID, true); string sql = "SELECT * FROM WF_RememberMe WHERE FK_Emp='" + WebUser.No + "' AND FK_Node=" + this.NodeID; DataTable dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count == 0) { throw new Exception("@system error....."); } try { string[] objs = dt.Rows[0]["Objs"].ToString().Split('@'); string[] empStrs = dt.Rows[0]["Emps"].ToString().Split('@'); ArrayList al = new ArrayList(); GenerWorkerLists wlSeles = new GenerWorkerLists(); foreach (string fk_emp in empStrs) { if (fk_emp == null || fk_emp == "") { continue; } CheckBox cb = this.GetCBByID("CB_" + fk_emp); if (cb == null) { BP.DA.Log.DebugWriteWarning("不应该查询不到:" + fk_emp); continue; } if (cb.Checked == false) { continue; } GenerWorkerList wl = wls.GetEntityByKey(GenerWorkerListAttr.FK_Emp, fk_emp) as GenerWorkerList; al.Add(cb.ID.Substring(3)); wlSeles.AddEntity(wl); } if (al.Count == 0) { this.Alert("当前工作中你没有分配给任何人,此工作将不能被其他人所执行!"); return; } if (this.IsFHL) { /* 处理分合流 */ this.DealWithFHLFlow(al, wlSeles); } else { this.DealWithPanelFlow(al, wlSeles); } // 保存记忆功能。 RememberMe rm = new RememberMe(); rm.FK_Emp = BP.Web.WebUser.No; rm.FK_Node = NodeID; rm.Objs = "@"; rm.ObjsExt = ""; foreach (GenerWorkerList mywl in wlSeles) { rm.Objs += mywl.FK_Emp + "@"; rm.ObjsExt += mywl.FK_EmpText + " "; } rm.Emps = "@"; rm.EmpsExt = ""; foreach (GenerWorkerList wl in wls) { rm.Emps += wl.FK_Emp + "@"; if (rm.Objs.IndexOf(wl.FK_Emp) != -1) { rm.EmpsExt += "<font color=green>(" + wl.FK_Emp + ")" + wl.FK_EmpText + "</font> "; } else { rm.EmpsExt += "<strike>(" + wl.FK_Emp + ")" + wl.FK_EmpText + "</strike> "; } } rm.FK_Emp = BP.Web.WebUser.No; rm.Update(); if (WebUser.IsWap) { this.Clear(); this.AddFieldSet("提示信息"); this.Add("<br> 任务分配成功,特别提示:当下一次流程发送时系统会按照您设置的路径进行智能投递。"); this.AddUL(); this.AddLi("<a href='./WAP/Home.aspx' ><img src='/WF/Img/Home.gif' border=0/>主页</a>"); this.AddLi("<a href='./WAP/Start.aspx' ><img src='/WF/Img/Start.gif' border=0/>发起</a>"); this.AddLi("<a href='./WAP/Runing.aspx' ><img src='/WF/Img/Runing.gif' border=0/>待办</a>"); this.AddULEnd(); this.AddFieldSetEnd(); } else { this.WinCloseWithMsg("任务分配成功。"); } } catch (Exception ex) { this.Response.Write(ex.Message); Log.DebugWriteWarning(ex.Message); this.Alert("任务分配出错:" + ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { string strsql = @"select * from WF_GenerWorkFlow where WorkID not in ( select distinct WorkID from WF_GenerWorkerlist) and WFState<> 3 and WFState<>7 and RDT > '2014-10-01 00:00' order by RDT desc "; DataTable dt = DBAccess.RunSQLReturnTable(strsql); foreach (DataRow row in dt.Rows) { string empwors = row["TodoEmps"].ToString(); if (!string.IsNullOrEmpty(empwors)) { string[] emps = empwors.Split(';'); if (emps != null && emps.Length > 0) { foreach (string str in emps) { if (!string.IsNullOrEmpty(str)) { string[] emp = str.Split(','); BP.WF.GenerWorkerList list = new GenerWorkerList(); list.WorkID = Convert.ToInt64(row["WorkID"].ToString()); list.FK_Emp = emp[0]; list.FK_EmpText = emp[1]; list.FK_Node = Convert.ToInt32(row["FK_Node"].ToString()); list.FK_NodeText = row["NodeName"].ToString(); list.FID = Convert.ToInt64(row["FID"].ToString()); list.FK_Flow = row["FK_Flow"].ToString(); list.FK_Dept = row["FK_Dept"].ToString(); list.SDT = row["SDTOfNode"].ToString(); list.DTOfWarning = row["SDTOfFlow"].ToString(); list.WarningHour = 0; list.RDT = row["RDT"].ToString(); list.IsEnable = true; list.IsPass = false; list.WhoExeIt = 0; list.Sender = row["Starter"].ToString(); list.PRI = 1; list.IsRead = false; list.PressTimes = 0; list.HungUpTimes = 0; list.CDT = row["RDT"].ToString(); list.Insert(); } } } } } try { string url = "../WF/WFRpt.aspx?DoType=View&WorkID={0}&FK_Flow={1}&FK_Node={2}"; string sql = "SELECT top 1 OID FROM RMS.dbo.V_FlowData WHERE ProjNo in (SELECT ProjNo FROM ND137Rpt WHERE OID='{0}') AND FK_Flow='{1}' ORDER BY OID DESC"; //列表展示 if (this.FrmView == "1") { sql = "SELECT ProjNo FROM ND137Rpt WHERE OID='{0}'"; sql = string.Format(sql, this.WorkID); string projNo = DBAccess.RunSQLReturnStringIsNull(sql, "0"); url = "ProjectInfoView.aspx?FK_Flow=" + this.FK_Flow + "&id=" + projNo; Response.Redirect(url); } else { //如果传入项目编号,直接使用 if (string.IsNullOrEmpty(this.ProjNo)) { sql = string.Format(sql, this.WorkID, this.FK_Flow); } else { sql = "SELECT top 1 OID FROM RMS.dbo.V_FlowData WHERE ProjNo ='" + this.ProjNo + "' AND FK_Flow='" + this.FK_Flow + "' ORDER BY OID DESC"; } //查到信息进行跳转,查不到进行提示 string OID = BP.DA.DBAccess.RunSQLReturnString(sql); if (!string.IsNullOrEmpty(OID)) { url = string.Format(url, OID, this.FK_Flow, this.FK_Node); Response.Redirect(url); } } } catch (Exception ex) { BP.DA.Log.DefaultLogWriteLineError(ex); } Response.Write("所选信息不存在!"); }
/// <summary> /// 执行zhanghaicheng的 发送。 /// 1,检查发送的对象。 /// 2,检查流程引擎控制表。 /// 3,检查节点表。 /// </summary> public void Step3() { // 让主线程上的发起人登录. BP.WF.Dev2Interface.Port_Login("zhanghaicheng"); // 查询出来 zhangyifan 的workid. string sql = "SELECT WorkID FROM WF_GenerWorkerList WHERE FK_Emp='zhangyifan' AND FID=" + workid; DataTable dt = BP.DA.DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count != 1) { throw new Exception("@不应该找不到子线程的."); } // 取得子线程ID. Int64 threakWorkID = Int64.Parse(dt.Rows[0][0].ToString()); // 执行删除子线程. 删除子线程与删除流程是同一个方法。 BP.WF.Dev2Interface.Flow_DoDeleteFlowByReal(this.fk_flow, threakWorkID, false); #region 第1步: 检查发送后的变量. // 检查 zhangyifan 是否有待办工作? sql = "SELECT COUNT(*) FROM WF_EmpWorks WHERE WorkID=" + threakWorkID; dt = BP.DA.DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count != 0) { throw new Exception("@不应该找到该线程的待办工作."); } //检查子流程数据是否还在? GenerWorkFlow gwf = new GenerWorkFlow(); gwf.WorkID = threakWorkID; if (gwf.IsExits == true) { throw new Exception("@子线程数据还存在,这是错误的."); } //检查子流程数据是否还在? GenerWorkerList gwl = new GenerWorkerList(); gwl.WorkID = threakWorkID; gwl.FID = workid; gwl.FK_Emp = "zhangyifan"; if (gwl.IsExits == true) { throw new Exception("@子线程数据的待办还存在,这是错误的."); } //检查主流程数据是否还在? gwf = new GenerWorkFlow(); gwf.WorkID = workid; if (gwf.IsExits == false) { throw new Exception("@主线程数据已经不存在,这是错误的."); } #endregion 第1步: 检查发送后的变量. // 删除测试数据. BP.WF.Dev2Interface.Flow_DoDeleteFlowByReal(this.fk_flow, workid, false); }
/// <summary> /// 步骤1 让zhanghaicheng 发起流程. /// </summary> public void Step1() { //给发起人赋值. starterEmp = new Port.Emp(userNo); //让 userNo 登录. 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; 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 GERptAttr.FID: if (val != "0") { throw new Exception("@应当是0"); } break; case GERptAttr.FK_Dept: if (val != WebUser.FK_Dept) { throw new Exception("@应当是" + WebUser.FK_Dept + ", 现在是:" + val); } break; case GERptAttr.FK_NY: if (val != DataType.CurrentYearMonth) { throw new Exception("@应当是" + DataType.CurrentYearMonth + ", 现在是:" + val); } break; case GERptAttr.FlowDaySpan: if (val != "0") { throw new Exception("@应当是 0 , 现在是:" + val); } break; case GERptAttr.FlowEmps: if (val.Contains(WebUser.No) == false) { throw new Exception("@应当是包含当前人员, 现在是:" + val); } break; case GERptAttr.FlowEnder: if (val != WebUser.No) { throw new Exception("@应当是 当前人员, 现在是:" + val); } break; case GERptAttr.FlowEnderRDT: if (val.Contains(DataType.CurrentData) == false) { throw new Exception("@应当是 当前日期, 现在是:" + val); } break; case GERptAttr.FlowEndNode: if (val != "2401") { throw new Exception("@应当是 2401, 现在是:" + val); } break; case GERptAttr.FlowStarter: if (val != WebUser.No) { throw new Exception("@应当是 WebUser.No, 现在是:" + val); } break; case GERptAttr.FlowStartRDT: if (string.IsNullOrEmpty(val)) { throw new Exception("@应当不能为空,现在是:" + val); } break; case GERptAttr.Title: if (string.IsNullOrEmpty(val)) { throw new Exception("@不能为空title" + val); } break; case GERptAttr.WFState: WFState sta = (WFState)int.Parse(val); if (sta != WFState.Blank) { throw new Exception("@应当是 WFState.Blank 现在是" + sta.ToString()); } break; default: break; } } #endregion 检查创建工作是否符合预期 //执行发送. objs = BP.WF.Dev2Interface.Node_SendWork(fk_flow, workID, null, null, 0, "zhoupeng"); #region 第1步: 检查发送对象. //从获取的发送对象里获取到下一个工作者. zhangyifan(张一帆)、zhoushengyu(周升雨). if (objs.VarAcceptersID != "zhoupeng") { throw new Exception("@下一步的接受人不正确, 应当是: zhoupeng.现在是:" + objs.VarAcceptersID); } if (objs.VarToNodeID != 2402) { throw new Exception("@应该是 2401 节点. 现在是:" + objs.VarToNodeID); } if (objs.VarWorkID != workID) { throw new Exception("@主线程的workid不应该变化:" + objs.VarWorkID); } if (objs.VarCurrNodeID != 2401) { throw new Exception("@当前节点的编号不能变化:" + objs.VarCurrNodeID); } if (objs.VarTreadWorkIDs != null) { throw new Exception("@不应当获得子线程WorkID."); } #endregion 第1步: 检查发送对象. #region 第2步: 检查流程引擎表. //检查创建这个空白是否有数据完整? sql = "SELECT * FROM WF_EmpWorks WHERE WorkID=" + workID + " AND FK_Emp='" + objs.VarAcceptersID + "'"; dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count == 0) { throw new Exception("@不应该找不到当前人员的待办."); } gwf = new GenerWorkFlow(workID); if (gwf.Starter != WebUser.No || gwf.StarterName != WebUser.Name) { throw new Exception("没有写入发起人的信息."); } if (gwf.FK_Dept != starterEmp.FK_Dept) { throw new Exception("@发起人的部门有变化,应当是" + starterEmp.FK_Dept + ",现在是:" + gwf.FK_Dept); } if (gwf.Starter != starterEmp.No) { throw new Exception("@发起人的 No 有变化,应当是" + starterEmp.No + ",现在是:" + gwf.Starter); } //判断当前点. if (gwf.FK_Node != 2402) { throw new Exception("@当前点应该是 2402 现在是:" + gwf.FK_Node); } //判断当前点. if (gwf.FID != 0) { throw new Exception("@当前点应该是 FID=0 现在是:" + gwf.FID); } //判断PWorkID,没有谁调用它,应当是 0. if (gwf.PWorkID != 0) { throw new Exception("@没有谁调用它, 当前点应该是 PWorkID=0 现在是:" + gwf.PWorkID); } //判断 WFState . if (gwf.WFState != WFState.Runing) { throw new Exception("@应当是 WFState=Runing 现在是:" + gwf.WFState.ToString()); } //检查开始节点 发送人的WF_GenerWorkerList 的. gwl = new GenerWorkerList(); gwl.FK_Emp = Web.WebUser.No; gwl.FK_Node = 2401; gwl.WorkID = workID; gwl.Retrieve(); // 没有分合流应当是 0 . if (gwl.FID != 0) { throw new Exception("@没有分合流应当是 0."); } if (gwl.IsEnable == false) { throw new Exception("@应该是启用的状态 "); } if (gwl.IsPass == false) { throw new Exception("@应该是通过的状态 "); } if (gwl.Sender.Contains(WebUser.No) == false) { throw new Exception("@应该是 包含当前状态 . "); } //检查接受人的 WF_GenerWorkerList 的. gwl = new GenerWorkerList(); gwl.FK_Emp = objs.VarAcceptersID; gwl.FK_Node = 2402; gwl.WorkID = workID; gwl.Retrieve(); // 没有分合流应当是 0 . if (gwl.FID != 0) { throw new Exception("@没有分合流应当是 0."); } if (gwl.IsEnable == false) { throw new Exception("@应该是启用的状态 "); } if (gwl.IsPass == true) { throw new Exception("@应该是未通过的状态 "); } if (gwl.Sender.Contains(WebUser.No) == false) { throw new Exception("@应该是 当前人发送的,现在是: " + gwl.Sender); } #endregion 第2步: 检查流程引擎表. #region 第3步: 检查节点数据表. //检查流程表的数据. sql = "SELECT * FROM " + fl.PTable + " WHERE OID=" + 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 GERptAttr.PWorkID: if (val != "0") { throw new Exception("@PWorkID应当是0, 现在是:" + val); } break; case GERptAttr.PFlowNo: if (val != "") { throw new Exception("@PFlowNo应当是 '' 现在是:" + val); } break; case GERptAttr.FID: if (val != "0") { throw new Exception("@应当是0"); } break; case GERptAttr.FK_Dept: if (val != starterEmp.FK_Dept) { throw new Exception("@应当是" + starterEmp.FK_Dept + ", 现在是:" + val); } break; case GERptAttr.FK_NY: if (val != DataType.CurrentYearMonth) { throw new Exception("@应当是" + DataType.CurrentYearMonth + ", 现在是:" + val); } break; case GERptAttr.FlowDaySpan: if (val != "0") { throw new Exception("@应当是 0 , 现在是:" + val); } break; case GERptAttr.FlowEmps: if (val.Contains(WebUser.No) == false) { throw new Exception("@应当是包含当前人员, 现在是:" + val); } break; case GERptAttr.FlowEnder: if (val != WebUser.No) { throw new Exception("@应当是 当前人员, 现在是:" + val); } break; case GERptAttr.FlowEnderRDT: if (val.Contains(DataType.CurrentData) == false) { throw new Exception("@应当是 当前日期, 现在是:" + val); } break; case GERptAttr.FlowEndNode: if (val != "2402") { throw new Exception("@应当是 2402, 现在是:" + val); } break; case GERptAttr.FlowStarter: if (val != starterEmp.No) { throw new Exception("@应当是 " + starterEmp.No + ", 现在是:" + val); } break; case GERptAttr.FlowStartRDT: if (string.IsNullOrEmpty(val)) { throw new Exception("@应当不能为空,现在是:" + val); } break; case GERptAttr.Title: if (string.IsNullOrEmpty(val)) { throw new Exception("@不能为空title" + val); } break; case GERptAttr.WFState: WFState sta = (WFState)int.Parse(val); if (sta != WFState.Runing) { throw new Exception("@应当是 WFState.Runing 现在是" + sta.ToString()); } break; default: break; } } #endregion 第3步: 检查节点数据表. }
/// <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(workid, 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> /// 恢复已完成的流程数据到指定的节点,如果节点为0就恢复到最后一个完成的节点上去. /// </summary> /// <param name="workid">要恢复的workid</param> /// <param name="backToNodeID">恢复到的节点编号,如果是0,标示回复到流程最后一个节点上去.</param> /// <param name="note"></param> /// <returns></returns> public string DoRebackFlowData(Int64 workid, int backToNodeID, string note) { if (note.Length <= 2) { return("请填写恢复已完成的流程原因."); } Flow fl = new Flow(this.No); GERpt rpt = new GERpt("ND" + int.Parse(this.No) + "Rpt"); rpt.OID = workid; int i = rpt.RetrieveFromDBSources(); if (i == 0) { throw new Exception("@错误,流程数据丢失。"); } if (backToNodeID == 0) { backToNodeID = rpt.FlowEndNode; } Emp empStarter = new Emp(rpt.FlowStarter); // 最后一个节点. Node endN = new Node(backToNodeID); GenerWorkFlow gwf = null; bool isHaveGener = false; try { #region 创建流程引擎主表数据. gwf = new GenerWorkFlow(); gwf.WorkID = workid; if (gwf.RetrieveFromDBSources() == 1) { isHaveGener = true; //判断状态 if (gwf.WFState != WFState.Complete) { throw new Exception("@当前工作ID为:" + workid + "的流程没有结束,不能采用此方法恢复。"); } } gwf.FK_Flow = this.No; gwf.FlowName = this.Name; gwf.WorkID = workid; gwf.PWorkID = rpt.PWorkID; gwf.PFlowNo = rpt.PFlowNo; gwf.PNodeID = rpt.PNodeID; gwf.PEmp = rpt.PEmp; gwf.FK_Node = backToNodeID; gwf.NodeName = endN.Name; gwf.Starter = rpt.FlowStarter; gwf.StarterName = empStarter.Name; gwf.FK_FlowSort = fl.FK_FlowSort; gwf.Title = rpt.Title; gwf.WFState = WFState.ReturnSta; /*设置为退回的状态*/ gwf.FK_Dept = rpt.FK_Dept; Dept dept = new Dept(empStarter.FK_Dept); gwf.DeptName = dept.Name; gwf.PRI = 1; DateTime dttime = DateTime.Now; dttime = dttime.AddDays(3); gwf.SDTOfNode = dttime.ToString("yyyy-MM-dd HH:mm:ss"); gwf.SDTOfFlow = dttime.ToString("yyyy-MM-dd HH:mm:ss"); if (isHaveGener) { gwf.Update(); } else { gwf.Insert(); /*插入流程引擎数据.*/ } #endregion 创建流程引擎主表数据 string ndTrack = "ND" + int.Parse(this.No) + "Track"; string actionType = (int)ActionType.Forward + "," + (int)ActionType.FlowOver + "," + (int)ActionType.ForwardFL + "," + (int)ActionType.ForwardHL; string sql = "SELECT * FROM " + ndTrack + " WHERE ActionType IN (" + actionType + ") and WorkID=" + workid + " ORDER BY RDT DESC, NDFrom "; System.Data.DataTable dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count == 0) { throw new Exception("@工作ID为:" + workid + "的数据不存在."); } string starter = ""; bool isMeetSpecNode = false; GenerWorkerList currWl = new GenerWorkerList(); foreach (DataRow dr in dt.Rows) { int ndFrom = int.Parse(dr["NDFrom"].ToString()); Node nd = new Node(ndFrom); string ndFromT = dr["NDFromT"].ToString(); string EmpFrom = dr[TrackAttr.EmpFrom].ToString(); string EmpFromT = dr[TrackAttr.EmpFromT].ToString(); // 增加上 工作人员的信息. GenerWorkerList gwl = new GenerWorkerList(); gwl.WorkID = workid; gwl.FK_Flow = this.No; gwl.FK_Node = ndFrom; gwl.FK_NodeText = ndFromT; if (gwl.FK_Node == backToNodeID) { gwl.IsPass = false; currWl = gwl; } gwl.FK_Emp = EmpFrom; gwl.FK_EmpText = EmpFromT; if (gwl.IsExits) { continue; /*有可能是反复退回的情况.*/ } Emp emp = new Emp(gwl.FK_Emp); gwl.FK_Dept = emp.FK_Dept; gwl.RDT = dr["RDT"].ToString(); gwl.SDT = dr["RDT"].ToString(); gwl.DTOfWarning = gwf.SDTOfNode; gwl.WarningHour = nd.WarningHour; gwl.IsEnable = true; gwl.WhoExeIt = nd.WhoExeIt; gwl.Insert(); } #region 加入退回信息, 让接受人能够看到退回原因. ReturnWork rw = new ReturnWork(); rw.WorkID = workid; rw.ReturnNode = backToNodeID; rw.ReturnNodeName = endN.Name; rw.Returner = WebUser.No; rw.ReturnerName = WebUser.Name; rw.ReturnToNode = currWl.FK_Node; rw.ReturnToEmp = currWl.FK_Emp; rw.Note = note; rw.RDT = DataType.CurrentDataTime; rw.IsBackTracking = false; rw.MyPK = BP.DA.DBAccess.GenerGUID(); #endregion 加入退回信息, 让接受人能够看到退回原因. //更新流程表的状态. rpt.FlowEnder = currWl.FK_Emp; rpt.WFState = WFState.ReturnSta; /*设置为退回的状态*/ rpt.FlowEndNode = currWl.FK_Node; rpt.Update(); // 向接受人发送一条消息. BP.WF.Dev2Interface.Port_SendMsg(currWl.FK_Emp, "工作恢复:" + gwf.Title, "工作被:" + WebUser.No + " 恢复." + note, "ReBack" + workid, BP.WF.SMSMsgType.ToDo, this.No, int.Parse(this.No + "01"), workid, 0); //写入该日志. WorkNode wn = new WorkNode(workid, currWl.FK_Node); wn.AddToTrack(ActionType.RebackOverFlow, currWl.FK_Emp, currWl.FK_EmpText, currWl.FK_Node, currWl.FK_NodeText, note); return("@已经还原成功,现在的流程已经复原到(" + currWl.FK_NodeText + "). @当前工作处理人为(" + currWl.FK_Emp + " , " + currWl.FK_EmpText + ") @请通知他处理工作."); } catch (Exception ex) { //此表的记录删除已取消 //gwf.Delete(); GenerWorkerList wl = new GenerWorkerList(); wl.Delete(GenerWorkerListAttr.WorkID, workid); string sqls = ""; sqls += "@UPDATE " + fl.PTable + " SET WFState=" + (int)WFState.Complete + " WHERE OID=" + workid; DBAccess.RunSQLs(sqls); return("<font color=red>会滚期间出现错误</font><hr>" + ex.Message); } }
/// <summary> /// 说明 :此测试针对于演示环境中的 001 流程编写的单元测试代码。 /// 涉及到了: 创建,发送,撤销,方向条件、退回等功能。 /// </summary> public override void Do() { string fk_flow = "001"; string userNo = "zhoutianjiao"; Flow fl = new Flow(fk_flow); // zhoutianjiao 登录. BP.WF.Dev2Interface.Port_Login(userNo); //创建空白工作, 发起开始节点. Int64 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 ND101 WHERE OID=" + workid; dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count == 0) { throw new Exception("@不应该在开始节点表单表中找不到数据,"); } #endregion 检查发起流程后的数据是否完整? //执行发送,并获取发送对象,. SendReturnObjs objs = BP.WF.Dev2Interface.Node_SendWork(fk_flow, workid); #region 检查发送对象返回的信息是否完整? //从获取的发送对象里获取到下一个工作者. string nextUser = objs.VarAcceptersID; if (nextUser != "qifenglin") { throw new Exception(WebUser.No + "启动财务报销流程,下一步的接受人不正确, 应该是qifenglin,他是部门的负责人.现在是:" + nextUser); } if (objs.VarToNodeID != 102) { throw new Exception(WebUser.No + "启动财务报销流程,下一步的节点, 应该是102.现在是:" + objs.VarToNodeID); } //检查节点表单表是否有数据? sql = "SELECT * FROM ND102 WHERE OID=" + workid; dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count == 0) { throw new Exception("@不应该在部门经理审批表节点表单表中找不到数据,"); } #endregion 检查发送对象返回的信息是否完整? //检查开始节点的执行撤销是否可用? string info = BP.WF.Dev2Interface.Flow_DoUnSend(fk_flow, workid); #region 检查撤销发送是否符合预期. //检查节点表单表是否有数据? sql = "SELECT * FROM ND102 WHERE OID=" + workid; dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count == 1) { throw new Exception("@已经撤销了,当前节点表单数据也应该删除,但是ccflow没有删除它。"); } //查询流程注册表. GenerWorkFlow gwf = new GenerWorkFlow(); gwf.WorkID = workid; gwf.RetrieveFromDBSources(); if (gwf.FK_Node != fl.StartNodeID) { throw new Exception("@撤销发送后的数据不符合预期: 没有停留到开始节点上,而是停留在了:" + gwf.FK_Node); } GenerWorkerList gwl = new GenerWorkerList(); gwl.FK_Emp = WebUser.No; gwl.FK_Node = fl.StartNodeID; gwl.WorkID = workid; gwl.Retrieve(); if (gwl.IsPass == true) { throw new Exception("@撤销发送后的数据不符合预期: 当前的操作人员的停留状态应该是未发送,现在是已发送."); } //检查qifenglin的待办工作是否还存在. gwl = new GenerWorkerList(); gwl.FK_Emp = nextUser; gwl.FK_Node = fl.StartNodeID; gwl.WorkID = workid; if (gwl.RetrieveFromDBSources() != 0) { throw new Exception("@撤销发送后的数据不符合预期: 撤销后的接受人的待办工作不应该存在."); } //通检查数据符合预期结果。 BP.WF.Dev2Interface.Node_SendWork(fk_flow, workid); #endregion 检查撤销发送是否符合预期 // 让qifenglin 登录. BP.WF.Dev2Interface.Port_Login(nextUser); //按小于.HeJiFeiYong < 10000 时向下发送。 Hashtable ht = new Hashtable(); ht.Add("HeJiFeiYong", 900); objs = BP.WF.Dev2Interface.Node_SendWork(fk_flow, workid, ht); #region 检查 HeJiFeiYong < 1000 向下发送时是否发送到财务部门上去了。 //检查节点表单表是否有数据? sql = "SELECT HeJiFeiYong FROM ND102 WHERE OID=" + workid; dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count != 1) { throw new Exception("@没有找到节点2的数据。"); } int je = int.Parse(dt.Rows[0][0].ToString()); if (je != 900) { throw new Exception("@ht 数据没有传入到节点表里面去,注意如果是自动填充字段将不能写入里面。"); } if (objs.VarAcceptersID != "yangyilei") { throw new Exception("@当合计费用小于 10000 时,执行结果不符合预期. 应该提交给财务部经理yangyilei审批.现在是:" + objs.VarAcceptersID); } //检查yangyilei 是否有待办? sql = "SELECT FK_Emp FROM WF_EmpWorks WHERE WorkID=" + workid; dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count != 1 || dt.Rows[0][0].ToString() != objs.VarAcceptersID) { throw new Exception("@执行结果不符合预期: 应该只有一个待办并且是: yangyilei."); } //检查完毕执行撤销发送, 目的是检查当数据 大于1万的方向条件. BP.WF.Dev2Interface.Flow_DoUnSend(fk_flow, workid); //检查qifenglin 是否有待办? sql = "SELECT FK_Emp FROM WF_EmpWorks WHERE WorkID=" + workid; dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count != 1 || dt.Rows[0][0].ToString() != "qifenglin") { throw new Exception("@在节点2执行撤销时,数据不符合预期: qifenglin."); } #endregion //按小于.HeJiFeiYong > 10000 时向下发送。 ht = new Hashtable(); ht.Add("HeJiFeiYong", 990999); objs = BP.WF.Dev2Interface.Node_SendWork(fk_flow, workid, ht); #region 检查当合计费用大于10000 时,数据是否符合预期. if (objs.VarAcceptersID != "zhoupeng") { throw new Exception("@在节点2时,数据大于1万,方向条件不符合预期, 应该执行到zhoupeng 现在转入了:" + objs.VarAcceptersID); } //检查zhoupeng 是否有待办? sql = "SELECT FK_Emp FROM WF_EmpWorks WHERE WorkID=" + workid; dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count != 1) { throw new Exception("@在节点2时,数据大于1万,方向条件不符合预期, 应该执行到zhoupeng一个人, 现在查询的待办结果不对, 执行的查询sql:" + sql); } if (dt.Rows[0][0].ToString() != "zhoupeng") { throw new Exception("@在节点2时,数据大于1万,方向条件不符合预期, 应该是zhoupeng 执行的查询sql:" + sql); } // 检查是否转到了 103 节点上去了? gwf = new GenerWorkFlow(); gwf.WorkID = workid; gwf.RetrieveFromDBSources(); if (gwf.FK_Node != 103) { throw new Exception("@方向条件没有转入到 103上,目前转入到了:" + gwf.FK_Node); } sql = "SELECT HeJiFeiYong FROM ND103 WHERE OID=" + workid; dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count != 1) { throw new Exception("@没有找到节点(总经理审批)的数据。"); } #endregion 检查当合计费用大于10000 时,数据是否符合预期. // 让zhoupeng 登录. BP.WF.Dev2Interface.Port_Login("zhoupeng"); //执行发送. objs = BP.WF.Dev2Interface.Node_SendWork(fk_flow, workid); #region 检查总经理审批节点发送后数据是否符合预期? if (objs.VarAcceptersID != "yangyilei") { throw new Exception("@应该发送到 yangyilei 但是没有发送给他."); } //检查qifenglin 是否有待办? sql = "SELECT FK_Emp FROM WF_EmpWorks WHERE WorkID=" + workid; dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count != 1 || dt.Rows[0][0].ToString() != "yangyilei") { throw new Exception("@应该发送到 yangyilei 但是没有发送给他."); } //检查报表数据是否完整? sql = "SELECT FlowEnder,FlowEndNode,FlowStarter,WFState,FID,FK_NY FROM ND1Rpt WHERE OID=" + workid; dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows[0]["FlowEnder"].ToString() != "zhoupeng") { throw new Exception("@应该是 zhoupeng 是 FlowEnder ."); } if (dt.Rows[0]["FlowStarter"].ToString() != "zhoutianjiao") { throw new Exception("@应该是 zhoutianjiao 是 FlowStarter ."); } if (dt.Rows[0]["FlowEndNode"].ToString() != "104") { throw new Exception("@应该是 104 是 FlowEndNode ."); } if (int.Parse(dt.Rows[0]["WFState"].ToString()) != (int)WFState.Runing) { throw new Exception("@应该是 WFState.Runing 是 WFState ."); } if (int.Parse(dt.Rows[0]["FID"].ToString()) != 0) { throw new Exception("@应该是 FID =0"); } if (dt.Rows[0]["FK_NY"].ToString() != DataType.CurrentYearMonth) { throw new Exception("@ FK_NY 字段填充错误. "); } #endregion 检查总经理审批节点发送后数据是否符合预期 // 让yangyilei 登录. BP.WF.Dev2Interface.Port_Login("yangyilei"); //执行发送, 这个是最后节点,它应该自动结束。 objs = BP.WF.Dev2Interface.Node_SendWork(fk_flow, workid); #region 检查结束节点是否符合预期? gwf = new GenerWorkFlow(); gwf.WorkID = workid; sql = "SELECT * FROM wf_GenerWorkerList WHERE WORKID=" + workid; dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count != 0) { throw new Exception("@ 流程结束后 wf_GenerWorkerList 没有删除. "); } //检查报表数据是否完整? sql = "SELECT FlowEnder,FlowEndNode,FlowStarter,WFState,FID,FK_NY FROM ND1Rpt WHERE OID=" + workid; dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows[0]["FlowEnder"].ToString() != "yangyilei") { throw new Exception("@应该是 yangyilei 是 FlowEnder ."); } if (dt.Rows[0]["FlowStarter"].ToString() != "zhoutianjiao") { throw new Exception("@应该是 zhoutianjiao 是 FlowStarter ."); } if (dt.Rows[0]["FlowEndNode"].ToString() != "104") { throw new Exception("@应该是 104 是 FlowEndNode ."); } if (int.Parse(dt.Rows[0]["WFState"].ToString()) != (int)WFState.Complete) { throw new Exception("@应该是 WFState.Complete 是 WFState ."); } if (int.Parse(dt.Rows[0]["FID"].ToString()) != 0) { throw new Exception("@应该是 FID =0"); } if (dt.Rows[0]["FK_NY"].ToString() != DataType.CurrentYearMonth) { throw new Exception("@ FK_NY 字段填充错误. "); } #endregion 检查结束节点是否符合预期 }
/// <summary> /// 特殊处理天津的流程 /// 当指定的节点,到了10号,15号自动向下发送. /// </summary> private void DoTianJinSpecFunc() { if (DateTime.Now.Day == 10 || DateTime.Now.Day == 15) { /* 一个是10号自动审批,一个是15号自动审批. */ } else { return; } #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 "; sql += " a.FK_Node=b.NodeID "; if (DateTime.Now.Day == 10) { sql += " AND b.NodeID=13304 "; } if (DateTime.Now.Day == 15) { sql += "AND b.NodeID=13302 "; } generTab = DBAccess.RunSQLReturnTable(sql); #endregion 找到要逾期的数据. // 遍历循环,逾期表进行处理. string msg = ""; foreach (DataRow row in generTab.Rows) { string fk_flow = row["FK_Flow"] + ""; string fk_node = row["FK_Node"] + ""; long workid = long.Parse(row["WorkID"] + ""); string title = row["Title"] + ""; string compleateTime = row["SDTOfNode"] + ""; string starter = row["Starter"] + ""; try { Node node = new Node(int.Parse(fk_node)); try { GenerWorkerList workerList = new GenerWorkerList(); workerList.RetrieveByAttrAnd(GenerWorkerListAttr.WorkID, workid, GenerWorkFlowAttr.FK_Node, fk_node); WebUser.SignInOfGener(workerList.HisEmp); WorkNode firstwn = new WorkNode(workid, int.Parse(fk_node)); string sendIfo = firstwn.NodeSend().ToMsgOfText(); msg = "流程 '" + node.FlowName + "',标题: '" + title + "'的应该完成时间为'" + compleateTime + "',当前节点'" + node.Name + "'超时处理规则为'自动发送到下一节点',发送消息为:" + sendIfo; //输出消息. BP.DA.Log.DefaultLogWriteLine(LogType.Info, msg); } catch (Exception ex) { msg = "流程 '" + node.FlowName + "',标题: '" + title + "'的应该完成时间为'" + compleateTime + "',当前节点'" + node.Name + "'超时处理规则为'自动发送到下一节点',发送异常:" + ex.Message; BP.DA.Log.DefaultLogWriteLine(LogType.Error, msg); } } catch (Exception ex) { BP.DA.Log.DefaultLogWriteLine(LogType.Error, ex.ToString()); } } BP.DA.Log.DefaultLogWriteLine(LogType.Info, "结束扫描逾期流程数据."); }