Advertisement
Guest User

Untitled

a guest
Mar 1st, 2016
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.52 KB | None | 0 0
  1. <%@page import="org.bean.UserBean"%>
  2. <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  3. pageEncoding="ISO-8859-1"%>
  4. <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
  5. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  6. <html>
  7. <head>
  8. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  9. <script type="text/javascript"
  10. src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
  11.  
  12. <link rel="stylesheet" type="text/css" href="myCssFile.css">
  13. <title>Insert title here</title>
  14. <script type="text/javascript">
  15. function enableSubmit() {
  16. document.getElementById("getCase").disabled = true;
  17. document.getElementById("submitButton").disabled = false;
  18. }
  19. function enableGetCase() {
  20. document.getElementById("getCase").disabled = false;
  21. document.getElementById("submitButton").disabled = true;
  22. }
  23. </script>
  24. </head>
  25. <body>
  26. <div class="header" id="header">
  27. <form id="form1"></form>
  28. </div>
  29.  
  30. <div class="bodytag">
  31. <form method="get" action="GetData">
  32. <input type="Submit" value="Get Case" name="getCase" id="getCase"
  33. onclick="enableSubmit()" />
  34. <table>
  35.  
  36. <tr>
  37. <td>Case Number</td>
  38. <td><input id="Text1" type="text" value="" /></td>
  39.  
  40. <td>Case Owner</td>
  41. <td><input id="Text6" type="text" value="" /></td>
  42. </tr>
  43. <tr>
  44. <td>Source</td>
  45. <td><input id="Text2" type="text" /></td>
  46. <td>Status</td>
  47. <td><input id="Text7" /></td>
  48. </tr>
  49. <tr>
  50. <td class="auto-style2">Issue</td>
  51. <td class="auto-style2"><input id="Text3" value="" type="text" /></td>
  52. <td class="auto-style2">Reason</td>
  53. <td class="auto-style2"><input id="Text8" value="" type="text" /></td>
  54. </tr>
  55. <tr>
  56. <td>Date/Time Opened</td>
  57. <td><input id="Text4" type="text" value="" /></td>
  58. <td>Age(Days)</td>
  59. <td><input id="Text10" type="text" value="" /></td>
  60. </tr>
  61. <tr>
  62. <td>Resolution</td>
  63. <td><select id="Select1" name="D1">
  64. <option></option>
  65. </select></td>
  66. <td>Final Status</td>
  67. <td><select id="Select2" name="D2">
  68. <option value=" "></option>
  69. </select></td>
  70. </tr>
  71. <tr>
  72. <td>Start Time</td>
  73. <td><input id="Text5" type="text" value="Start Time" /></td>
  74. <td>End Time</td>
  75. <td><input id="Text9" type="text" value="end Time" /></td>
  76. </tr>
  77. </table>
  78. <input type="button" value="Submit" name="submitButton"
  79. id="submitButton" disabled="disabled" onClick="enableGetCase()" />
  80. </form>
  81. </div>
  82. <script type="text/javascript" src="SampleJS.js"></script>
  83. </body>
  84.  
  85. package org.servlet;
  86.  
  87. import java.io.IOException;
  88. import javax.servlet.ServletException;
  89. import javax.servlet.annotation.WebServlet;
  90. import javax.servlet.http.HttpServlet;
  91. import javax.servlet.http.HttpServletRequest;
  92. import javax.servlet.http.HttpServletResponse;
  93.  
  94. import org.DAO.GetTheCountsDAO;
  95.  
  96. import com.google.gson.Gson;
  97.  
  98. import net.sf.json.JSONObject;
  99.  
  100. /**
  101. * Servlet implementation class GetTheCounts
  102. */
  103. @WebServlet("/GetTheCounts")
  104. public class GetTheCounts extends HttpServlet {
  105. private static final long serialVersionUID = 1L;
  106.  
  107. /**
  108. * @see HttpServlet#HttpServlet()
  109. */
  110. public GetTheCounts() {
  111. super();
  112. // TODO Auto-generated constructor stub
  113. }
  114.  
  115. /**
  116. * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
  117. * response)
  118. */
  119. protected void doGet(HttpServletRequest request, HttpServletResponse response)
  120. throws ServletException, IOException {
  121.  
  122. GetTheCountsDAO getTheCountsDAO = new GetTheCountsDAO();
  123. try {
  124. response.setContentType("application/json");
  125. int excelCount = getTheCountsDAO.getTotalFromExcel();
  126. int DAOCount = getTheCountsDAO.getTotalFromDB();
  127. double getEffeciency = getTheCountsDAO.getEffeciency();
  128. JSONObject jsonObject = new JSONObject();
  129. jsonObject.put("DAOCount", DAOCount);
  130. jsonObject.put("excelCount", excelCount);
  131. jsonObject.put("effeciency", getEffeciency);
  132. String json = new Gson().toJson(jsonObject);
  133. response.setCharacterEncoding("UTF-8");
  134. System.out.println("Returned String is " + json);
  135. response.getWriter().write(json);
  136.  
  137. } catch (Exception e) {
  138. // TODO Auto-generated catch block
  139. e.printStackTrace();
  140. }
  141. }
  142.  
  143. }
  144.  
  145. package org.DAO;
  146.  
  147. import java.sql.Connection;
  148. import java.sql.DriverManager;
  149. import java.sql.ResultSet;
  150. import java.sql.Statement;
  151. import org.code.general.DBConnection;
  152.  
  153. public class GetTheCountsDAO {
  154. DBConnection dbConnection = new DBConnection();
  155. int excelCount, DBCount, effeciency;
  156. double timeTaken = -1.0;
  157.  
  158. public int getTotalFromExcel() throws Exception {
  159. Connection conn = dbConnection.getConn();
  160. Statement stmt = dbConnection.getStmt();
  161. ResultSet rs = dbConnection.getRs();
  162. String excelPath = dbConnection.getExcelPath();
  163. String queryString = null;
  164. dbConnection.createClassForNameForExcel();
  165. conn = DriverManager.getConnection(
  166. "jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DBQ=" + excelPath + "; READONLY=FALSE;");
  167. stmt = conn.createStatement();
  168. queryString = "SELECT COUNT(*) as CNT from [report1448039568905$]";
  169. rs = stmt.executeQuery(queryString);
  170. rs.next();
  171. excelCount = rs.getInt("CNT");
  172. rs.close();
  173. return excelCount;
  174. }
  175.  
  176. public int getTotalFromDB() throws Exception {
  177. Connection conn = dbConnection.getConn();
  178. Statement stmt, stmt1 = dbConnection.getStmt();
  179. ResultSet rs, rs1 = dbConnection.getRs();
  180.  
  181. String queryString, queryString1 = null;
  182. dbConnection.createClassForNameForSQLServer();
  183. String userName = "sa";
  184. String password = "T!ger123";
  185. String url = "jdbc:sqlserver://U0138039-TPD-A\SQLEXPRESS;DatabaseName=TEST";
  186. dbConnection.createClassForNameForSQLServer();
  187. conn = DriverManager.getConnection(url, userName, password);
  188. stmt = conn.createStatement();
  189. queryString = "SELECT COUNT(*) as CNT from statusTable";
  190. rs = stmt.executeQuery(queryString);
  191. rs.next();
  192. DBCount = rs.getInt("CNT");
  193. rs.close();
  194. stmt.close();
  195. stmt1 = conn.createStatement();
  196. queryString1 = "select sum([Time Taken(minutes)]) as timeTaken from statusTable";
  197. rs1 = stmt1.executeQuery(queryString1);
  198. rs1.next();
  199. timeTaken = rs1.getDouble(1);
  200. stmt1.close();
  201. conn.close();
  202. return DBCount;
  203. }
  204.  
  205. public double getEffeciency() throws Exception {
  206. double getAtcualProcessed = DBCount / timeTaken;
  207. double effeciency = (getAtcualProcessed / 8) * 100;
  208. return Math.round(effeciency * 100) / 100.00;
  209. }
  210.  
  211. }
  212.  
  213. @CHARSET "ISO-8859-1";
  214.  
  215. .header {
  216. position: fixed;
  217. top: 1em;
  218. left: 0px;
  219. width: 100%;
  220. padding-bottom: 3em;
  221. border-bottom: 1px solid black;
  222. background: #ff8800;
  223. }
  224.  
  225. .bodytag {
  226. margin-top: 7em;
  227. display: table;
  228. margin-right: auto;
  229. margin-left: auto;
  230. border: 1px solid lightgray;
  231. padding: 3em;
  232. }
  233.  
  234. span.totalTime {
  235. display: block;
  236. float: left;
  237. margin-left: 1.5em;
  238. position: absolute;
  239. top: 30px;
  240. color: white;
  241. font-weight: bold;
  242. }
  243.  
  244. span.effeciency {
  245. display: block;
  246. float: right;
  247. width: auto;
  248. margin-right: 2em;
  249. top: 30px;
  250. position: relative;
  251. color: white;
  252. font-weight: bold;
  253. }
  254.  
  255. #getCase {
  256. margin-left: auto;
  257. margin-right: auto;
  258. margin-bottom: 1em;
  259. display: block;
  260. }
  261.  
  262. #submitButton {
  263. margin-left: auto;
  264. margin-right: auto;
  265. margin-top: 1em;
  266. display: block;
  267. }
  268.  
  269. #postData {
  270. margin-left: auto;
  271. margin-right: auto;
  272. margin-top: 1em;
  273. display: block;
  274. }
  275.  
  276. table {
  277. border-spacing: 10px;
  278. border-collapse: separate;
  279. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement