document.java
来自「一个用java编写的功能强大的OA系统」· Java 代码 · 共 1,589 行 · 第 1/4 页
JAVA
1,589 行
} public String getVoteResult() { return voteResult; } public String getNick() { return nick; } public java.util.Date getModDate() { return modifiedDate; } public String getModifiedDate() { java.util.Date d = modifiedDate; if (d != null) return DateUtil.format(d, "yy-MM-dd HH:mm"); else return ""; } public boolean vote(int id, int votesel) throws ErrMsgException { boolean re = false; Conn conn = new Conn(connname); try { String[] rlt = voteResult.split("\\|"); int len = rlt.length; int[] intre = new int[len]; for (int i = 0; i < len; i++) intre[i] = Integer.parseInt(rlt[i]); intre[votesel]++; String result = ""; for (int i = 0; i < len; i++) { if (result.equals("")) result = "" + intre[i]; else result += "|" + intre[i]; } String sql = "update document set voteresult=" + StrUtil.sqlstr(result) + " where id=" + id; logger.info(sql); re = conn.executeUpdate(sql) == 1 ? true : false; DocCacheMgr dcm = new DocCacheMgr(); dcm.refreshUpdate(id); } catch (SQLException e) { logger.error("vote:" + e.getMessage()); } finally { if (conn != null) { conn.close(); conn = null; } } return re; } protected long[] getDocBlock(String query, String groupKey, int startIndex) { DocCacheMgr dcm = new DocCacheMgr(); return dcm.getDocBlock(query, groupKey, startIndex); } public DocBlockIterator getDocuments(String query, String groupKey, int startIndex, int endIndex) { if (!SecurityUtil.isValidSql(query)) return null; long[] docBlock = getDocBlock(query, groupKey, startIndex); return new DocBlockIterator(docBlock, query, groupKey, startIndex, endIndex); } public int getDocCount(String sql) { DocCacheMgr dcm = new DocCacheMgr(); return dcm.getDocCount(sql); } public Document getDocument(int id) { DocCacheMgr dcm = new DocCacheMgr(); return dcm.getDocument(id); } private int type = TYPE_DOC; private String voteOption; private String voteResult; private String nick; public String getKeywords() { return keywords; } public boolean getIsRelateShow() { return isRelateShow; } private String keywords; private boolean isRelateShow; private boolean loaded = false; public boolean isLoaded() { if (id==-1) return false; return loaded; } public int getHit() { return hit; } public int getTemplateId() { return templateId; } public int getPageCount() { return pageCount; } public String getParentCode() { return parentCode; } public int getIsNew() { return isNew; } public String getAuthor() { return author; } public String getFlowTypeCode() { return flowTypeCode; } public String getColor() { return color; } public boolean isBold() { return bold; } public java.util.Date getExpireDate() { return expireDate; } public String getOrgAddr() { return orgAddr; } public java.util.Date getCreateDate() { return createDate; } private int hit = 0; private int templateId = NOTEMPLATE; public boolean AddContentPage(ServletContext application, CMSMultiFileUploadBean mfu, String content) throws ErrMsgException { String action = StrUtil.getNullStr(mfu.getFieldValue("action")); int afterpage = -1; if (action.equals("insertafter")) { String insafter = StrUtil.getNullStr(mfu.getFieldValue("afterpage")); if (StrUtil.isNumeric(insafter)) afterpage = Integer.parseInt(insafter); } int pageNo = 1; if (afterpage!=-1) pageNo = afterpage + 1; else pageNo = pageCount + 1; String isuploadfile = StrUtil.getNullString(mfu.getFieldValue( "isuploadfile")); DocContent dc = new DocContent(); if (isuploadfile.equals("false")) { if (dc.createWithoutFile(application, mfu, id, content, pageNo)) { pageCount++; return UpdatePageCount(pageCount); } } else { if (dc.create(application, mfu, id, content, pageNo)) { pageCount++; return UpdatePageCount(pageCount); } } return false; } public boolean EditContentPage(ServletContext application, CMSMultiFileUploadBean mfu) throws ErrMsgException { String strpageNum = StrUtil.getNullStr(mfu.getFieldValue("pageNum")); int pageNum = Integer.parseInt(strpageNum); DocContent dc = new DocContent(); dc = dc.getDocContent(id, pageNum); dc.setContent(content); dc.save(application, mfu); return true; } public synchronized boolean UpdatePageCount(int pagecount) throws ErrMsgException { String sql = "update document set modifiedDate=NOW(),page_count=? where id=?"; Conn conn = new Conn(connname); PreparedStatement pstmt = null; try { pstmt = conn.prepareStatement(sql); pstmt.setInt(1, pagecount); pstmt.setInt(2, id); conn.executePreUpdate(); DocCacheMgr dcm = new DocCacheMgr(); dcm.refreshUpdate(id); } catch (SQLException e) { logger.error(e.getMessage()); throw new ErrMsgException("服务器内部错!"); } finally { if (conn != null) { conn.close(); conn = null; } } return true; } private int pageCount = 1; private String parentCode; public Vector getAttachments(int pageNum) { DocContent dc = new DocContent(); dc = dc.getDocContent(id, pageNum); if (dc==null) return null; return dc.getAttachments(); } public Attachment getAttachment(int pageNum, int att_id) { Iterator ir = getAttachments(pageNum).iterator(); while (ir.hasNext()) { Attachment at = (Attachment)ir.next(); if (at.getId()==att_id) return at; } return null; } public Document getTemplate() { if (templateId == this.NOTEMPLATE) return null; else return getDocument(templateId); } public String getAbstract(HttpServletRequest request, int len, boolean isText) { int MAX_LEN2 = 10000; String docContent = StrUtil.getLeft(content, len); int idx1 = docContent.lastIndexOf('<'); int idx2 = docContent.lastIndexOf('>'); if ((idx2 == -1 && idx1 >= 0) || (idx1 > idx2)) { String ct3 = content; int idx3 = ct3.indexOf('>', idx1); if (idx3!=-1) { if (idx3 < MAX_LEN2) { docContent = ct3.substring(0, idx3 + 1); } } } idx2 = docContent.toLowerCase().lastIndexOf("</object>"); idx1 = docContent.toLowerCase().lastIndexOf("<object"); if ((idx2 == -1 && idx1 >= 0) || idx1 > idx2) { String ct2 = content.toLowerCase(); int idx3 = ct2.indexOf("</object>"); if (idx3 != -1) docContent += content.substring(docContent.length(), docContent.length() + idx3 + 9); else docContent = content.substring(0, idx1); } String str = ""; try { Parser myParser; NodeList nodeList = null; myParser = Parser.createParser(docContent, "utf-8"); NodeFilter textFilter = new NodeClassFilter(TextNode.class); NodeFilter linkFilter = new NodeClassFilter(LinkTag.class); NodeFilter imgFilter = new NodeClassFilter(ImageTag.class); OrFilter lastFilter = new OrFilter(); lastFilter.setPredicates(new NodeFilter[] {textFilter, linkFilter, imgFilter}); nodeList = myParser.parse(lastFilter); Node[] nodes = nodeList.toNodeArray(); for (int i = 0; i < nodes.length; i++) { Node anode = (Node) nodes[i]; String line = ""; if (anode instanceof TextNode) { TextNode textnode = (TextNode) anode; line = textnode.getText(); } else if (anode instanceof ImageTag) { if (!isText) { ImageTag imagenode = (ImageTag) anode; String url = imagenode.getImageURL(); String ext = StrUtil.getFileExt(url).toLowerCase(); if (ext.equals("gif") || ext.equals("png") || ext.equals("jpg") || ext.equals("jpeg") || ext.equals("bmp")) { if (imagenode.getImageURL().startsWith("http")) ; else if (imagenode.getImageURL().startsWith("/")) { ; } else { url = request.getContextPath() + "/forum/" + imagenode.getImageURL(); } line = "<div align=center><a onfocus=this.blur() href=\"" + url + "\" target=_blank><IMG SRC=\"" + url + "\" border=0 alt=" + SkinUtil.LoadString(request, "res.cn.js.fan.util.StrUtil", "click_open_win") + " onload=\"javascript:if(this.width>screen.width*0.4) this.width=screen.width*0.4\"></a></div><BR>"; } } } if (line==null || line.trim().equals("")) continue; str += line; } } catch (ParserException e) { LogUtil.getLog(getClass()).error("getAbstract:" + e.getMessage()); } return str; } public boolean UpdateExamine(int examine) throws ErrMsgException { String sql = "update document set examine=? where id=?"; Conn conn = new Conn(connname); PreparedStatement pstmt = null; try { pstmt = conn.prepareStatement(sql); pstmt.setInt(1, examine); pstmt.setInt(2, id); conn.executePreUpdate(); DocCacheMgr dcm = new DocCacheMgr(); dcm.refreshUpdate(id, class1, parentCode); } catch (SQLException e) { logger.error(e.getMessage()); throw new ErrMsgException("Err db."); } finally { if (conn != null) { conn.close(); conn = null; } } return true; } private int isNew = 0; private String author; private String flowTypeCode = ""; private String color; private boolean bold; private java.util.Date expireDate; private String orgAddr; private java.util.Date createDate;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?