public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // ActionMessages msg = new ActionMessages(); //建立共用訊息 // ActionMessages error = new ActionMessages(); //建立共用錯誤訊息 HttpSession session = request.getSession(false); CourseManager manager = (CourseManager) getBean("courseManager"); AdminManager amanager = (AdminManager) getBean("adminManager"); DynaActionForm dForm = (DynaActionForm) form; UserCredential credential = (UserCredential) session.getAttribute("Credential"); String studentNo = credential.getStudent().getStudentNo(); String dept = manager.ezGetString( "SELECT DeptNo FROM Class c, stmd s WHERE c.ClassNo=s.depart_class AND s.student_no='" + studentNo + "'"); manager.executeSql( "INSERT INTO DeAnsw (Student_no, Depart_class, Score) VALUES " + "('" + studentNo + "', '" + dept + "', " + (Integer.parseInt(dForm.getString("Q1")) + Integer.parseInt(dForm.getString("Q2")) + Integer.parseInt(dForm.getString("Q3")) + Integer.parseInt(dForm.getString("Q4")) + Integer.parseInt(dForm.getString("Q5"))) + ");"); studentNo = null; dept = null; session.setAttribute("directory", "Student"); session.removeAttribute("deQuest"); List messageList = amanager.findMessagesByCategory("Student"); request.setAttribute("MessageList", messageList); setContentPage(request.getSession(false), "BulletinBoard.jsp"); return mapping.findForward("Main"); }
public ActionForward unspecified( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { HttpSession session = request.getSession(false); // DynaActionForm dForm = (DynaActionForm) form; // ActionMessages error = new ActionMessages(); //建立共用錯誤訊息 // ActionMessages msg = new ActionMessages(); CourseManager manager = (CourseManager) getBean("courseManager"); List list = manager.ezGetBy("SELECT * FROM dept ORDER BY no"); Map map; List depts = new ArrayList(); SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); String cname; for (int i = 0; i < list.size(); i++) { map = new HashMap(); map.put("no", ((Map) list.get(i)).get("no")); map.put("sname", ((Map) list.get(i)).get("sname")); map.put("fname", ((Map) list.get(i)).get("fname")); map.put("dname", ((Map) list.get(i)).get("dname")); map.put("engname", ((Map) list.get(i)).get("engname")); map.put("Oid", ((Map) list.get(i)).get("Oid")); map.put("school_name", ((Map) list.get(i)).get("school_name")); if (((Map) list.get(i)).get("last_edit_user") != null) { cname = new String(); cname = manager.ezGetString( "SELECT cname FROM empl WHERE idno='" + ((Map) list.get(i)).get("last_edit_user") + "'"); if (cname == null || cname.equals("")) { cname = manager.ezGetString( "SELECT cname FROM dempl WHERE idno='" + ((Map) list.get(i)).get("last_edit_user") + "'"); } map.put("last_edit_user", "*" + cname); } if (((Map) list.get(i)).get("last_edit_time") != null) { map.put( "last_edit_time", sf.format(sf.parse(((Map) list.get(i)).get("last_edit_time").toString()))); } depts.add(map); } session.setAttribute("depts", depts); setContentPage(request.getSession(false), "registration/DeptNameManager.jsp"); return mapping.findForward("Main"); }
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServletContext()); StudAffairManager sm = (StudAffairManager) wac.getBean("studAffairManager"); ScoreManager scm = (ScoreManager) wac.getBean("scoreManager"); HttpSession session = request.getSession(false); CourseManager manager = (CourseManager) wac.getBean("courseManager"); // UserCredential credential = // (UserCredential)session.getAttribute("Credential"); // String studentNo = credential.getMember().getAccount(); String studentNo = request.getParameter("studentno"); String sterm = Toolket.getSysParameter("School_term"); /* * if(studentNo == null) { studentNo = * credential.getStudent().getStudentNo(); } else * if(studentNo.trim().equals("")) { studentNo = * credential.getStudent().getStudentNo(); } */ response.setContentType("text/xml; charset=UTF-8"); PrintWriter out = response.getWriter(); if (!studentNo.trim().equals("")) { Student student = scm.findStudentByStudentNo(studentNo); if (student != null) { String studentName = student.getStudentName(); String departClass = student.getDepartClass(); String deptClassName = student.getDepartClass2(); String daynite = sm.chkStudentDepart(studentNo); String mode = request.getParameter("mode"); if (mode.equals("")) mode = "all"; log.info("GetTimeOff has been called! and Mode=" + mode); // Leo 20120321 將下列79~83行遮蔽,改取85~90行程式執行 // int elearnSum = 0; // List<Seld> elearnList= sm.findDilgByStudentNo(studentNo,"elearn"); // for (Seld seld : elearnList) { // elearnSum += seld.getElearnDilg(); // } String elcnt; elcnt = manager.ezGetString( "Select SUM(s.`elearn_dilg`) " + "From Seld s, Dtime d " + "Where s.`student_no` like '" + studentNo + "' " + " And s.`Dtime_oid`=d.`Oid` " + " And d.`Sterm`='" + sterm + "' "); int elearnSum; if (elcnt == null) { elearnSum = 0; } else { elearnSum = Integer.parseInt(elcnt); } List dilgList = sm.getDilgByStudentNo(studentNo, mode); Dilg dilg; // ===========================Leo // Start==================================================================================================== List desdList = sm.findDesdByStudentNo(studentNo); Desd desd; // ===========================Leo // End====================================================================================================== String weekday = ""; // Map result = new HashMap(); out.println("<dilgPrompt>"); out.println("<mode>" + mode + "</mode>"); out.println("<studentNo>" + studentNo + "</studentNo>"); out.println("<studentName>" + studentName + "</studentName>"); out.println("<departClass>" + departClass + "</departClass>"); out.println("<deptClassName>" + deptClassName + "</deptClassName>"); out.println("<daynite>" + daynite + "</daynite>"); out.println("<elearnSum>" + elearnSum + "</elearnSum>"); if (mode.equals("all")) { if (dilgList.size() > 0) { for (Iterator<Dilg> dilgIter = dilgList.iterator(); dilgIter.hasNext(); ) { dilg = dilgIter.next(); out.println("<dilgInfo>"); out.println( "<ddate>" + Toolket.printNativeDate(dilg.getDdate()) + "(" + weekTran(dilg.getWeekDay()) + ")" + "</ddate>"); out.println("<abs0>" + dilg.getAbsName0() + "</abs0>"); out.println("<abs1>" + dilg.getAbsName1() + "</abs1>"); out.println("<abs2>" + dilg.getAbsName2() + "</abs2>"); out.println("<abs3>" + dilg.getAbsName3() + "</abs3>"); out.println("<abs4>" + dilg.getAbsName4() + "</abs4>"); out.println("<abs5>" + dilg.getAbsName5() + "</abs5>"); out.println("<abs6>" + dilg.getAbsName6() + "</abs6>"); out.println("<abs7>" + dilg.getAbsName7() + "</abs7>"); out.println("<abs8>" + dilg.getAbsName8() + "</abs8>"); out.println("<abs9>" + dilg.getAbsName9() + "</abs9>"); out.println("<abs10>" + dilg.getAbsName10() + "</abs10>"); out.println("<abs11>" + dilg.getAbsName11() + "</abs11>"); out.println("<abs12>" + dilg.getAbsName12() + "</abs12>"); out.println("<abs13>" + dilg.getAbsName13() + "</abs13>"); out.println("<abs14>" + dilg.getAbsName14() + "</abs14>"); out.println("<abs15>" + dilg.getAbsName15() + "</abs15>"); out.println("</dilgInfo>"); } } else { out.println("<dilgInfo></dilgInfo>"); } } else if (mode.equals("subject")) { if (dilgList.size() > 0) { for (Iterator dilgIter = dilgList.iterator(); dilgIter.hasNext(); ) { Map dilgMap = (Map) dilgIter.next(); out.println("<dilgInfo>"); out.println("<subjectName>" + dilgMap.get("subjectName") + "</subjectName>"); out.println("<period>" + dilgMap.get("period") + "</period>"); out.println("<tfLimit>" + dilgMap.get("tfLimit") + "</tfLimit>"); out.println("<timeOff>" + dilgMap.get("timeOff") + "</timeOff>"); out.println("<elearnDilg>" + dilgMap.get("elearnDilg") + "</elearnDilg>"); out.println("<warnning>" + dilgMap.get("warnning") + "</warnning>"); out.println("<dtimeClass>" + dilgMap.get("dtimeClass") + "</dtimeClass>"); out.println("<absType>" + dilgMap.get("absType") + "</absType>"); out.println("</dilgInfo>"); } } else { out.println("<dilgInfo></dilgInfo>"); } // ===========================Leo // Start==================================================================================================== } else if (mode.equals("desd")) { if (desdList.size() > 0) { // System.out.println(desdList.size()); for (Iterator<Desd> desdIter = desdList.iterator(); desdIter.hasNext(); ) { desd = desdIter.next(); Map Reason = manager.ezGetMap("SELECT name FROM code2 WHERE no='" + desd.getReason() + "'"); // System.out.println(Reason.get("name")); out.println("<dilgInfo>"); out.println("<ddate>" + desd.getDdate() + "</ddate>"); out.println("<no>" + desd.getNo() + "</no>"); out.println("<reason>" + Reason.get("name") + "</reason>"); out.println("<kind1>" + desd.getKind1() + "</kind1>"); out.println("<cnt1>" + desd.getCnt1() + "</cnt1>"); out.println("<kind2>" + desd.getKind2() + "</kind2>"); out.println("<cnt2>" + desd.getCnt2() + "</cnt2>"); out.println("</dilgInfo>"); } } else { out.println("<dilgInfo></dilgInfo>"); } } // ===========================Leo // End====================================================================================================== out.println("</dilgPrompt>"); out.close(); } else { out.println("<dilgPrompt>"); out.println("<dilgInfo>"); out.println("<mode>notfound</mode>"); out.println("</dilgInfo>"); out.println("</dilgPrompt>"); out.close(); } } else { out.println("<dilgPrompt>"); out.println("<dilgInfo>"); out.println("<mode>notfound</mode>"); out.println("</dilgInfo>"); out.println("</dilgPrompt>"); out.close(); } }
/** * 下載 * * @throws IOException */ public ActionForward Download( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException { // Toolket.resetCheckboxCookie(response, "FN"); // Toolket.resetCheckboxCookie(response, "FNList"); // Toolket.resetCheckboxCookie(response, "FN_List"); // Toolket.resetCheckboxCookie(response, "FA_List"); Toolket.resetCheckboxCookie(response, "FNList"); HttpSession session = request.getSession(false); CourseManager manager = (CourseManager) getBean("courseManager"); // DynaActionForm aForm = (DynaActionForm) form; // UserCredential user = (UserCredential) session.getAttribute("Credential"); // ActionMessages messages = new ActionMessages(); String ids = Toolket.getSelectedIndexFromCookie(request, "FNList"); String FL_id = ids.substring(1, ids.length() - 1); String FN_id = manager.ezGetString("Select FN_Oid From File_DataList Where Oid = '" + FL_id + "'"); String SelType = manager.ezGetString("Select FN_Type From File_Name Where Oid = '" + FN_id + "'"); String FD_ShareType = manager.ezGetString("Select ShareType From File_DataList Where Oid = '" + FL_id + "'"); String FN_Share = manager.ezGetString("Select Share From File_Name Where Oid = '" + FN_id + "'"); String URL = manager.ezGetString("Select Data_URL From File_DataList Where Oid = '" + FL_id + "'"); String pristineData = manager.ezGetString("Select pristineData From File_DataList Where Oid = '" + FL_id + "'"); manager.DownloadFileFTPServer( URL, pristineData, session.getServletContext().getRealPath("/UserFiles/").toString()); try { response.setContentType("application/octet-stream; charset=utf-8"); String path = session.getServletContext().getRealPath("/UserFiles/") + "/" + pristineData; File file = new File(path); if (!file.exists()) { if (!file.exists()) { file = new File(path); } } try { String realName = java.net.URLEncoder.encode(file.getName(), "utf-8"); response.setHeader("Content-Disposition", "attachment; filename=\"" + realName + "\""); if (file.exists()) { FileInputStream in = new FileInputStream(file); OutputStream out = response.getOutputStream(); byte[] b = new byte[100]; int len; while ((len = in.read(b)) > 0) { out.write(b, 0, len); } if (in != null) { in.close(); } if (out != null) { out.close(); } file.delete(); } } catch (Exception e) { System.out.println(path + " generate errors!"); e.printStackTrace(); } } catch (Exception e) { response.setHeader("Content-Disposition", "attachment;filename=ProjectReport.doc"); response.setContentType("application/vnd.ms-word; charset=UTF-8"); PrintWriter out = response.getWriter(); out.println("<html>"); out.println("<body>"); out.println("下載檔案方式不正確!"); out.println("</body>"); out.println("</html>"); out.close(); } Toolket.resetCheckboxCookie(response, "FNList"); return mapping.findForward("File_OutDownload"); // return nul // System.out.println(session.getServletContext().getRealPath("/UserFiles/")+"/"+pristineData) }