/// <summary> /// 测试案例说明: /// 1, . 这是一个标准的发送效率测试. /// 2, . 执行了createworkid 之后进行发送. /// </summary> public override void Do() { this.AddNote("开始执行发送....."); String userNo = "admin"; BP.Port.Emp emp = new BP.Port.Emp(userNo); BP.Web.WebUser.SignInOfGener(emp); BP.WF.UnitTesting.TestAPI api = new BP.WF.UnitTesting.TestAPI(); api.No = "SendWork"; api.Name = "标准的工作发送"; api.Save(); BP.WF.UnitTesting.TestVer apiVer = new BP.WF.UnitTesting.TestVer(); apiVer.No = "SendWork" + BP.DA.DataType.CurrentDataTime; apiVer.Name = "版本" + apiVer.No; try { //定义了10个样本. 对该过程执行10次。 for (int idx = 0; idx < 5; idx++) { DateTime startTime = System.DateTime.Now; for (int i = 0; i <= 1000; i++) { long workid = BP.WF.Dev2Interface.Node_CreateBlankWork("230"); BP.WF.SendReturnObjs objs = BP.WF.Dev2Interface.Node_SendWork("230", workid, 0, "admin"); } //doSomeThing(); //要运行的java程序 DateTime endTime = System.DateTime.Now; TimeSpan ts = endTime - startTime; BP.WF.UnitTesting.TestSample dtl = new BP.WF.UnitTesting.TestSample(); dtl.MyPK = BP.DA.DBAccess.GenerGUID(); dtl.FK_API = api.No; dtl.FK_Ver = apiVer.No; dtl.DTFrom = startTime.ToShortTimeString(); dtl.DTTo = endTime.ToShortTimeString(); dtl.Name = api.Name + "-" + apiVer.Name; dtl.TimeUse = ts.TotalMilliseconds; dtl.TimesPerSecond = ts.TotalMilliseconds / 1000; dtl.Insert(); } apiVer.Insert(); //执行成功后,版本号在插入里面. } catch (Exception ex) { BP.WF.UnitTesting.TestSample dtl = new BP.WF.UnitTesting.TestSample(); dtl.Delete(BP.WF.UnitTesting.TestSampleAttr.FK_Ver, apiVer.No); throw ex; } this.AddNote("查看数据: <a href=''></a>"); }
//批量退回 void btnDelete_Return_Click(object sender, EventArgs e) { string sql = "SELECT Title,RDT,ADT,SDT,FID,WorkID,Starter FROM WF_EmpWorks WHERE FK_Emp='" + WebUser.No + "'"; DataTable dt = BP.DA.DBAccess.RunSQLReturnTable(sql); BP.WF.Node nd = new BP.WF.Node(this.FK_Node); string msg = ""; foreach (DataRow dr in dt.Rows) { Int64 workid = Int64.Parse(dr["WorkID"].ToString()); Int64 fid = Int64.Parse(dr["FID"].ToString()); CheckBox cb = this.Pub1.GetCBByID("CB_" + workid); if (cb == null || cb.Checked == false) { continue; } msg += "@对工作(" + dr["Title"] + ")处理情况如下。<br>"; BP.WF.SendReturnObjs objs = null;// BP.WF.Dev2Interface.Node_ReturnWork(nd.FK_Flow, workid,fid,this.FK_Node,"批量退回"); msg += objs.ToMsgOfHtml(); msg += "<hr>"; } if (msg == "") { this.Alert("您没有选择工作."); } else { this.Pub1.Clear(); msg += "<a href='Batch.aspx'>返回...</a>"; this.Pub1.AddMsgOfInfo("批量处理信息", msg); } }
/// <summary> /// ccbpm API开发 Demo /// </summary> public void ccbpmDemo() { // 让用户登录. BP.WF.Dev2Interface.Port_Login("liyan"); //定义一个测试的流程编号. string flowNo = "001"; #region ccbpm 的最简单的API操作。 //创建一个workid. Int64 workid = BP.WF.Dev2Interface.Node_CreateBlankWork(flowNo); //执行开始节点的发发送,获得一个发送对象. BP.WF.SendReturnObjs objs = BP.WF.Dev2Interface.Node_SendWork(flowNo, workid); //输出发送对象,流程在发送的时候会把发送的过程记录在这个对象里,比如:发送给谁?发送到那个节点了?提示的信息是什么?是否发送成功? foreach (BP.WF.SendReturnObj obj in objs) { this.Response.Write("Key=" + obj.MsgFlag + " Value=" + obj.MsgOfText); } //获取发送到节点ID. int nextNodeID = objs.VarToNodeID; //获取接受人, 多个的话,用逗号分开的,比如: zhangsan,lisi string nextWorker = objs.VarAcceptersID; //如果发送人这个时间感到发送错误了,忘记了填写东西 ,需要撤销,就执行撤销API. //if (1 == 2) //{ // //执行撤销API. // BP.WF.Dev2Interface.Flow_DoUnSend(flowNo, workid); //} ////让下一个接受人登录, 让其执行发送。 //BP.WF.Dev2Interface.Port_Login(nextWorker); //// 如果你要退回,就执行退回接口. //if (1 == 2) //{ // BP.WF.Dev2Interface.Node_ReturnWork(flowNo, workid, 0, nextNodeID, 101, "退回测试", false); // return; //} //// 如果你要删除,就执行删除接口. //if (1 == 2) //{ // BP.WF.Dev2Interface.Flow_DoDeleteFlowByReal(flowNo, workid, false); // return; //} //// 如果你要移交,就执行移交接口. //if (1 == 2) //{ // BP.WF.Dev2Interface.Node_Shift(flowNo,nextNodeID,workid,0,"fuhui","移交测试."); // return; //} // 执行下一步发送。 objs = BP.WF.Dev2Interface.Node_SendWork(flowNo, workid); //objs.VarWorkID #endregion ccbpm 的最简单的API操作。 }
//发送 void btn_Send_Click(object sender, EventArgs e) { //string sql = "SELECT Title,RDT,ADT,SDT,FID,WorkID,Starter FROM WF_EmpWorks WHERE FK_Emp='" + WebUser.No + "'"; string sql = string.Format("SELECT Title,RDT,ADT,SDT,FID,WorkID,Starter FROM WF_EmpWorks WHERE FK_Emp='{0}' and FK_Node='{1}'", WebUser.No, this.FK_Node); DataTable dt = BP.DA.DBAccess.RunSQLReturnTable(sql); BP.WF.Node nd = new BP.WF.Node(this.FK_Node); string[] strs = nd.BatchParas.Split(','); MapAttrs attrs = new MapAttrs(this.FK_MapData); string msg = ""; int idx = -1; string workids = null; if (nd.BatchParas_IsSelfUrl == true) { workids = ""; } foreach (DataRow dr in dt.Rows) { idx++; if (idx == nd.BatchListCount) { break; } Int64 workid = Int64.Parse(dr["WorkID"].ToString()); CheckBox cb = this.Pub1.GetCBByID("CB_" + workid); if (cb == null || cb.Checked == false) { continue; } // 如果是自定义的,就记录workids, 让其转到 if (nd.BatchParas_IsSelfUrl == true) { workids += "," + workid; continue; } Hashtable ht = new Hashtable(); #region 给属性赋值. bool isChange = false; foreach (string str in strs) { if (string.IsNullOrEmpty(str)) { continue; } foreach (MapAttr attr in attrs) { if (str != attr.KeyOfEn) { continue; } if (attr.LGType == FieldTypeS.Normal) { TB tb = this.Pub1.GetTBByID("TB_" + attr.KeyOfEn + "_" + workid); if (tb != null) { if (tb.Text != attr.DefVal) { isChange = true; } ht.Add(str, tb.Text); continue; } cb = this.Pub1.GetCBByID("CB_" + attr.KeyOfEn + "_" + workid); if (cb != null) { if (cb.Checked != attr.DefValOfBool) { isChange = true; } if (cb.Checked) { ht.Add(str, 1); } else { ht.Add(str, 0); } continue; } } else { DDL ddl = this.Pub1.GetDDLByID("DDL_" + attr.KeyOfEn + "_" + workid); if (ddl != null) { if (ddl.SelectedItemStringVal != attr.DefVal) { isChange = true; } if (attr.LGType == FieldTypeS.Enum) { ht.Add(str, ddl.SelectedItemIntVal); } else { ht.Add(str, ddl.SelectedItemStringVal); } continue; } } } } #endregion 给属性赋值. msg += "<fieldset>"; msg += "<legend>@对工作(" + dr["Title"] + ")处理情况如下。</legend>"; BP.WF.SendReturnObjs objs = BP.WF.Dev2Interface.Node_SendWork(nd.FK_Flow, workid, ht); msg += objs.ToMsgOfHtml(); msg += "</fieldset>"; } if (nd.BatchParas_IsSelfUrl == true) { if (workids == "") { this.Alert("您没有选择工作."); } else { this.Response.Redirect("BatchSelfDeal.aspx?FK_Node=" + this.FK_Node + "&FK_Flow=" + nd.FK_Flow + "&WorkIDs=" + workids, true); } return; } if (msg == "") { this.Alert("您没有选择工作."); } else { this.Pub1.Clear(); msg += "<a href='Batch.aspx'>返回...</a>"; this.Pub1.AddMsgOfInfo("批量处理信息", msg); } }