/** * 取配置信息,构建成JSON对象 * * @param userId -- 用户信息 * @return */ public String getPortalJson(String userId) { // 取用户所属角色的模板信息 List<Map<String, String>> lsTemp = queryTemplet(userId); if (lsTemp.isEmpty()) { // "构建首页失败,因为用户所属角色没有定义PORTAL模板!" setMessage(JsMessage.getValue("portalquery.notemp")); return _returnFaild; } // 构建PORTAL的JSON StringBuilder sbtemps = new StringBuilder(); for (int i = 0, n = lsTemp.size(); i < n; i++) { Map<String, String> mpTemp = lsTemp.get(i); try { String tempJson = templetJson(mpTemp); sbtemps.append(tempJson); sbtemps.append((i < n - 1) ? ",\n" : "\n"); } catch (BoException e) { _log.showError(e); setMessage(e.getMessage()); return _returnFaild; } } String portalJson = "{portalnum:" + lsTemp.size() + ", portals:[\n" + sbtemps.toString() + "]}"; _log.showDebug("---------portalJson=" + portalJson); setReturnData(portalJson); return _returnSuccess; }
/** * 批量发布公告。 * * @param keyIds -- 消息数组ID * @return */ public String gridSendMsg(String[] keyIds) { if (keyIds == null || keyIds.length == 0) { // "发送消息ID为空!" setMessage(JsMessage.getValue("portlet.msgidisnull")); return _returnFaild; } // 发送消息 try { for (int i = 0, n = keyIds.length; i < n; i++) { sendMsg(keyIds[i]); } } catch (BoException e) { _log.showError(e); setMessage(e.getMessage()); return _returnFaild; } return _returnSuccess; }
/** * 发布公告,如果有消息ID说明是先保存了再发送的,如果没有消息ID则需要先保存再发送。 * * @param requestContext * @return */ public String formSendMsg(RequestContext requestContext) { String sKeyID = requestContext.getRequestValue(JsParam.KEYID); // 消息ID为空,先保存再发送 if (sKeyID == null || sKeyID.length() == 0) { CreateEvent ce = new CreateEvent(); String bret = ce.create(requestContext); if (bret.equals(_returnFaild)) return _returnFaild; sKeyID = requestContext.getRequestValue(JsParam.KEYID); } // 发送消息 try { sendMsg(sKeyID); } catch (BoException e) { _log.showError(e); setMessage(e.getMessage()); return _returnFaild; } return _returnSuccess; }