带有多个计数调用的计数表达式示例
本主题提供了在一个表达式中使用多个计数调用以及避免两次触发同一事件的示例。
参考工作流
TallyExpressionWithTwoTallyCalls.xml
说明
同一表达式中可能有多个计数调用。在这种情况下,可能会多次将同一路由事件添加到事件列表中。要避免这种情况,请使用 setEvents( ) 方法,如示例中所示。此方法收集未复制的路由事件,从而使列表中的每个路由事件都只激发一次。下面的表达式会轮询“测试”的选取次数,并将结果保存在矢量 tallyResults 中。然后轮询选取“修改”而不是其他两个的工作负责人的百分比。此轮询的结果现在被添加到矢量 tallyResults。使用 setEvents 方法可防止“修改”事件 (在两次标签调用中都出现) 在要激发的事件列表中出现两次。然后将结果设置为矢量 tallyResults。
指示
此活动的路由事件数量不限。只有评选为工作流定义中的必需工作负责人的投票才会用于轮询。
复制下列代码:
//Create a vector that will hold all the non-duplicated UserEvents chosen for this activity.
Vector tallyResults = new Vector( );
//Get the object representing this activity.
wt.workflow.work.WfAssignedActivity mySelf = (( wt.workflow.work.WfAssignedActivity ) self.getObject( ));
//Get all the UserEvents for this activity. The resulting Vector may hold duplicate values of some events.
Vector userEvents = (Vector) mySelf.getUserEventList( );
//If "Test" receives 2 or more of the required votes, get "Test", else get "Modify".
//Collect the non-duplicated events into the Vector tallyResults ( i.e add only those events that do not already exist in the vector.
WfTally.setEvents(tallyResults , wt.workflow.work.WfTally.number(self , WfTally.GTE, 2, "Test", "Modify"));
//If "Modify" receives more than 35% of the required votes, get "Modify" else get "Approve and Release".
//Collect the non-duplicated events into the Vector tallyResults ( i.e add only those events that do not already exist in the vector.
WfTally.setEvents(tallyResults , wt.workflow.work.WfTally.percent(self , WfTally.GT, 35, "Modify", "Approve and Release"));
//set result to the tallyResults Vector.
result= tallyResults