<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="java.sql.*" %>
<%@ page import="net.sz600.tool.SzConvert" %>
<%@ page import="net.sz600.tool.SzDateHelp" %>
<%@ page import="net.sz600.system.*" %>
<%@ page import="net.sz600.flow.*" %>
<%@ page import="net.sz600.formEngine2.*" %>
<%@ page import="net.sz600.searcher.TextFileIndexer" %>
<%@ include file="/sessionInfo.jsp"%>
<%
    String sKEY =  SzConvert.toZeroStr(request.getParameter("KEY"));
    String sTable =  SzConvert.toZeroStr(request.getParameter("table"));
    String sTableAnnex =  SzConvert.toZeroStr(request.getParameter("annex"));
    String sFormID = SzConvert.toZeroStr(request.getParameter("FormID"));
    boolean bReadonly = true;

    //sql server连接配置参考：
    String sDriver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
    String sUrl = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=SZ_GROUPOA";
    String sUser = "sa";
    String sPassword = "";

    Connection conn = null;
    PreparedStatement pstmt = null;
    Statement stmt = null;
    ResultSet rs = null;

	String sql = "select XXMC1,XXMC4,XXMC8,FJMC,FJLJ from " + sTable + "," + sTableAnnex + 
		" where XXMC1=" + sKEY+ " and XXMC1=FJXX";
    try {
    	Class.forName(sDriver);
    	conn = DriverManager.getConnection(sUrl, sUser, sPassword);
		stmt = conn.createStatement();
    	rs = stmt.executeQuery(sql);    	
    } catch(Exception e) { 
		out.println("连接客户信息数据库有问题<p>");
		out.println("URL: " + sUrl + "<BR>");
		out.println("User: " + sUser + "<BR>");
		if (stmt != null) {
			stmt.close();
			stmt = null;
		}
		if (conn != null) {
			conn.close();
			conn = null;
		} 
		return;
    }

	if (!rs.next()) {
		out.println("没有需要建立索引的附件。");
		try {
			if (rs != null) {
				rs.close();
				rs = null;
			}
			if (pstmt != null) {
				pstmt.close();
				pstmt = null;
			}
			if (conn != null) {
				conn.close();
				conn = null;
			}     	
		} catch(Exception e) { 
		}  
		return;
	}
	String myKey = SzConvert.toSpaceStr(rs.getString("XXMC1"));
	String myTitle = SzConvert.toSpaceStr(rs.getString("XXMC4"));
	String mySummary = SzConvert.toSpaceStr(rs.getString("XXMC8"));
	String myFileName = SzConvert.toSpaceStr(rs.getString("FJMC"));
	String myAnnex = SzConvert.toSpaceStr(rs.getString("FJLJ"));
//	System.out.println(myTitle + "=====================");
%>

建立索引 <P>
<TABLE border=1 width="650">
<TR>
	<TD width="15%">标题</TD>
	<TD width="30%">摘要</TD>
	<TD>附件</TD>
</TR>
<TR>
	<TD><A HREF="/oa/share/formEngine2/update.jsp?OPERATOR=detail&type=0&KEY=<%=myKey%>&FormID=<%=sFormID%>"><%=myTitle%></A></TD>
	<TD><%=mySummary%></TD>
	<TD><%=myAnnex%></TD>
</TR>
</TABLE>

<%
	// 把服务器文件传给 lucene 进行索引
	TextFileIndexer fileIndexer = new TextFileIndexer();
	fileIndexer.doWordIndex(sFormID, myKey, myTitle, mySummary, myFileName, myAnnex, true);
%>

完成。

<%
  try {
	if (rs != null) {
		rs.close();
		rs = null;
	}
	if (pstmt != null) {
		pstmt.close();
		pstmt = null;
	}
	if (conn != null) {
		conn.close();
		conn = null;
	}     	
  } catch(Exception e) { 
  }  
%>
