给一个人发送通知可以直接调用TaskHelper.createNotice
如下:
public static void sendNotice() { String sData1 = "C69A1218E1B747278351EA20C7C35B4B"; // 获得通知接收者 List<OrgUnit> ls = new ArrayList<OrgUnit>(); ls = OrgUtils.findPersonMembersByID("ORG01", "PSN01"); // 设置通知为打开时抢占、打开后自动结束 Map<String, Object> varMap = new HashMap<String, Object>(); varMap.put("sExecuteMode2", com.justep.system.process.TaskExecuteMode2.FINISH_WHEN_OPEN); varMap.put("sPreemptMode", com.justep.system.process.TaskPreemptMode.OPEN); // 创建通知,执行保存方法,即发送通知 Task t = TaskHelper.createNotice("自定义通知", "/appdemo/test/process/date/dateProcess", "mainActivity", "/appdemo/test/process/date/mainActivity.a", "/appdemo/test/process/date/mainActivity.a",sData1, ls.get(0), varMap); t.save(); }
同时给多人发送通知需要用TaskHelper.createTask
如下:
public static void sendNotice() { String sData1 = "C69A1218E1B747278351EA20C7C35B4B"; // 获得通知接收者 List<OrgUnit> ls = new ArrayList<OrgUnit>(); ls.add(OrgUtils.findPersonMembersByID("ORG01", "PSN01").get(0)); OrgUnit unit = new OrgUnit("/ORG01.ogn/9B38128D8B33435DBB6781B6E04AE7FE@ORG01.psm","/起步软件/001"); ls.add(unit); // 设置通知打开后自动结束、打开时抢占 Map<String, Object> varMap = new HashMap<String, Object>(); varMap.put("sExecuteMode2", com.justep.system.process.TaskExecuteMode2.FINISH_WHEN_OPEN); varMap.put("sPreemptMode", com.justep.system.process.TaskPreemptMode.OPEN); varMap.put("sKindID", com.justep.system.process.TaskKind.NOTICE ); // 创建通知,执行保存方法,即发送通知 Task t = TaskHelper.createTask("给多人发送通知", "/appdemo/test/process/date/dateProcess", "mainActivity", "/appdemo/test/process/date/mainActivity.a", "/appdemo/test/process/date/mainActivity.a",sData1, ls, varMap); t.save(); }
这样创建的通知默认多人之间是抢占模式,如果多人需要同时处理可以用下面的API设置
varMap.put(“sExecuteMode”, com.justep.system.process.TaskExecuteMode.SIMULTANEOUS);
评一波