package cn.com.smartbi.workflow;
import smartbi.net.sf.json.JSONArray;
import smartbi.net.sf.json.JSONObject;
import smartbi.sdk.ClientConnector;
import smartbi.sdk.InvokeResult;
import smartbi.sdk.RemoteException;
public class WorkflowAPITest {
public static void main(String[] args) {
String Smartbi_URL = "http://10.10.202.17:19700/smartbi";
ClientConnector conn = new ClientConnector(Smartbi_URL);
InvokeResult result = null;
try {
// 先以指定用户登录smartbi
boolean ret = conn.open("admin", "admin");
if (ret) {
// 获取待办数量
// {"retCode":0,"result":{"startCount":31,"doneCount":11,"todoCount":14},"duration":10}
result = conn.remoteInvoke("WorkflowModule", "allCount", new Object[] { null });
if ("0".equals(result.getOriginalResult().optString("retCode"))) {
JSONObject json = (JSONObject) result.getResult();
System.out.println("待办数:" + json.optInt("todoCount"));
System.out.println("已办数:" + json.optInt("doneCount"));
System.out.println("我的发起数:" + json.optInt("startCount"));
}
// 搜索关键字
String keyword = "";
// 开始页码
int pageNo = 0;
// 每页记录数
int pageSize = Integer.MAX_VALUE;
// 获取待办列表
result = conn.remoteInvoke("WorkflowModule", "todoList", new Object[] { keyword, pageNo, pageSize });
if ("0".equals(result.getOriginalResult().optString("retCode"))) {
JSONArray json = (JSONArray) result.getResult();
if (json.length() > 0) {
System.out.println("待办:" + json.get(0).toString());
}
}
// 获取已办
result = conn.remoteInvoke("WorkflowModule", "doneList", new Object[] { keyword, pageNo, pageSize });
if ("0".equals(result.getOriginalResult().optString("retCode"))) {
JSONArray json = (JSONArray) result.getResult();
if (json.length() > 0) {
System.out.println("已办:" + json.get(0).toString());
}
}
// 获取我的发起
result = conn.remoteInvoke("WorkflowModule", "startList", new Object[] { keyword, pageNo, pageSize });
if ("0".equals(result.getOriginalResult().optString("retCode"))) {
JSONArray json = (JSONArray) result.getResult();
if (json.length() > 0) {
System.out.println("我的发起办:" + json.get(0).toString());
}
}
}
} catch (RemoteException e) {
e.printStackTrace();
} finally {
conn.close();
}
}
}