CSC_IMPORT.jsp 4.38 KB
Newer Older
Thitichaipun Wutthisak committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
<%@page contentType="text/html; charset=UTF-8"%>
<%@page import="com.csc.library.entry.HelpEntry,com.csc.library.system.*,com.csc.library.utilities.*"%>
<%@ page import="com.csc.library.entry.*,com.csc.library.database.*,com.csc.library.session.*"  %>
<%@page import="java.util.*,java.net.*,java.io.*,com.csc.upload.*,com.csc.library.cscimport.MyImport;"%>
<jsp:useBean id="upload" class="com.csc.library.system.Task" scope="page"/>
<jsp:useBean id="hmul" class="com.csc.upload.HttpMultiPartParser" scope="page"/>
<%
	upload.setChannel(request,response); 
	upload.checkProfile();	
	UProfile u=upload.getUProfile();

 	InitialEnvironment en = new InitialEnvironment("GLOBAL");
    String filePath=en.getValue("dirimport-dir");

	String tempdir = ".";
	
	request.setAttribute("dir", request.getParameter("dir"));
	String browser_name = request.getRequestURI();	
	String status="";
	Hashtable ht=new Hashtable();	
	String dir="";
	String xmlName="";

%>

<%
	if ((request.getContentType()!=null)&&(request.getContentType().toLowerCase().startsWith("multipart"))){
		response.setContentType("text/html");
		 try{	
			int bstart = request.getContentType().lastIndexOf("oundary=");
			String bound = request.getContentType().substring(bstart+8);
			ht = hmul.processData(request.getInputStream(), bound, tempdir);
    		hmul.uploadFiles(ht);									
			u.set("upload","true");			
			dir=(String) ht.get("dir");
			xmlName=(String) ht.get("__xml");
			FileInfo f = (FileInfo) ht.get("myFile");
			String fileFullPath = f.file.toString();			
			String fileName="";
			StringTokenizer str = new StringTokenizer(fileFullPath, "\\");
			while (str.hasMoreTokens()) {
				fileName = str.nextToken();							
			}//end while  
 
			response.sendRedirect("CSC_IMPORT_RESULT.jsp?__fileName="+fileName+"&__cmd=process_data&__xml="+xmlName);
		}catch (Exception e){ 
			e.printStackTrace();
		}//end try
	}//end if 	
 
%>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../CSS/TISCO.css" rel="stylesheet" type="text/css">
<script language="JavaScript" src="../JS/SCREEN.js"></script>
<script language="javascript">setLang('<%=upload.getUProfile().get("lang")%>');</script>
<script language="JavaScript" >
<!--
function checktype(){
 	var stdstr="";
    with(document.cscform){
		if(myFile.value.length>0){
			stdstr=myFile.value.substring(myFile.value.lastIndexOf("\\")+1,myFile.value.length);
			if(stdstr.indexOf(".txt")>-1){		
				
				submit(); 
			}else if(stdstr.indexOf(".TXT")>-1){					
				submit(); 
			} else{
				alert(MyCode[81]);
			}
		} else if (myFile.value.length==0)
			alert(MyCode[80]);
	}
}

function notInput(){
	with(document.cscform){
		alert(myFile.value);
		myFile.value="5";
	}
}
//-->
</script>

</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<form  name="cscform"  enctype="multipart/form-data" method="POST" >
	<input type="hidden" name="__fixCon" value="">

<br>
  	<div align="center">
    <table  cellpadding="0"  cellspacing="0">
    <tr > 
    	<td  class="header">CSC IMPORT,&nbsp;<script language="javascript">swapLang("CSC IMPORT DATA");</script>&nbsp;</td>
  	</tr>
    <tr > 
    	<td  colspan="2">
			<table width="630" border="0">            
            <tr> 
            	<td colspan="2"></td>
            </tr>
            <tr> 
             	<td class="columnlabel"><script language="javascript">swapLang("File");</script>&nbsp;</td>
              	<td>
					<input type="hidden"name="__screen"  value="upload">
            		<input type="hidden" name="dir" value="<%=filePath%>">
            		<input type="file" name="myFile" onKeyDown="javascript:notInput();">
				</td>				              	
           	</tr>
			<tr>
				<td class="columnlabel"><script language="javascript">swapLang("XML");</script>&nbsp;</td>
				<td>  
				<select name="__xml">
					<option selected value="ORG_PLUS"><script language="javascript">swapLang("Org Plus");</script></option>	
					<option  value="tot"><script language="javascript">swapLang("TOT");</script></option>
				</select>				
				</td>
			</tr>			
			<tr>
				<td colspan="2" align="center"><input type="Button" name="Submit" value="Upload" onClick="checktype();"> </td>
			</tr>
            <tr> 
              	<td colspan="2" class="blankspace"  ></td>
            </tr>
          	</table> 
		</td>
   	</tr>
    <tr> 
    	<td  class="bottom"></td>
   	</tr>	  
    </table>
  </div>
</form>

</body>
</html>