<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="net.sz600.tool.SzConvert" %>
<%@ page import="net.sz600.tool.SzDateHelp" %>
<%@ page import="net.sz600.system.*" %>
<%@ page import="net.sz600.mail.*" %>
<%@ page import="com.jspsmart.upload.SmartUpload" %>
<%@ page import="com.jspsmart.upload.Request" %>
<%@ include file="/sessionInfo.jsp"%>
<%
		request.setCharacterEncoding("UTF-8");
		//long fM1 = java.lang.Runtime.getRuntime().freeMemory();
    SmartUpload smartUpload = new SmartUpload();    
    smartUpload.initialize(pageContext);    
    //2012-06-02增加
    //限制总上传数据的总长度
    //smartUpload.setMaxFileSize(10000000);
    //smartUpload.setTotalMaxFileSize(1000);
    //允许上传的文件 通过扩展名限制  
    //smartUpload.setAllowedFilesList("jpg,rar,dmp,gif,png,ppt");

    //内存大小
    try {
    	smartUpload.upload();
    } catch(Exception e) {
    	System.out.println(e);
    }		
    Request requestSu = smartUpload.getRequest();    

		//javax.servlet.http.HttpServletRequest requestSu = request;
    //获取提交的参数
    String sType = SzConvert.toZeroStr(requestSu.getParameter("type"));
    String sPage = SzConvert.toZeroStr(requestSu.getParameter("page"));
    String sSearch = SzConvert.uploadWriteData(requestSu.getParameter("txtSearch"));
    String sPKEY = SzConvert.toZeroStr(requestSu.getParameter("PKEY"));
    
    String sSearchName = SzConvert.strWriteData(requestSu.getParameter("txtSearchName"));
	String sSearchTitle = SzConvert.strWriteData(requestSu.getParameter("txtSearchTitle"));
	String sSearchBegin = SzConvert.strWriteData(requestSu.getParameter("txtSearchBegin"));
	String sSearchEnd = SzConvert.strWriteData(requestSu.getParameter("txtSearchEnd"));        
%>
<form name="formHidden" method="post">
  <input type="hidden" name="page" value="<%=sPage%>">
  <input type="hidden" name="txtSearch" value="<%=sSearch%>">
  <input type="hidden" name="PKEY" value="<%=sPKEY%>">
  <input type="hidden" name="type" value="<%=sType%>">
  
	<input type="hidden" name="txtSearchBegin" value="<%=sSearchBegin%>">
	<input type="hidden" name="txtSearchEnd" value="<%=sSearchEnd%>">  
  <input type="hidden" name="txtSearchName" value="<%=sSearchName%>">
  <input type="hidden" name="txtSearchTitle" value="<%=sSearchTitle%>">  
</form>
<%
    String sOPERATOR = SzConvert.toSpaceStr(requestSu.getParameter("OPERATOR"));

    YjMailNew yjMail = new YjMailNew();
    boolean flag = false;
    String sUrl = "index.jsp";
    if (sType.equals("0") || sType.equals("3")) {
    	
    } else if (sType.equals("1") || sType.equals("2")) {
    	sUrl = "index_send.jsp";
    } else {
    	sUrl = "index_fold.jsp";
    }
    String sMessage = "";
    if (sOPERATOR.equals("delete")) {
        String id_str[] = requestSu.getParameterValues("chkId");
        flag = yjMail.delete(id_str);
    } else {
    	flag = yjMail.control(smartUpload, session);
    }
    
    //增加调用关闭
    smartUpload.closeAll();
    //long fM2 = java.lang.Runtime.getRuntime().freeMemory();
    //System.out.println("内存大小:" + fM1 + "," + fM2 + "==" + (fM1 -fM2) );   
    
    
    sMessage = SzOut.getMessage();

    if (flag) {
        out.println(SzPageHelp.jsAlert("操作成功"));
        //out.println(SzPageHelp.jsGoUrl(sUrl));
        out.println(SzPageHelp.jsFormSubmit("formHidden",sUrl));
    } else {
        out.println(SzPageHelp.jsAlertBack(sMessage));
    }
    
 
%>
