⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 document.java

📁 oa 源码
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
package com.redmoon.oa.flow;import java.io.File;import java.sql.*;import java.sql.Date;import java.util.Iterator;import java.util.Vector;import javax.servlet.ServletContext;import cn.js.fan.base.ITagSupport;import cn.js.fan.db.Conn;import cn.js.fan.security.SecurityUtil;import cn.js.fan.util.ErrMsgException;import cn.js.fan.util.StrUtil;import cn.js.fan.web.Global;import com.redmoon.kit.util.FileInfo;import org.apache.log4j.Logger;import com.redmoon.oa.db.SequenceManager;public class Document implements java.io.Serializable, ITagSupport {    public static final int NOTEMPLATE = -1;    String connname = "";    int id = -1;    String title;    String content;    String date;    String class1;    Date modifiedDate;    String summary;    boolean isHome = false;    int examine = 0;    public static final int EXAMINE_NOT = 0;     public static final int EXAMINE_NOTPASS = 1;     public static final int EXAMINE_PASS = 2;     transient Logger logger = Logger.getLogger(Document.class.getName());    private static final String INSERT_DOCUMENT =            "INSERT into flow_document (id, title, class1, type, voteoption, voteresult, nick, keywords, isrelateshow, can_comment, hit, template_id, parent_code, examine, isNew, author, flowTypeCode, modifiedDate) VALUES (?,?,?,?,?,?,?,?,?,?,0,?,?,?,?,?,?,NOW())";    private static final String LOAD_DOCUMENT =            "SELECT title, class1, modifiedDate, can_comment,summary,ishome,type,voteOption,voteResult,examine,nick,keywords,isrelateshow,hit,template_id,page_count,parent_code,isNew,author,flowTypeCode FROM flow_document WHERE id=?";    private static final String DEL_DOCUMENT =            "delete FROM flow_document WHERE id=?";    private static final String SAVE_DOCUMENT =            "UPDATE flow_document SET title=?, can_comment=?, ishome=?, modifiedDate=NOW(),examine=?,keywords=?,isrelateshow=?,template_id=?,class1=?,isNew=?,author=?,flowTypeCode=? WHERE id=?";    private static final String SAVE_SUMMARY =            "UPDATE flow_document SET summary=? WHERE id=?";    private static final String SAVE_HIT =            "UPDATE flow_document SET hit=? WHERE id=?";    public Document() {        connname = Global.defaultDB;        if (connname.equals(""))            logger.info("Document:默认数据库名为空!");    }        public Document(int id) {        connname = Global.defaultDB;        if (connname.equals(""))            logger.info("Directory:默认数据库名为空!");        this.id = id;        loadFromDB();    }    public void renew() {        if (logger==null)            logger = Logger.getLogger(Document.class.getName());    }        public int getIDOrCreateByCode(String code, String nick) {        int myid = getFirstIDByCode(code);        if (myid != -1) {            this.id = myid;            loadFromDB();        } else {             title = "";            content = " ";             Leaf leaf = new Leaf();            leaf = leaf.getLeaf(code);            create(code, title, content, 0, "", "", nick, leaf.getTemplateId(), nick);            this.id = getFirstIDByCode(code);                                    leaf.setDocID(id);            leaf.update();        }        return id;    }    public void delDocumentByDirCode(String code) throws ErrMsgException {        Vector v = getDocumentsByDirCode(code);        Iterator ir = v.iterator();        while (ir.hasNext()) {            Document doc = (Document) ir.next();            doc.del();        }    }    public Vector getDocumentsByDirCode(String code) {        Vector v = new Vector();        String sql = "select id from flow_document where class1=" +                     StrUtil.sqlstr(code);        Conn conn = new Conn(connname);        ResultSet rs = null;        try {            rs = conn.executeQuery(sql);            if (rs != null) {               while (rs.next()) {                   v.addElement(getDocument(rs.getInt(1)));               }            }        } catch (SQLException e) {            logger.error(e.getMessage());        } finally {            if (rs != null) {                try {                    rs.close();                } catch (Exception e) {}            }            if (conn != null) {                conn.close();                conn = null;            }        }        return v;    }        public int getFirstIDByCode(String code) {        String sql = "select id from flow_document where class1=" +                     StrUtil.sqlstr(code);        Conn conn = new Conn(connname);        ResultSet rs = null;        try {            rs = conn.executeQuery(sql);            if (rs != null && rs.next()) {                return rs.getInt(1);            }        } catch (SQLException e) {            logger.error(e.getMessage());        } finally {            if (rs != null) {                try {                    rs.close();                } catch (Exception e) {}            }            if (conn != null) {                conn.close();                conn = null;            }        }        return -1;    }    public String getSummary() {        return this.summary;    }    public int getID() {        return id;    }    public void setID(int id) {        this.id = id;    }    public String getTitle() {        return title;    }    public boolean getIsHome() {        return this.isHome;    }    public void setIsHome(boolean h) {        this.isHome = h;    }    public void setType(int type) {        this.type = type;    }    public void setVoteOption(String voteOption) {        this.voteOption = voteOption;    }    public void setVoteResult(String voteResult) {        this.voteResult = voteResult;    }    public String getContent(int pageNum) {        DocContent dc = new DocContent();        dc = dc.getDocContent(id, pageNum);        if (dc!=null)            return dc.getContent();        else            return null;    }        public Vector list(String sql, int count) {        ResultSet rs = null;        Vector result = new Vector();        Conn conn = new Conn(connname);        try {            rs = conn.executeQuery(sql);            if (rs == null) {                return result;            } else {                                rs.setFetchSize(count);                 while (rs.next()) {                    int id = rs.getInt(1);                    Document doc = getDocument(id);                    result.addElement(doc);                }            }        } catch (SQLException e) {            logger.error("list: " + e.getMessage());        } finally {            if (conn != null) {                conn.close();                conn = null;            }        }        return result;    }    public DocContent getDocContent(int pageNum) {        DocContent dc = new DocContent();        return dc.getDocContent(id, pageNum);    }    public boolean isCanComment() {        return canComment;    }    public String getDirCode() {        return class1;    }    public synchronized boolean UpdateWithoutFile(ServletContext application,CMSMultiFileUploadBean mfu) throws            ErrMsgException {                String dir_code = StrUtil.getNullStr(mfu.getFieldValue("dir_code"));        author = StrUtil.getNullString(mfu.getFieldValue("author"));        title = StrUtil.getNullString(mfu.getFieldValue("title"));                String strCanComment = StrUtil.getNullStr(mfu.getFieldValue(                "canComment"));        if (strCanComment.equals(""))            canComment = false;        else if (strCanComment.equals("1"))            canComment = true;        String strIsHome = StrUtil.getNullString(mfu.getFieldValue("isHome"));        if (strIsHome.equals(""))            isHome = false;        else if (strIsHome.equals("false"))            isHome = false;        else if (strIsHome.equals("true"))            isHome = true;        else            isHome = false;        String strexamine = mfu.getFieldValue("examine");        int oldexamine = examine;        examine = Integer.parseInt(strexamine);        String strisnew = StrUtil.getNullStr(mfu.getFieldValue("isNew"));        if (StrUtil.isNumeric(strisnew))            isNew = Integer.parseInt(strisnew);        else            isNew = 0;        keywords = StrUtil.getNullStr(mfu.getFieldValue("keywords"));        String strisRelateShow = StrUtil.getNullStr(mfu.getFieldValue("isRelateShow"));        int intisRelateShow = 0;        if (StrUtil.isNumeric(strisRelateShow)) {            intisRelateShow = Integer.parseInt(strisRelateShow);            if (intisRelateShow==1)                isRelateShow = true;        }        flowTypeCode = StrUtil.getNullString(mfu.getFieldValue("flowTypeCode"));        Conn conn = new Conn(connname);        PreparedStatement pstmt = null;        try {                        pstmt = conn.prepareStatement(SAVE_DOCUMENT);            pstmt.setString(1, title);            pstmt.setInt(2, canComment ? 1 : 0);            pstmt.setBoolean(3, isHome);            pstmt.setInt(4, examine);            pstmt.setString(5, keywords);            pstmt.setInt(6, intisRelateShow);            pstmt.setInt(7, templateId);            pstmt.setString(8, dir_code);            pstmt.setInt(9, isNew);            pstmt.setString(10, author);            pstmt.setString(11, flowTypeCode);            pstmt.setInt(12, id);            conn.executePreUpdate();                        DocCacheMgr dcm = new DocCacheMgr();            if (oldexamine==examine) {                dcm.refreshUpdate(id);            }            else {                dcm.refreshUpdate(id, class1, parentCode);            }                        if (!dir_code.equals(class1)) {                dcm.refreshChangeDirCode(class1, dir_code);            }                        DocContent dc = new DocContent();            dc = dc.getDocContent(id, 1);            dc.saveWithoutFile(application, mfu);        } catch (SQLException e) {            logger.error(e.getMessage());            throw new ErrMsgException("服务器内部错!");        } finally {            if (conn != null) {                conn.close();                conn = null;            }        }        return true;    }    public synchronized boolean UpdateIsHome(boolean isHome) throws            ErrMsgException {        String sql = "update flow_document set isHome=? where id=?";        Conn conn = new Conn(connname);        PreparedStatement pstmt = null;        try {                        pstmt = conn.prepareStatement(sql);            pstmt.setInt(1, isHome ? 1 : 0);            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;    }    public synchronized boolean increaseHit() throws            ErrMsgException {        hit ++;        Conn conn = new Conn(connname);        PreparedStatement pstmt = null;        try {                        pstmt = conn.prepareStatement(SAVE_HIT);            pstmt.setInt(1, hit);            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;    }    public synchronized boolean UpdateSummaryWithoutFile(ServletContext application,                                                CMSMultiFileUploadBean mfu) throws            ErrMsgException {        Conn conn = new Conn(connname);        boolean re = true;        try {                        String idstr = StrUtil.getNullString(mfu.getFieldValue("id"));            if (!StrUtil.isNumeric(idstr))                throw new ErrMsgException("标识id=" + idstr + "非法,必须为数字!");            id = Integer.parseInt(idstr);            summary = StrUtil.getNullString(mfu.getFieldValue("htmlcode"));            PreparedStatement pstmt = null;             pstmt = conn.prepareStatement(SAVE_SUMMARY);            pstmt.setString(1, summary);            pstmt.setInt(2, id);            re = conn.executePreUpdate()==1?true:false;                        DocCacheMgr dcm = new DocCacheMgr();            dcm.refreshUpdate(id);        } catch (SQLException e) {            re = false;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -