LOADCONFIG.jsp 7.87 KB
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html; charset=UTF-8" language="java"%>
<%@ page import="java.util.*" %>
<%@ page import="java.io.*" %>
<%@ page import="com.csc.library.upload.UploadConfig" %>
<%@ page import="com.csc.library.utilities.UProfile,com.csc.library.utilities.*" %>
<%@ page import="com.csc.library.database.StaticProperties,com.csc.library.database.SystemCode" %>
<%@ page import="com.csc.library.session.InitialEnvironment" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Load Config(<%=System.getProperty("webapp.name")%>)</title>
<style type="text/css"><!--
label {
	display: block;
}
--></style>
</head>
<body>
<style>
	body{
		background:#55C5EB;
	}
</style>
<script>
function get_random_color() {
    var letters = '0123456789ABCDEF'.split('');
    var color = '#';
    for (var i = 0; i < 6; i++ ) {
        color += letters[Math.round(Math.random() * 15)];
    }
    return color;
}
document.body.style.backgroundColor=get_random_color();
</script>
<form id="cscform" name="cscform" method="post" action="?">
  <div style="width:200px; border:solid 2px #666666; font-size:15px; margin:auto;">
  	<table width="200" cellpadding="1" cellspacing="0" style="background:#fdfdfd;">
    	<tr>
        	<td colspan="2" align="center" style="font-weight:bold; border-bottom:#333 solid 1px;">LoadConfig</td>
        </tr>
    	<tr>
        	<td align="center" style="border-bottom:#333 solid 1px;"><input type="checkbox" name="protable" id="protable" value="protable" /></td>
            <td  style="border-bottom:#333 solid 1px;">Load Protable XML</td>
        </tr>
        <tr>
        	<td align="center"  style="border-bottom:#333 solid 1px;"><input type="checkbox" name="systemcode" id="systemcode" value="systemcode" /></td>
            <td style="border-bottom:#333 solid 1px;">Load System Code</td>
        </tr>
        <tr>
        	<td align="center"  style="border-bottom:#333 solid 1px;"><input type="checkbox" name="uploadconfig" id="uploadconfig" value="uploadconfig" /></td>
            <td style="border-bottom:#333 solid 1px;">Load Upload Config</td>
        </tr>
        <tr>
        	<td align="center"  style="border-bottom:#333 solid 1px;"><input type="checkbox" name="loadmenu" id="loadmenu" value="loadmenu" /></td>
            <td style="border-bottom:#333 solid 1px;">Load Menu XML</td>
        </tr>
        <tr>
        	<td align="center"  style="border-bottom:#333 solid 1px;"><input type="checkbox" name="clearscreen" id="clearscreen" value="clearscreen" /></td>
            <td style="border-bottom:#333 solid 1px;">Clear Screen Hash</td>
        </tr>
        <tr>
        	<td align="center"  style="border-bottom:#333 solid 1px;"><input type="checkbox" name="cleartransferxml" id="cleartransferxml" value="cleartransferxml" /></td>
            <td style="border-bottom:#333 solid 1px;">Clear Transfer Xml</td>
        </tr>		
        <tr>
        	<td align="center"  style="border-bottom:#333 solid 1px;"><input type="checkbox" name="select_all" id="select_all" value="select_all" onclick="chkAll();"/></td>
            <td style="border-bottom:#333 solid 1px;"><strong>Select All</strong></td>
        </tr>
        <tr>
        	<td colspan="2" align="center" height="50">
            	<style>
                	input:hover{
						font-size:24px;
						font-weight:bold;
						color:#F00 #0F0
					}
                </style>
            	<input name="process" type="submit" value="Process" style="background-color:#FFF; cursor:pointer; border:#000000 solid 1px;"/>
            </td>
        </tr>
    </table>
  </div>
    <br />
    <div style="width:700px; margin:auto; background-color:#FFF;	">
    <%
	if(request.getParameter("process") != null) {
		boolean clearscreen = false;
		if(request.getParameter("protable") != null) {
			// load protable
			clearscreen = true;

			String lflag = request.getParameter("loadprocessdata");
			if (lflag == null || lflag.equals(""))
				lflag = "false";
				System.out.println("::::: Start load protable  waiting......");
 
				ServletContext context = pageContext.getServletContext();
				String nodeName=System.getProperty("webapp.name");
				StaticProperties.invBase._configFile=context.getInitParameter("xmlconfig");
			    if(nodeName!=null && nodeName.trim().length()>0){
				    	StaticProperties.invBase._configFile=nodeName+"-"+context.getInitParameter("xmlconfig");
			    }
			    StaticProperties.invBase._configPath=context.getRealPath("/WEB-INF/classes").replace("\\.\\", "\\")+"//";
			    StaticProperties.invBase._configPath=context.getRealPath("/WEB-INF/classes").replace("\\.\\", "\\")+"//";
			    StaticProperties.invBase.isconfigDoc=true;

		
			LoadStaticProperties l = new LoadStaticProperties();
			l.setIsSetConnection(false);
			if (lflag.equalsIgnoreCase("false")) {
				l.process();
			} else {
				l.setProcessData();
			}
			StaticProperties.isload = true;

			System.out.println("::::: Load protable  commited......");
			out.println("<b> Load protable : </b> <span style=\"color:#0F0\"><b>Commited.</b></span><br>");
			//------------------------------------------------------------------------------------------
		}
		
		if(request.getParameter("systemcode") != null) {
			// load systemcode
			clearscreen = true;
			String resource = new InitialEnvironment("GLOBAL").getValue("config-dir");
			new SystemCode().initValue(resource + "SYSTEMCODE.xml");
			out.println("<b>Load System Code : </b> <span style=\"color:#0F0\"><b>Complete.</b></span><br>");

		}
		
		if(request.getParameter("cleartransferxml") != null) {
			clearscreen = true;
			new ReadXml().loadWorkflowXmlOnMemory();
			out.println("<b>Clear Transfer Xml : </b> <span style=\"color:#0F0\"><b>Complete.</b></span><br>");

		}		
		
		if(request.getParameter("uploadconfig") != null) {
			// load uploadconfig 
			String  cfg = application.getInitParameter("upload-config");
			String uploadConfigPath = application.getRealPath( cfg ).replace('\\', '/').replace('/', File.separatorChar);
		
			StringWriter sw = new StringWriter();
			PrintWriter pw = new PrintWriter(sw);
			
			try {
				UploadConfig upload = new UploadConfig( uploadConfigPath );
				upload.load();
				//upload.getProperties().list(new PrintWriter(out));
				out.println("<b>Load Upload Config : </b>  <span style=\"color:#0F0\"><b>Complete.</b></span><br />");
				upload.getProperties().list(pw);
				out.println("<!--");
				out.println (sw.toString().replaceAll("\\n", "<br />"));
				out.println("-->");
			} catch (Exception e) {
				out.println("<br/><br /><span style=\"color:#F00\"><b>Could not load upload-config :</b> </span>" +uploadConfigPath +"<br />");
				out.println (sw.toString().replaceAll("\\n", "<br />"));
			}
			sw.close();
			pw.close();
		}
		
		if(request.getParameter("loadmenu") != null )  {
			// clear screen
			com.csc.library.menu.StaticMenu.MENUMAP.clear();
			//StaticProperties.jspAuthen= new com.csc.library.security.JspFileAuthen();
			StaticProperties.jspAuthen.loadProperties();
			com.csc.library.menu.StaticMenu.MENU_CACHED.clear();

			out.println("<b>Clear Screen Hash :</b> <span style=\"color:#0F0\"><b>Complete.</b></span><br>");
		}
		%>
		<script>
			var url = document.URL;
			var urlA = url.split("/");
			document.write("<a href=\"http://"+urlA[2]+"/hr\">Go!! Login Page!</a>");
        </script>
		<%
	} 
%></div><br />
    
  
</form>
<script>
function chkAll(){
	with(document.cscform){
		if(select_all.checked==true){
			protable.checked = true;
			systemcode.checked = true;
			uploadconfig.checked = true;
			loadmenu.checked = true;
			clearscreen.checked = true;
			cleartransferxml.checked = true;
		}else{
			protable.checked = false;
			systemcode.checked = false;
			uploadconfig.checked = false;
			loadmenu.checked = false;
			clearscreen.checked = false;
			cleartransferxml.checked = false;
		}
	}
}
</script>

</body>
</html>