72 lines
1.9 KiB
Java
72 lines
1.9 KiB
Java
package com.amarsoft.aims.flow.exp;
|
|
|
|
import com.amarsoft.amarscript.Any;
|
|
import com.amarsoft.amarscript.Expression;
|
|
import com.amarsoft.awe.util.Transaction;
|
|
import com.amarsoft.biz.workflow.FlowTask;
|
|
/**
|
|
* 处理流程中表达式解析
|
|
* @author SHIGUANGHUA347
|
|
*
|
|
*/
|
|
public class FlowExpressionTool {
|
|
public static Any executeScript(String script, FlowTask task, Transaction Sqlca) throws Exception {
|
|
Any rel = null;
|
|
if ((script != null) && (!script.equals("")) && (script.trim().length() > 0)){
|
|
try {
|
|
String [][] oConstantList = task.getConstantList();
|
|
String [][] constantList = new String[oConstantList.length + 1][2];
|
|
for(int i = 0; i < oConstantList.length; i++){
|
|
constantList[i][0] = oConstantList[i][0];
|
|
constantList[i][1] = oConstantList[i][1];
|
|
}
|
|
constantList[oConstantList.length][0] = "#ForkNo";
|
|
constantList[oConstantList.length][1] = task.ForkNo;
|
|
|
|
script = Expression.pretreatConstant(script, constantList);
|
|
rel = Expression.getExpressionValue(script, Sqlca);
|
|
} catch (Exception ex) {
|
|
throw new Exception(ex.toString() + " " + script + "定义错误!");
|
|
}
|
|
}
|
|
|
|
return rel;
|
|
}
|
|
|
|
public static Any executeScript(String script, String taskNo, Transaction Sqlca) throws Exception {
|
|
Any rel = null;
|
|
|
|
boolean b = false;
|
|
try{
|
|
if(Sqlca == null){
|
|
Sqlca = Transaction.createTransaction("als");
|
|
b = true;
|
|
}
|
|
FlowTask task = new FlowTask(taskNo, Sqlca);
|
|
rel = executeScript(script, task, Sqlca);
|
|
} catch (Exception ex) {
|
|
if (b && Sqlca != null){
|
|
try {
|
|
Sqlca.rollback();
|
|
} catch (Exception e1) {
|
|
e1.printStackTrace();
|
|
}
|
|
}
|
|
|
|
throw new Exception(ex.toString() + " " + script + "定义错误!");
|
|
} finally {
|
|
if (b && Sqlca != null){
|
|
try {
|
|
Sqlca.commit();
|
|
Sqlca.disConnect();
|
|
Sqlca = null;
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
|
|
return rel;
|
|
}
|
|
}
|