IMPORT.jsp 7.18 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 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
<%@page contentType="text/html; charset=UTF-8"%>
<%@page import="java.util.*,com.csc.library.cscimport.*,com.csc.library.database.*,com.csc.library.session.*,com.csc.library.utilities.*"%>
<jsp:useBean id="importPage" class="com.csc.library.system.Task" scope="page"/>
<%
	importPage.setChannel(request,response); 
	importPage.checkProfile();	
	UProfile u = importPage.getUProfile();
	InitialEnvironment en = new InitialEnvironment("GLOBAL");
    String filePath=en.getValue("dirimport-dir");
	String result="";
	
	if (request.getParameter("__cmd")!=null&&request.getParameter("__cmd").equals("true")) {
		//Temp Variable
		String databaseName="", schemaName="", userName="", companyID="", language="";
		String tableName="", xmlPath="", xmlFileName="", dataPath="", dataFileName="";	
		String errorPath="", errorFileName="";
		try {
			databaseName = request.getParameter("__dbName");
			schemaName = request.getParameter("__schemaName");
			userName = request.getParameter("__userName");
			companyID = request.getParameter("__companyID");
			language = request.getParameter("__language");
			tableName = request.getParameter("__tableName");
			xmlPath = request.getParameter("__xmlPath");
			xmlFileName = request.getParameter("__xmlFileName");
			dataPath = request.getParameter("__dataPath");
			dataFileName = request.getParameter("__dataFileName");		
			errorPath = request.getParameter("__errorPath");
			errorFileName = request.getParameter("__errorFileName");		
		
			UProfile up = new UProfile();
			up.setDbName(databaseName);
			up.setSchemaName(schemaName);
			up.setUserName(userName);
			up.set("companyid", companyID);
			up.set("lang", language);

			HashMap param = new HashMap();
			Properties pr = new Properties();
			HashMap hm = new HashMap();
			param.put("__screen","import");
			
			DbRecord rec = new InitialRecord(up).getDbRecord(tableName);
			rec.setParam(param);
			rec.setColumn("*");
			MyImport myImp = new MyImport(rec, dataPath + dataFileName, xmlPath + xmlFileName);
			myImp.process();
			CscCalendar csc = new CscCalendar();
            String time = "-"+csc.getYYYYMMDD()+"-"+csc.getCSCTime();
            myImp.writeErrorResult(errorPath+errorFileName+time+".txt");
			result="Import Successful";
		} catch (Exception e) {
            e.printStackTrace();
			//result=e.getMessage();
			result="ERROR!!! Import Not Successful";
        }
	} 
%>
<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 type='text/javascript' src='./js/screen.js'></script>
<script language="JavaScript" type="text/JavaScript">
	function copyFileName() {
		with (document.cscform) {
			if (__tableName.value!="") {
				__xmlFileName.value = __tableName.value+".xml";
				__dataFileName.value = __tableName.value+".txt";
				__errorFileName.value = __tableName.value;
			} else alert("Table Name is empty !!! Not Copy");
		}
	}
	
	function importTXT() {
		with (document.cscform) {
			bCon=confirm("Import Data To Database ?");
			if (bCon==true)	{
				__cmd.value="true";
				submit();
			}
		}
	}	
</script>
</head>
<body leftmargin="0" topmargin="0" onLoad="MM_preloadImages('images/button/swap/copy_swap20.gif')"> 
<div align="center"> 
  <form name="cscform" method="post" action="#"> 
   

<!----------BEGIN CSC INITIAL ZONE ------------------------>

<%=screen.InitialVariable()%>

<!----------END CSC INITIAL ZONE -------------------------->

<input type="hidden" name="__screen" value="import"> 
    <input type="hidden" name="__cmd" value=""> 
    <br> 
    <table height="" align="center" cellpadding="0" cellspacing="0"> 
      <tr bgcolor="#3366CC"> 
        <td class="header" colspan="2">myHR Utility :> Import Page&nbsp;</td> 
      </tr> 
	  <tr> 
        <td class="blankspace" colspan="2"></td> 
      </tr>
      <tr valign="top"> 
        <td colspan="2" class="blankspace">&nbsp;&nbsp;<strong>User Profile Data</strong></td> 
      </tr> 
      <tr> 
        <td width="130" align="right" valign="top">Database Name :&nbsp;</td> 
        <td width="438"><input name="__dbName" value="<%=u.getDbName()%>"></td> 
      </tr> 
      <tr> 
        <td align="right" valign="top">Schema Name :&nbsp;</td> 
        <td><input name="__schemaName" value="<%=u.getSchemaName()%>"></td> 
      </tr> 
      <tr> 
        <td align="right" valign="top">User Name :&nbsp;</td> 
        <td><input name="__userName" value="<%=u.get("username")%>"></td> 
      </tr> 
      <tr> 
        <td align="right" valign="top">Company ID :&nbsp;</td> 
        <td><input name="__companyID" value="<%=u.get("companyid")%>"></td> 
      </tr> 
      <tr> 
        <td align="right" valign="top">Language :&nbsp;</td> 
        <td>
			<select name="__language">
				<% if (u.get("lang").equalsIgnoreCase("eng")) { %>
					<option value="eng" selected>English Lanquage</option>
					<option value="tha">Thai Lanquage</option>
				<% } else { %>
					<option value="eng">English Lanquage</option>
					<option value="tha" selected>Thai Lanquage</option>
				<% } %>
		</select>		</td> 
      </tr> 
      <tr> 
        <td class="blankspace" colspan="2"></td> 
      </tr> 
      <tr> 
        <td colspan="2" class="blankspace">&nbsp;&nbsp;<strong>Import Data</strong></td> 
      </tr> 
      <tr> 
        <td align="right" valign="top">Table Name :&nbsp;</td> 
        <td><input name="__tableName" value="">&nbsp;<a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('copyImg','','images/button/swap/copy_swap20.gif',1)"><img src="images/button/main/copy20.gif" alt="Copy FileName" name="copyImg" width="20" height="20" border="0" align="absbottom" onClick="copyFileName()"></a></td> 
      </tr> 
	  <tr> 
        <td align="right" valign="top">Xml Path :&nbsp;</td> 
        <td><textarea name="__xmlPath" cols="60" rows="3"  ><%=filePath%></textarea></td> 
      </tr>
      <tr> 
        <td align="right" valign="top">Xml File :&nbsp;</td> 
        <td><input name="__xmlFileName" value=""></td> 
      </tr> 
	  <tr> 
        <td align="right" valign="top">Data Path :&nbsp;</td> 
        <td><textarea name="__dataPath" cols="60" rows="3"  ><%=filePath%></textarea></td> 
      </tr> 
      <tr> 
        <td align="right" valign="top">Data File :&nbsp;</td> 
        <td><input name="__dataFileName" value=""></td> 
      </tr> 
	  <tr> 
        <td align="right" valign="top">Error Path :&nbsp;</td> 
        <td><textarea name="__errorPath" cols="60" rows="3"  ><%=filePath%></textarea></td> 
      </tr>
	  <tr> 
        <td align="right" valign="top">Error File :&nbsp;</td> 
        <td><input name="__errorFileName" value=""><br> * - Finish Time Ex. ERROR-2005-08-15-10.19.txt, And Not Input Type Of File</td> 
      </tr>
	  <tr> 
        <td class="blankspace" colspan="2"></td> 
      </tr>
	  <tr> 
        <td class="blankspace" colspan="2"><div align="center"><a href="javascript:importTXT();"><img src="images/button/ok.gif" border="0"></a></div></td> 
      </tr>
	  <tr> 
        <td class="blankspace" colspan="2"></td> 
      </tr>
	  <tr> 
        <td class="blankspace" colspan="2">&nbsp;&nbsp;<strong>Result : </strong><%=result%></td> 
      </tr>
	  <tr> 
        <td class="blankspace" colspan="2"></td> 
      </tr>
    </table> 
  
</form> 
</div> 
</body>
</html>