同步化自訂工作流程事件
本主題提供一個「同步」自動機制節點範例,該節點可暫停流程的進行,直到另一流程裡的某個特定的使用者定義事件觸發後再進行。
參考的工作流程
SynchronizationOfUserDefinedEvents.xml
UserEventsWorkflow.xml
描述
您能定義自動機制,該機制可暫停流程的進行,直到另一流程裡的某個使用者定義事件觸發後再進行。在下列運算式中,自動機制會聽取活動的 ACTIVITY_STATE_CHANGED 事件,並檢查三種使用者定義的事件 (thermal analysis、fatigue analysis 或 stress analysis) 中是否有任一種已經被觸發。這些事件都有自己對應的、必須要觸發的事件,並會將其新增到 vector: tempResult。最後,它會將其結果設定到 Vector tempResult。現在,自動機制會觸發結果 Vector 內容已觸發的事件。
指示
複製下述的程式碼:
Vector tempResult = new Vector ();
//Get activity that caused the event
WfAssignedActivity activity = (WfAssignedActivity) (( wt.events.KeyedEvent) event).getEventTarget();
//Check if the activity and process are the one's we're looking for
if (activity.getName().equals(activityName)){
//Check if the Parent process of the activity is the one we are interested in.
if (activity.getParentProcess().getName().equals(processName)){
//Check if the list of events for the activity contains the event "thermal analysis".
//If so, add to the Vector tempResult, the appropriate event to fire for the robot.
if (activity.getAllEvents().contains("thermal analysis")){
tempResult.addElement("thermal analysis");
}
//Check if the list of events for the activity contains the event "fatigue analysis".
//If so, add to the Vector tempResult, appropriate event for the robot.
if (activity.getAllEvents().contains("fatigue analysis")){
tempResult.addElement("fatigue analysis");
}
//Check if the list of events for the activity contains the event "stress analysis".
//If so, add to the Vector tempResult, appropriate event for the robot.
if (activity.getAllEvents().contains("stress analysis")){
tempResult.addElement("stress analysis");
}
}
}
//Set result to the Vector tempResult.
//Note that in the previous steps, all the events that the robot must fire were added to tempResult.
result = tempResult;