<%@ page trimDirectiveWhitespaces="true" %> <%@ page language="java" contentType="text/html; charset=GBK"%> <%@page import="com.amarsoft.are.jbo.impl.BizObjectTableMapper"%> <%@ page import="com.amarsoft.biz.formatdoc.model.FormatDocConfig"%> <%@ page import="com.amarsoft.biz.formatdoc.model.FormatDocHelp"%> <%@ include file="/Frame/resources/include/include_begin_ajax.jspf" %> <% out.print(changeHtmlData2xml(new FormatDocConfig(request), Sqlca) ? "转换成功" : "转换失败"); %> <%@ include file="/Frame/resources/include/include_end_ajax.jspf" %> <%! public static boolean changeHtmlData2xml(FormatDocConfig config, Transaction Sqlca) { ASResultSet rs = null; try{ String sTable = ((BizObjectTableMapper)(JBOFactory.getBizObjectManager("jbo.app.FORMATDOC_DATA"))).getTable(); rs = Sqlca.getASResultSet(new SqlObject("select SerialNo, HtmlData from "+sTable)); while(rs.next()){ changeHtmlData2xml(rs, config); } return true; }catch(Exception e){ ARE.getLog().debug(e); return false; }finally{ if(rs != null) try{ rs.close(); }catch (Exception e) { } } } private static void changeHtmlData2xml(ASResultSet rs, FormatDocConfig config) throws SQLException, IOException { InputStream is = null; FileWriter fw = null; try{ String sSerialNo = rs.getString("SerialNo"); is = rs.getBinaryStream("HtmlData"); if(is == null){ ARE.getLog().debug("SerialNo="+sSerialNo+",HtmlData值为空"); return; } String sFolder = config.getWorkDocSavePath() + "/htmldata/" + sSerialNo.substring(0,4) + "/" + sSerialNo.substring(4, 6)+ "/" + sSerialNo.substring(6, 8); File file = new File(sFolder + "/" + sSerialNo + ".htm"); if(file.exists()){ ARE.getLog().debug("HtmlData文件,SerialNo="+sSerialNo+"已存在"); return; } fw = new FileWriter(file); fw.write(new String(FormatDocHelp.getBytes(is), "GBK")); // TODO 可修改值HtmlData=null }finally{ if(fw != null) try{ fw.close(); }catch (Exception e) { } if(is != null) try{ is.close(); }catch (Exception e) { } } } %>