Teamcenter的rac端开发中NewProcessCommand类流程触发详细介绍及样例
时间: 2023-02-16 22:50:35 浏览: 95
Teamcenter二次开发培训教程(RCP,ITK).pdf
5星 · 资源好评率100%
Teamcenter中的RAC(Remote Application Connector)端开发中,NewProcessCommand类是用来触发流程的。该类继承自com.teamcenter.rac.kernel.TCSession的Command类,通过重写execute()方法来实现流程的触发。
下面是一个使用NewProcessCommand类触发流程的样例:
```java
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.services.rac.workflow._2008_06.Workflow;
import com.teamcenter.services.rac.workflow._2008_06.WorkflowService;
public class StartProcessCommand extends NewProcessCommand {
private TCSession session;
private String processName;
private String[] inputArgumentNames;
private String[] inputArgumentValues;
public StartProcessCommand(TCSession session, String processName,
String[] inputArgumentNames, String[] inputArgumentValues) {
this.session = session;
this.processName = processName;
this.inputArgumentNames = inputArgumentNames;
this.inputArgumentValues = inputArgumentValues;
}
public void execute() {
try {
WorkflowService workflowService = WorkflowService.getService(session);
Workflow.ProcessInfo processInfo = workflowService.startProcess(processName, inputArgumentNames, inputArgumentValues);
String processId = processInfo.processId;
System.out.println("Process " + processName + " started with ID: " + processId);
} catch (Exception e) {
e.printStackTrace();
}
}
}
```
这个样例中,StartProcessCommand类继承自NewProcessCommand类。通过调用workflowService.startProcess(processName, inputArgumentNames, inputArgumentValues)来触发流程。
在这个样例中,processName 是流程名称,inputArgumentNames和inputArgumentValues是传入流程所需要的参数。
阅读全文