物件狀態的同步
本主題提供一個「同步」自動機制節點範例,該節點可辨別文件何時達到指定生命週期狀態。
參考的工作流程
SynchronizeOn State.xml
描述
此運算式會聽取文件的狀態,當文件被釋放時,即會觸發。自動機制接聽的事件為 wt.lifecycle.lifeCycleServiceEvent.STATE_CHANGE,而自動機制接聽的 Windchill 類別則是 wt.doc.WTDocument。
指示
在工作流程範本的 System 資料夾中建立文件。定義名為 docNumber 的變數,並賦予它一個與剛才所建立的文件相同的編號,作為預設值。請注意,此變數是 java.lang.String。
複製下述的程式碼:
//fetch the object that emitted the State_change event.
wt.doc.WTDocument targetObject = ( wt.doc.WTDocument ) ((wt.events.KeyedEvent) event).getEventTarget();
//Set the result to null so the robot keeps running until the condition is satisfied.
result=nul
l
//check if the object that emitted the state_change event is the same document that the Robot is looking for.
// docNumber is a variable that holds the number of the document that the Robot is looking for.
if ( targetObject.getNumber( ).equals ((( wt.doc.WTDocument ) primaryBusinessObject). getNumber ())){
//check if the document has been released. If so, fire the next activity else the result is null so the robot keeps running //in the background.
if ( targetObject.getLifeCycleState ().equals ( wt.lifecycle.State.RELEASED )){
result = "released";
}
}
這是否有幫助?