Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%@page import="org.bean.UserBean"%>
- <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
- pageEncoding="ISO-8859-1"%>
- <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
- <script type="text/javascript"
- src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
- <link rel="stylesheet" type="text/css" href="myCssFile.css">
- <title>Insert title here</title>
- <script type="text/javascript">
- function enableSubmit() {
- document.getElementById("getCase").disabled = true;
- document.getElementById("submitButton").disabled = false;
- }
- function enableGetCase() {
- document.getElementById("getCase").disabled = false;
- document.getElementById("submitButton").disabled = true;
- }
- </script>
- </head>
- <body>
- <div class="header" id="header">
- <form id="form1"></form>
- </div>
- <div class="bodytag">
- <form method="get" action="GetData">
- <input type="Submit" value="Get Case" name="getCase" id="getCase"
- onclick="enableSubmit()" />
- <table>
- <tr>
- <td>Case Number</td>
- <td><input id="Text1" type="text" value="" /></td>
- <td>Case Owner</td>
- <td><input id="Text6" type="text" value="" /></td>
- </tr>
- <tr>
- <td>Source</td>
- <td><input id="Text2" type="text" /></td>
- <td>Status</td>
- <td><input id="Text7" /></td>
- </tr>
- <tr>
- <td class="auto-style2">Issue</td>
- <td class="auto-style2"><input id="Text3" value="" type="text" /></td>
- <td class="auto-style2">Reason</td>
- <td class="auto-style2"><input id="Text8" value="" type="text" /></td>
- </tr>
- <tr>
- <td>Date/Time Opened</td>
- <td><input id="Text4" type="text" value="" /></td>
- <td>Age(Days)</td>
- <td><input id="Text10" type="text" value="" /></td>
- </tr>
- <tr>
- <td>Resolution</td>
- <td><select id="Select1" name="D1">
- <option></option>
- </select></td>
- <td>Final Status</td>
- <td><select id="Select2" name="D2">
- <option value=" "></option>
- </select></td>
- </tr>
- <tr>
- <td>Start Time</td>
- <td><input id="Text5" type="text" value="Start Time" /></td>
- <td>End Time</td>
- <td><input id="Text9" type="text" value="end Time" /></td>
- </tr>
- </table>
- <input type="button" value="Submit" name="submitButton"
- id="submitButton" disabled="disabled" onClick="enableGetCase()" />
- </form>
- </div>
- <script type="text/javascript" src="SampleJS.js"></script>
- </body>
- package org.servlet;
- import java.io.IOException;
- import javax.servlet.ServletException;
- import javax.servlet.annotation.WebServlet;
- import javax.servlet.http.HttpServlet;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import org.DAO.GetTheCountsDAO;
- import com.google.gson.Gson;
- import net.sf.json.JSONObject;
- /**
- * Servlet implementation class GetTheCounts
- */
- @WebServlet("/GetTheCounts")
- public class GetTheCounts extends HttpServlet {
- private static final long serialVersionUID = 1L;
- /**
- * @see HttpServlet#HttpServlet()
- */
- public GetTheCounts() {
- super();
- // TODO Auto-generated constructor stub
- }
- /**
- * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
- * response)
- */
- protected void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- GetTheCountsDAO getTheCountsDAO = new GetTheCountsDAO();
- try {
- response.setContentType("application/json");
- int excelCount = getTheCountsDAO.getTotalFromExcel();
- int DAOCount = getTheCountsDAO.getTotalFromDB();
- double getEffeciency = getTheCountsDAO.getEffeciency();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("DAOCount", DAOCount);
- jsonObject.put("excelCount", excelCount);
- jsonObject.put("effeciency", getEffeciency);
- String json = new Gson().toJson(jsonObject);
- response.setCharacterEncoding("UTF-8");
- System.out.println("Returned String is " + json);
- response.getWriter().write(json);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
- package org.DAO;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.Statement;
- import org.code.general.DBConnection;
- public class GetTheCountsDAO {
- DBConnection dbConnection = new DBConnection();
- int excelCount, DBCount, effeciency;
- double timeTaken = -1.0;
- public int getTotalFromExcel() throws Exception {
- Connection conn = dbConnection.getConn();
- Statement stmt = dbConnection.getStmt();
- ResultSet rs = dbConnection.getRs();
- String excelPath = dbConnection.getExcelPath();
- String queryString = null;
- dbConnection.createClassForNameForExcel();
- conn = DriverManager.getConnection(
- "jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DBQ=" + excelPath + "; READONLY=FALSE;");
- stmt = conn.createStatement();
- queryString = "SELECT COUNT(*) as CNT from [report1448039568905$]";
- rs = stmt.executeQuery(queryString);
- rs.next();
- excelCount = rs.getInt("CNT");
- rs.close();
- return excelCount;
- }
- public int getTotalFromDB() throws Exception {
- Connection conn = dbConnection.getConn();
- Statement stmt, stmt1 = dbConnection.getStmt();
- ResultSet rs, rs1 = dbConnection.getRs();
- String queryString, queryString1 = null;
- dbConnection.createClassForNameForSQLServer();
- String userName = "sa";
- String password = "T!ger123";
- String url = "jdbc:sqlserver://U0138039-TPD-A\SQLEXPRESS;DatabaseName=TEST";
- dbConnection.createClassForNameForSQLServer();
- conn = DriverManager.getConnection(url, userName, password);
- stmt = conn.createStatement();
- queryString = "SELECT COUNT(*) as CNT from statusTable";
- rs = stmt.executeQuery(queryString);
- rs.next();
- DBCount = rs.getInt("CNT");
- rs.close();
- stmt.close();
- stmt1 = conn.createStatement();
- queryString1 = "select sum([Time Taken(minutes)]) as timeTaken from statusTable";
- rs1 = stmt1.executeQuery(queryString1);
- rs1.next();
- timeTaken = rs1.getDouble(1);
- stmt1.close();
- conn.close();
- return DBCount;
- }
- public double getEffeciency() throws Exception {
- double getAtcualProcessed = DBCount / timeTaken;
- double effeciency = (getAtcualProcessed / 8) * 100;
- return Math.round(effeciency * 100) / 100.00;
- }
- }
- @CHARSET "ISO-8859-1";
- .header {
- position: fixed;
- top: 1em;
- left: 0px;
- width: 100%;
- padding-bottom: 3em;
- border-bottom: 1px solid black;
- background: #ff8800;
- }
- .bodytag {
- margin-top: 7em;
- display: table;
- margin-right: auto;
- margin-left: auto;
- border: 1px solid lightgray;
- padding: 3em;
- }
- span.totalTime {
- display: block;
- float: left;
- margin-left: 1.5em;
- position: absolute;
- top: 30px;
- color: white;
- font-weight: bold;
- }
- span.effeciency {
- display: block;
- float: right;
- width: auto;
- margin-right: 2em;
- top: 30px;
- position: relative;
- color: white;
- font-weight: bold;
- }
- #getCase {
- margin-left: auto;
- margin-right: auto;
- margin-bottom: 1em;
- display: block;
- }
- #submitButton {
- margin-left: auto;
- margin-right: auto;
- margin-top: 1em;
- display: block;
- }
- #postData {
- margin-left: auto;
- margin-right: auto;
- margin-top: 1em;
- display: block;
- }
- table {
- border-spacing: 10px;
- border-collapse: separate;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement