address_list_import.jsp
上传用户:guhaomin
上传日期:2007-06-10
资源大小:23203k
文件大小:6k
源码类别:

电子政务应用

开发平台:

Java

  1. <%@ page errorPage="/vnex/ErrorPage.jsp" %>
  2. <%@ page import="com.vnex.intranet.addresslist.value.*"%>
  3. <%@ page import="com.vnex.intranet.addresslist.proxy.*"%>
  4. <%@ page import="com.vnex.intranet.addresslist.handler.*"%>
  5. <%@ page import="com.vnex.intranet.system.loader.ConfigParaLoader"%>
  6. <%@ page import="com.vnex.intranet.util.*"%>
  7. <%@ page import="com.vnex.intranet.upload.*"%>
  8. <%@ page import="java.util.*" %>
  9. <%@ page import="java.sql.*" %>
  10. <%@ page import="java.io.*" %>
  11. <jsp:useBean id="addressProxy" class="com.vnex.intranet.addresslist.proxy.AddressProxyBean" scope="application" />
  12. <jsp:useBean id="BusinessName" scope="session" class="com.vnex.intranet.pub.BusinessSession" />
  13. <jsp:useBean id="myUpload" scope="page" class="com.vnex.intranet.upload.SmartUpload" />
  14. <%
  15.  
  16.   if( request.getParameter("import") !=null && request.getParameter("import").equals("ok") ) //上载 
  17.   {              
  18. System.out.println("ok");
  19.     String root = ConfigParaLoader.getParameter("rootUrl");
  20. System.out.println(root);
  21.  // Initialization 
  22.     myUpload.initialize( pageContext ); 
  23.     myUpload.setTotalMaxFileSize( Integer.parseInt(ConfigParaLoader.getParameter("attachmentSize")) );
  24. System.out.println(root);
  25. System.out.println(Integer.parseInt(ConfigParaLoader.getParameter("attachmentSize")));
  26.  // Only allow txt or htm files
  27.  // myUpload.setAllowedFilesList("csv,CSV");
  28.  
  29.  //是否目录存在
  30.       java.io.File f = new java.io.File(root+"\CSVFile\");
  31.       if(!f.isDirectory())
  32.       {
  33.         f.mkdir();
  34.       }
  35.  
  36.  // Upload        
  37.     myUpload.upload(); 
  38.     com.vnex.intranet.upload.File myFile = myUpload.getFiles().getFile(0);
  39.     myFile.saveAs( root+"/CSVFile/NetOffice_Im.csv" );
  40.     
  41.     RandomAccessFile outFile = new RandomAccessFile( root+"/CSVFile/NetOffice_Im.csv","r" );
  42.     com.vnex.intranet.upload.Request multi = myUpload.getRequest();
  43.     
  44.     AddressCSVHandler.csvToDB(outFile, BusinessName.getEmpId(), Integer.parseInt(multi.getParameter("csv")));
  45.     outFile.close();
  46.     //response.sendRedirect("/mainctrl/addressbook/home");
  47.   }
  48. %>
  49. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  50. <HTML>
  51. <jsp:include page="/vnex/page/FORM_HEAD.jsp" />
  52. <BODY text=#000000 vLink=#000000 aLink=#000000 link=#000000 bgColor=#ffffff topMargin=20 leftmargin="0" marginwidth="0" marginheight="0">
  53. <script language="javascript" src="/vnex/validate.js" ></script>
  54. <script language="JavaScript">
  55. function check()
  56. {
  57.   if(document.myform.file.value.toLowerCase().indexOf(".csv")==-1)
  58.   {
  59.     alert("导入的文件必须是csv格式的文件。");
  60.     document.myform.file.focus();
  61.     return false;
  62.   }
  63.   return true;
  64. }
  65. function importt()
  66. {
  67.   if(!check())
  68.   {
  69.     return false;
  70.   }
  71.   document.myform.action = "/mainctrl/addressbook/import?import=ok";
  72.   myform.encoding="multipart/form-data";
  73.   document.myform.submit();
  74. }
  75. </script>
  76. <script language="JavaScript1.2" src="/vnex/menu/dockmenu_person.js"></script>
  77. <script language="JavaScript" src="/vnex/menu/dockmenu.js"></script>
  78. <DIV align=center>
  79. <form name="myform" method="post" action="">
  80.   <TABLE class=outter cellSpacing=0 cellPadding=0 width=600 border=0>
  81.      <jsp:include page="/vnex/page/TTOA_TABLE_TOP.jsp" />
  82.     <TR> 
  83.         <TD colSpan=3 align="center"><br>
  84.           <table width="600" border="1" cellspacing="1" bordercolor="#666666">
  85.             <tr> 
  86.               <td align="center" colspan="2" bgcolor="#FFFFFF"> 
  87.                 <table width="600" border="0" cellspacing="0" cellpadding="0">
  88.                   <tr bgcolor="#666666"> 
  89.                       <td colspan="2"><font class="strongw"><a href="/mainctrl/home/index"><font color="#ffffff">主页</font></a>&gt;&gt;<a href="/mainctrl/personal/main"><font color="#ffffff">个人办公</font></a>&gt;&gt;<a href="/mainctrl/addressbook/home"><font color="#ffffff">个人通讯录</font></a>&gt;&gt;导入</font>
  90.                       </td>
  91.                   </tr>
  92.                 </table>
  93.                 <table class=title border="0" cellpadding="2" cellspacing="1" width="600">
  94.               <tr bgcolor="#e0e0e0">
  95.                  
  96.               <td width="15%"><strong>&nbsp;说明:</strong></td>
  97.               <td><a href="/mainctrl/addressbook/help"><font color="#0000FF">导入导出说明</font></a>
  98.               </td>
  99.               </tr>
  100.               <tr bgcolor="#fafafa">
  101.                 <td width="15%"><strong>&nbsp;导入格式:</strong></td>
  102.                 <td>
  103.                   <input type="radio" value="1" name="csv" checked>导入Net-Office格式的csv文件<br>
  104.                   <input type="radio" value="0" name="csv">导入Outlook格式的csv文件
  105.                 </td>
  106.               </tr>
  107.               <tr bgcolor="#e0e0e0">
  108.                 <td width="15%"><strong>&nbsp;文件:</strong></td>
  109.                 <td><input type="file" name="file" class="text"></td>
  110.               </tr>
  111.               <tr bgcolor="#fafafa" height="30"> 
  112.                 <td colspan="2" align="center">
  113.                  <input type="button" name="Button2" value="导入" onClick="importt()" class="text"> 
  114.                  &nbsp;&nbsp; 
  115.                  <input type="button" name="Button3" value="返回" onClick="location='/mainctrl/addressbook/home'" class="text">      
  116.                  </td>
  117.               </tr>
  118.            </table>
  119.                </td>
  120.             </tr>
  121.           </table>
  122.          <jsp:include page="/vnex/page/TTOA_HELP.jsp" />
  123.       </TD>
  124.     </TR>
  125.     <jsp:include page="/vnex/page/TTOA_TABLE_BOTTOM.jsp" />
  126.    </TABLE>
  127.     <br>
  128.   <jsp:include page="/vnex/page/TTOA_PRODUCER_LOGO.jsp" />
  129. </form></DIV>
  130. </BODY></HTML>