/**
   * 處理確定更新學生選課內容之方法
   *
   * @param mapping org.apache.struts.action.ActionMapping object
   * @param form org.apache.struts.action.ActionForm object
   * @param request javax.servlet.http.HttpServletRequest object
   * @param response javax.servlet.http.HttpServletResponse object
   * @return org.apache.struts.action.ActionForward object
   * @exception java.lang.Exception
   */
  public ActionForward update(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    DynaActionForm aForm = (DynaActionForm) form;
    ActionMessages messages = validateInputForUpdate(aForm, Toolket.getBundle(request));
    if (!messages.isEmpty()) {
      saveErrors(request, messages);
      return mapping.findForward(IConstants.ACTION_MAIN_NAME);
    } else {
      try {
        Short selectLimit = (Short) aForm.get("selectLimit");
        CourseManager cm = (CourseManager) getBean(COURSE_MANAGER_BEAN_NAME);
        cm.txUpdateDtimeSelLimit(aForm.getString("dtimeOid"), selectLimit);
        messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Message.ModifySuccessful"));
        saveMessages(request, messages);
        Toolket.resetCheckboxCookie(response, SELD_LIST_NAME);
        return mapping.findForward(IConstants.ACTION_SUCCESS_NAME);
      } catch (Exception e) {
        ActionMessages errors = new ActionMessages();
        errors.add(
            ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Exception.generic", e.getMessage()));
        saveErrors(request, errors);
        return mapping.findForward(IConstants.ACTION_MAIN_NAME);
      }
    }
  }
Exemplo n.º 2
0
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    WebApplicationContext ctx =
        WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServletContext());
    CourseManager manager = (CourseManager) ctx.getBean("courseManager");

    InternetAddress addr;
    InternetAddress address[] = new InternetAddress[1];
    addr = new InternetAddress("*****@*****.**", "cust", "BIG5");
    address[0] = addr;

    manager.sendMail(
        "",
        "",
        "www.cust.edu.tw",
        "*****@*****.**",
        "王小明",
        new Date(),
        "測試",
        "<img src='http://192.192.237.19/CIS/CountImage?userid=77'>",
        address,
        null);

    // response.setContentType("image/jpeg");
    // response.sendRedirect("/CIS/pages/images/transparent.gif");
  }
Exemplo n.º 3
0
  /**
   * 修改
   *
   * @param mapping
   * @param form
   * @param request
   * @param response
   * @return
   * @throws Exception
   */
  public ActionForward ok(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    DynaActionForm dForm = (DynaActionForm) form;
    ActionMessages error = new ActionMessages(); // 建立共用錯誤訊息
    ActionMessages msg = new ActionMessages();
    CourseManager manager = (CourseManager) getBean("courseManager");

    String no[] = dForm.getStrings("no");
    String sname[] = dForm.getStrings("sname");
    String school_name[] = dForm.getStrings("school_name");
    String fname[] = dForm.getStrings("fname");
    String dname[] = dForm.getStrings("dname");
    String engname[] = dForm.getStrings("engname");
    String Oid[] = dForm.getStrings("Oid");
    String editCheck[] = dForm.getStrings("editCheck");

    Member me = getUserCredential(request.getSession(false)).getMember();
    for (int i = 1; i < Oid.length; i++) {
      // System.out.println("editCheck["+i+"]="+editCheck[i]);
      if (!editCheck[i].equals("")) {

        if (!no[i].equals("")) {

          Dept dept = (Dept) manager.hqlGetBy("FROM Dept WHERE Oid='" + Oid[i] + "'").get(0);
          dept.setDname(dname[i]);
          dept.setEngname(engname[i]);
          dept.setFname(fname[i]);
          dept.setLastEditUser(me.getIdno());
          dept.setNo(no[i]);
          dept.setSchoolName(school_name[i]);
          dept.setLastEditTime(new Date());
          dept.setSname(sname[i]);

          try {
            manager.updateObject(dept);
          } catch (Exception e) {
            e.printStackTrace();
            error.add(
                ActionErrors.GLOBAL_MESSAGE,
                new ActionError("Course.messageN1", dept.getFname() + "修改失敗"));
          }
        }
      }
    }

    if (!error.isEmpty()) {
      saveErrors(request, error);
      return unspecified(mapping, form, request, response);
    } else {
      // msg.add(ActionErrors.GLOBAL_MESSAGE, new ActionMessage("Course.messageN1", "修改完成"));
      saveMessages(request, msg);
    }
    return unspecified(mapping, form, request, response);
  }
Exemplo n.º 4
0
  /** 執行查詢動作 */
  public ActionForward Query(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response) {

    // 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");

    String SelKeyWords = aForm.getString("Data_name");
    String SelUnit = aForm.getString("FN_Unit");

    String Sel_KW =
        "  And (FD.KeyWords Like '%" + SelKeyWords + "%' or FN.Name Like '%" + SelKeyWords + "%') ";
    String Sel_UT = "  And FN.FN_Unit = '" + SelUnit + "' ";

    if (SelKeyWords.equals("")) {
      Sel_KW = "";
    }
    if (SelUnit.equals("")) {
      Sel_UT = "";
    }

    // List<FileName> FNList = null;
    List FNList =
        manager.ezGetBy(
            "Select FD.Oid, C.name Unit, FD.DocNo, FD.MeetingType, FD.MeetingDate, FN.Name FN_Name "
                + "From File_DataList FD, File_User FU, code5 C, File_Name FN "
                + "Where FD.FN_Oid = FU.FN_Oid "
                + "  And FD.FN_Oid = FN.Oid "
                + "  And FN.FN_Unit = C.Oid "
                + "  And FD.approve = '97' "
                + "  And FN.FN_Type = '550' "
                + "  And FN.OpenLine = '637'"
                + "  And FD.ShareType = '563'"
                + Sel_KW
                + Sel_UT
                + "Group By FN.Name "
                + "Order By C.name, FN.Name DESC ");

    session.setAttribute("FN_List", FNList);
    session.setAttribute("myOpen", "open");
    session.setAttribute("showType", "Query");
    return mapping.findForward("File_OutDownload");
  }
  /**
   * 處理學生退選線上選課紀錄之方法
   *
   * @param mapping org.apache.struts.action.ActionMapping object
   * @param form org.apache.struts.action.ActionForm object
   * @param request javax.servlet.http.HttpServletRequest object
   * @param response javax.servlet.http.HttpServletResponse object
   * @return org.apache.struts.action.ActionForward object
   * @exception java.lang.Exception
   */
  public ActionForward deleteCourse(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    DynaActionForm aForm = (DynaActionForm) form;
    ActionMessages messages = validateInputForUpdate(aForm, Toolket.getBundle(request));
    if (!messages.isEmpty()) {
      saveErrors(request, messages);
      return mapping.findForward(IConstants.ACTION_MAIN_NAME);
    } else {

      List<SeldDataInfo> aList = getSeldDataListByIndex(request);
      if (!aList.isEmpty()) {

        CourseManager cm = (CourseManager) getBean(COURSE_MANAGER_BEAN_NAME);
        // 取得選課欲退選之Oid列表
        StringBuffer seldBuf = new StringBuffer();
        for (SeldDataInfo info : aList) {
          seldBuf.append(info.getSeldOid()).append(",");
        }
        String inSyntax = StringUtils.substringBeforeLast(seldBuf.toString(), ",");
        log.info("Seld Oid SQL IN Syntax : " + inSyntax);
        String studentNo = aForm.getString("stdNo").toUpperCase();
        MemberManager mm = (MemberManager) getBean(MEMBER_MANAGER_BEAN_NAME);
        String classNo = mm.findStudentByNo(studentNo).getDepartClass();
        // 只有第一階段不會檢查選課人數下限
        cm.txRemoveSelectedSeld(studentNo, classNo, 1, inSyntax, false);
        String idno = getUserCredential(request.getSession(false)).getMember().getIdno();
        for (SeldDataInfo info : aList) {
          cm.txSaveAdcdHistory(info.getDtimeOid(), studentNo.toUpperCase(), idno, "D");
        }
        messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Message.DeleteSuccessful"));
        saveMessages(request, messages);
        // aForm.initialize(mapping);
        Toolket.resetCheckboxCookie(response, SELD_LIST_NAME);
        setContentPage(request.getSession(false), "course/OnlineAddRemoveCourse.jsp");
      } else {
        messages = new ActionMessages();
        messages.add(
            ActionMessages.GLOBAL_MESSAGE,
            new ActionMessage("Course.onlineAddRemoveCourse.unselected"));
        saveErrors(request, messages);
        return mapping.findForward(IConstants.ACTION_MAIN_NAME);
      }
    }

    return list(mapping, form, request, response);
  }
 private Seld processSeldByForm(DynaActionForm form) {
   CourseManager cm = (CourseManager) getBean(COURSE_MANAGER_BEAN_NAME);
   Seld seld = new Seld();
   Dtime dtime = cm.findDtimeBy(Integer.valueOf(form.getString("oid")));
   seld.setDtimeOid(Integer.valueOf(form.getString("oid")));
   seld.setStudentNo(form.getString("stdNo").toUpperCase());
   seld.setOpt(form.getString("optId"));
   seld.setCredit((Float) (form.get("credit")));
   seld.setDepartClass(dtime.getDepartClass());
   seld.setDepartClassName(Toolket.getClassFullName(dtime.getDepartClass()));
   seld.setCscode(dtime.getCscode().toUpperCase());
   seld.setCscodeName(cm.findCourseInfoByCscode(dtime.getCscode().toUpperCase()).getChiName());
   return seld;
 }
  /**
   * 處理學生課程衝突後確定加選之方法
   *
   * @param mapping org.apache.struts.action.ActionMapping object
   * @param form org.apache.struts.action.ActionForm object
   * @param request javax.servlet.http.HttpServletRequest object
   * @param response javax.servlet.http.HttpServletResponse object
   * @return org.apache.struts.action.ActionForward object
   * @exception java.lang.Exception
   */
  public ActionForward makeSureAdd(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    DynaActionForm aForm = (DynaActionForm) form;
    CourseManager cm = (CourseManager) getBean(IConstants.COURSE_MANAGER_BEAN_NAME);
    String stdNo = aForm.getString("stdNo");
    ScoreManager sm = (ScoreManager) getBean(SCORE_MANAGER_BEAN_NAME);
    Student student = sm.findStudentByStudentNo(stdNo);
    cm.txCreateBaseSelectedForStudent(student, "1");
    return list(mapping, form, request, response);
  }
Exemplo n.º 8
0
  /**
   * 新增
   *
   * @param mapping
   * @param form
   * @param request
   * @param response
   * @return
   * @throws Exception
   */
  public ActionForward create(
      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");

    String no[] = dForm.getStrings("no");
    String sname[] = dForm.getStrings("sname");
    String school_name[] = dForm.getStrings("school_name");
    String fname[] = dForm.getStrings("fname");
    String dname[] = dForm.getStrings("dname");
    String engname[] = dForm.getStrings("engname");

    if (no[0].equals("") || school_name[0].equals("") || fname[0].equals("")) {

      error.add(ActionErrors.GLOBAL_MESSAGE, new ActionError("Course.messageN1", "某些必要欄位不得空白"));
      saveErrors(request, error);
      return mapping.findForward("Main");
    }
    Member me = getUserCredential(request.getSession(false)).getMember();
    Dept dept = new Dept();
    dept.setDname(dname[0]);
    dept.setEngname(engname[0]);
    dept.setFname(fname[0]);
    dept.setLastEditUser(me.getIdno());
    dept.setNo(no[0]);
    dept.setSchoolName(school_name[0]);
    dept.setLastEditTime(new Date());
    dept.setSname(sname[0]);

    try {
      manager.updateObject(dept);
    } catch (Exception e) {
      e.printStackTrace();
      error.add(ActionErrors.GLOBAL_MESSAGE, new ActionError("Course.messageN1", "儲存失敗"));
      saveErrors(request, error);
      return mapping.findForward("Main");
    }

    return unspecified(mapping, form, request, response);
  }
Exemplo n.º 9
0
  public ActionForward unspecified(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    HttpSession session = request.getSession(false);
    CourseManager manager = (CourseManager) getBean("courseManager");

    session.setAttribute("allSchoolType", manager.getAllSchoolType());
    session.setAttribute(
        "allDept",
        manager.ezGetBy("SELECT name, idno FROM code5 WHERE category='Dept' ORDER BY idno"));
    setContentPage(request.getSession(false), "chief/CoanswReview.jsp");
    return mapping.findForward("Main");
  }
Exemplo n.º 10
0
  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");
  }
Exemplo n.º 11
0
  /**
   * 處理確定加選學生低修高選課內容之方法
   *
   * @param mapping org.apache.struts.action.ActionMapping object
   * @param form org.apache.struts.action.ActionForm object
   * @param request javax.servlet.http.HttpServletRequest object
   * @param response javax.servlet.http.HttpServletResponse object
   * @return org.apache.struts.action.ActionForward object
   * @exception java.lang.Exception
   */
  public ActionForward addHigherCourse(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    MemberManager mm = (MemberManager) getBean(MEMBER_MANAGER_BEAN_NAME);
    CourseManager cm = (CourseManager) getBean(COURSE_MANAGER_BEAN_NAME);
    ActionMessages messages = new ActionMessages();
    Seld seld = (Seld) request.getSession(false).getAttribute("seldInfoForOnline");

    try {
      Student student = mm.findStudentByNo(seld.getStudentNo());
      cm.txAddSelectedSeld(seld, student, "1", true);
      String idno = getUserCredential(request.getSession(false)).getMember().getIdno();
      cm.txSaveAdcdHistory(seld.getDtimeOid(), student.getStudentNo().toUpperCase(), idno, "A");
      messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Message.CreateSuccessful"));
      saveMessages(request, messages);
      Toolket.resetCheckboxCookie(response, SELD_LIST_NAME);
      return list(mapping, form, request, response);

    } catch (SeldException se) {
      ActionMessages errors = new ActionMessages();
      errors.add(
          ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Course.errorN1", se.getMessage()));
      saveErrors(request, errors);
      if (se.getMessage().indexOf("衝堂") != StringUtils.INDEX_NOT_FOUND) {
        // 目前會拒絕衝堂課程進行加選
        Dtime dtime = cm.findDtimeBy(seld.getDtimeOid());
        Csno csno = cm.findCourseInfoByCscode(dtime.getCscode());
        request.setAttribute("csnoInfo", csno);
        request.setAttribute("classInfo", Toolket.getClassFullName(dtime.getDepartClass()));
        setContentPage(request.getSession(false), "course/ConflictList.jsp");
        return list(mapping, form, request, response);
      } else return list(mapping, form, request, response);
    }
  }
Exemplo n.º 12
0
  /**
   * 處理學生課程衝突後確定加選之方法
   *
   * @param mapping org.apache.struts.action.ActionMapping object
   * @param form org.apache.struts.action.ActionForm object
   * @param request javax.servlet.http.HttpServletRequest object
   * @param response javax.servlet.http.HttpServletResponse object
   * @return org.apache.struts.action.ActionForward object
   * @exception java.lang.Exception
   */
  public ActionForward conflictAdd(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    // 選課人數上線於前端JavaScript判斷
    // 跨選設定不允許須阻擋並顯示訊息
    Seld seld = (Seld) request.getSession(false).getAttribute("seldInfoForOnline");
    MemberManager mm = (MemberManager) getBean(MEMBER_MANAGER_BEAN_NAME);
    Student student = mm.findStudentByNo(seld.getStudentNo());
    CourseManager cm = (CourseManager) getBean(COURSE_MANAGER_BEAN_NAME);
    // false代表不做衝堂判斷
    cm.txAddSelectedSeld(seld, student, "1", false);
    cm.txAddSeldConflictInfo(
        seld, getUserCredential(request.getSession(false)).getMember(), student, "1");
    ActionMessages messages = new ActionMessages();
    messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Message.CreateSuccessful"));
    saveMessages(request, messages);
    Toolket.resetCheckboxCookie(response, SELD_LIST_NAME);
    return list(mapping, form, request, response);
  }
Exemplo n.º 13
0
  /** 初始資料 */
  public ActionForward unspecified(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    // Toolket.resetCheckboxCookie(response, "FN");
    Toolket.resetCheckboxCookie(response, "FNList");
    // Toolket.resetCheckboxCookie(response, "FN_List");
    // Toolket.resetCheckboxCookie(response, "FA_List");

    HttpSession session = request.getSession(false);
    CourseManager manager = (CourseManager) getBean("courseManager");

    session.setAttribute(
        "FN_Unit",
        manager.ezGetBy( // 排除沒有法規的單位 sequence = 0
            "Select Oid, name From code5 Where category='FileUnit' And sequence <> '0' Order By Oid")); // 取得所屬單位選項
    /*
    List FNList = manager.ezGetBy(
    		"Select FD.Oid, C.name Unit, FD.DocNo, FD.MeetingType, FD.MeetingDate, FN.Name FN_Name " +
    		"From File_DataList FD, File_User FU, code5 C, File_Name FN " +
    		"Where FD.FN_Oid = FU.FN_Oid " +
    		"  And FD.FN_Oid = FN.Oid " +
    		"  And FN.FN_Unit = C.Oid " +
    		"  And FD.approve = '97' " +
    		"  And FN.FN_Type = '550' " +
    		"  And FN.OpenLine = '637'" +
    		"  And FD.ShareType = '563'"+
    		"Group By FN.Name " +
            "Order By C.name, FN.Name DESC ");
    session.setAttribute("FN_List", FNList);	*/

    session.setAttribute("myOpen", "close");
    return mapping.findForward("File_OutDownload");
  }
Exemplo n.º 14
0
  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();
    }
  }
Exemplo n.º 15
0
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    WebApplicationContext ctx =
        WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServletContext());

    CourseManager manager = (CourseManager) ctx.getBean("courseManager");
    HttpSession session = request.getSession(false);
    boolean b = false;
    if (request.getParameter("count") != null) {
      b = true;
    }

    List students = (List) session.getAttribute("students");

    ByteArrayOutputStream ba = new ByteArrayOutputStream();

    try {
      Document document = new Document(PageSize.A6.rotate(), 5, 5, 5, 5);

      PdfWriter writer = PdfWriter.getInstance(document, ba);
      document.open();
      Image image = null;

      Clazz clazz;
      Student stmd;
      String SchoolName;
      String DeptName;
      StringBuilder StudentNo;

      Map map;
      Map StmdCardNum;

      // writer = PdfWriter.getInstance(document, ba);
      PdfContentByte cb = writer.getDirectContent();
      BaseFont bf = BaseFont.createFont("/kaiu.ttf", "Identity-H", BaseFont.EMBEDDED);

      for (int i = 0; i < students.size(); i++) {

        stmd =
            (Student)
                manager
                    .hqlGetBy(
                        "FROM Student WHERE studentNo='"
                            + ((Map) students.get(i)).get("student_no")
                            + "'")
                    .get(0);
        clazz =
            (Clazz)
                manager.hqlGetBy("FROM Clazz WHERE ClassNo='" + stmd.getDepartClass() + "'").get(0);
        map =
            manager.ezGetMap(
                "SELECT * FROM dept WHERE no='" + clazz.getClassNo().substring(0, 4) + "'");

        try { // 系所名
          DeptName = map.get("fname").toString();
        } catch (Exception e) {
          DeptName = "";
        }
        try { // 部制名
          SchoolName = map.get("school_name").toString();
        } catch (Exception e) {
          SchoolName = "";
        }
        StudentNo = new StringBuilder(stmd.getStudentNo());
        // List list=manager.hqlGetBy("FROM StdImage WHERE studentNo='"+StudentNo+"'");

        /*
        if(b&&manager.testOnlineServer()){//寫入補發記錄
        	try{
        		//真實學號
        		manager.executeSql("INSERT INTO StmdCardNum (student_no, card_num)VALUES('"+stmd.getStudentNo()+"', 1)");
        	}catch(Exception e){
        		manager.executeSql("UPDATE StmdCardNum SET card_num=card_num+1 WHERE student_no='"+stmd.getStudentNo()+"'");
        	}
        	StudentNo.append(manager.ezGetString("SELECT card_num FROM StmdCardNum WHERE student_no='"+stmd.getStudentNo()+"'"));
        	sendMailToLib(stmd, StudentNo.toString(), request);
        }else{
        	//檢查是否已發卡
        	StmdCardNum=manager.ezGetMap("SELECT * FROM StmdCardNum WHERE student_no='"+stmd.getStudentNo()+"'");
        	if(StmdCardNum!=null){
        		StudentNo.append(manager.ezGetString("SELECT card_num FROM StmdCardNum WHERE student_no='"+stmd.getStudentNo()+"'"));
        	}
        }
        */

        StmdCardNum = manager.ezGetMap("SELECT * FROM StmdCardNum WHERE student_no='");

        // 學號不滿8碼補空白, 未來改為9碼時?
        if (StudentNo.length() <= 8) {
          for (int j = StudentNo.length(); j < 8; j++) {
            StudentNo.append(" ");
          }
        }
        // 照片
        try {
          image = getImage(StudentNo.toString());
        } catch (Exception e) {
          continue;
        }
        if (image == null) continue;

        image.scaleAbsolute(54.94f, 74.37f);
        image.setAbsolutePosition(18, 166);

        // 條碼
        Barcode39 code39 = new Barcode39();
        code39.setCode(StudentNo.toString());
        code39.setBarHeight(20);
        code39.setX(0.95f);

        code39.setStartStopText(false);
        code39.setGuardBars(false);
        code39.setExtended(false);
        code39.setChecksumText(false);
        code39.setSize(-1f);
        Image imageCode39 = code39.createImageWithBarcode(cb, null, null);

        imageCode39.setAbsolutePosition(83.15f, 152);

        cb.setColorStroke(Color.white);
        cb.rectangle(18, 150, 54.94f, 9); // 30
        cb.setLineWidth(10);
        cb.stroke();

        cb.closePath();
        cb.closePathEoFillStroke();
        cb.closePathFillStroke();
        cb.closePathStroke();

        // 文字

        cb.beginText(); // 部制
        cb.setFontAndSize(bf, 10);
        cb.showTextAligned(PdfContentByte.ALIGN_LEFT, SchoolName, 118, 229, 0);
        cb.endText();

        cb.beginText(); // 科系
        cb.setFontAndSize(bf, 10);
        if (DeptName.length() >= 9) {
          cb.setFontAndSize(bf, 8);
        }
        if (DeptName.length() >= 14) {
          cb.setFontAndSize(bf, 6);
        }

        cb.showTextAligned(PdfContentByte.ALIGN_LEFT, DeptName, 118, 215, 0);
        cb.endText();

        cb.beginText(); // 學號
        cb.setFontAndSize(bf, 10);
        cb.showTextAligned(PdfContentByte.ALIGN_LEFT, stmd.getStudentNo(), 118, 201, 0);
        cb.endText();

        cb.beginText(); // 姓名
        cb.setFontAndSize(bf, 10);
        cb.showTextAligned(PdfContentByte.ALIGN_LEFT, stmd.getStudentName(), 118, 187, 0);
        cb.endText();

        document.add(image);
        document.add(imageCode39);
        document.newPage();
        // bf=null;
      }

      document.close();
      writer.close();

      response.setHeader(
          "Content-Disposition", "attachment;filename=EmplCard" + Math.random() * 10 + ".pdf");
      response.setContentLength(ba.size());
      response.flushBuffer();
      ServletOutputStream out = response.getOutputStream();
      ba.writeTo(out);
      ba.close();
      out.flush();

    } catch (Exception e) {
      e.printStackTrace();
      try {
        Document document = new Document(PageSize.A6.rotate(), 5, 5, 5, 5);
        PdfWriter writer = PdfWriter.getInstance(document, ba);
        document.open();
        PdfContentByte cb = writer.getDirectContent();
        BaseFont bf = BaseFont.createFont("/kaiu.ttf", "Identity-H", BaseFont.EMBEDDED);
        cb.beginText(); // 部制
        cb.setFontAndSize(bf, 10);
        cb.showTextAligned(PdfContentByte.ALIGN_LEFT, "讀取資料有誤:" + e, 120, 226, 0);
        cb.endText();
        // document.add(cb );
        document.close();
        document = null;
      } catch (DocumentException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
      }

      response.setContentType("text/html; charset=UTF-8");
      response.setContentType("application/pdf");
      response.setHeader("Content-disposition", "attachment;filename=TechTimetable.pdf");
      response.setContentLength(ba.size());
      ServletOutputStream out = response.getOutputStream();
      ba.writeTo(out);
      out.flush();
    }
  }
Exemplo n.º 16
0
  /**
   * 下載
   *
   * @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)

  }
Exemplo n.º 17
0
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    WebApplicationContext ctx =
        WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServletContext());
    HttpSession session = request.getSession(false);
    CourseManager manager = (CourseManager) ctx.getBean("courseManager");
    response.setContentType("application/vnd.ms-excel");
    response.setContentType("text/html; charset=utf-8");

    response.setHeader("Content-disposition", "attachment;filename=ooxx.xls");
    PrintWriter out = response.getWriter();

    List dtimeList = (List) session.getAttribute("dtimeList");
    // String sterm=manager.getSchoolTerm().toString();
    String sterm = session.getAttribute("xterm").toString();
    StringBuffer strbuf =
        new StringBuffer(
            "SELECT d.techid, e.cname FROM Dtime d, empl e WHERE "
                +
                // "d.Sterm='"+sterm+"' AND e.idno=d.techid AND d.Oid IN(");
                "e.idno=d.techid AND d.Oid IN(");
    for (int i = 0; i < dtimeList.size(); i++) {
      strbuf.append("'" + ((Map) dtimeList.get(i)).get("oid") + "',");
    }
    strbuf.delete(strbuf.length() - 1, strbuf.length());
    strbuf.append(") GROUP BY d.techid");

    List cscodeList = manager.ezGetBy(strbuf.toString());

    // String schoolTerm=manager.getSchoolTerm().toString();

    // System.out.println(strbuf);

    for (int i = 0; i < cscodeList.size(); i++) {

      List myCs =
          manager.ezGetBy(
              "SELECT cl.ClassName, c.chi_name FROM "
                  + "((Dtime d LEFT OUTER JOIN Class cl ON d.depart_class=cl.ClassNo)LEFT OUTER JOIN "
                  + "Csno c ON d.cscode=c.cscode) WHERE d.Sterm='"
                  + sterm
                  + "' AND d.techid='"
                  + ((Map) cscodeList.get(i)).get("techid")
                  + "'");

      out.println("<table border='1' align='left'>");
      out.println("<tr>");
      out.println(
          "<td colspan='2' style='mso-number-format:\\@' nowrap>教師姓名:"
              + ((Map) cscodeList.get(i)).get("cname")
              + "</td>");
      out.println("</tr>");

      int tmp = 0;

      for (int j = 0; j < myCs.size(); j++) {

        if (j >= tmp) {
          tmp = tmp + 2;
          out.println("<tr>");
        }

        out.println(
            "<td align='right' style='mso-number-format:\\@' nowrap>"
                + ((Map) myCs.get(j)).get("ClassName")
                + "</td>");
        out.println(
            "<td align='left' style='mso-number-format:\\@' nowrap>"
                + ((Map) myCs.get(j)).get("chi_name")
                + "</td>");

        if (j >= tmp) {
          out.println("</tr>");
        }
      }

      out.println("</table>");

      out.println("<br>");
    }

    out.close();
  }
Exemplo n.º 18
0
  /**
   * 處理以學號查詢學生選課清單
   *
   * @param mapping org.apache.struts.action.ActionMapping object
   * @param form org.apache.struts.action.ActionForm object
   * @param request javax.servlet.http.HttpServletRequest object
   * @param response javax.servlet.http.HttpServletResponse object
   * @return org.apache.struts.action.ActionForward object
   * @exception java.lang.Exception
   */
  @SuppressWarnings("unchecked")
  public ActionForward list(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    DynaActionForm aForm = (DynaActionForm) form;
    HttpSession session = request.getSession(false);
    Toolket.resetCheckboxCookie(response, SELD_LIST_NAME);
    // 確實清除變數"seldList"內所存資料,因學生可能無選課資料
    session.removeAttribute(SELD_LIST_NAME);
    ActionMessages messages = validateInputForUpdate(aForm, Toolket.getBundle(request));
    if (!messages.isEmpty()) {
      saveErrors(request, messages);
      return mapping.findForward(IConstants.ACTION_MAIN_NAME);
    } else {
      try {
        CourseManager cm = (CourseManager) getBean(COURSE_MANAGER_BEAN_NAME);
        log.info("Student NO : " + aForm.getString("stdNo"));
        List<Map> seldList =
            doForDuplicate(cm.getSeldDataByStudentNo(aForm.getString("stdNo"), "1"));
        if (!seldList.isEmpty()) {
          session.setAttribute("NO", aForm.getString("stdNo").toUpperCase());
          int hours = 0, position = 0;
          float credit = 0.0F;
          List<SeldDataInfo> result = new ArrayList<SeldDataInfo>();
          SeldDataInfo info = null;
          for (Map content : seldList) {
            info = new SeldDataInfo();
            Integer dtimeOid = (Integer) content.get("oid");
            info.setClassNo((String) content.get("classNo"));
            info.setClassName((String) content.get("className"));
            info.setCsCode((String) content.get("cscode"));
            info.setCsName((String) content.get("chi_Name"));
            info.setStuSelect(String.valueOf(cm.findSeldCountByDtimeOid(dtimeOid)));
            info.setSelectLimit(((Integer) content.get("select_Limit")).toString());
            info.setHour(Short.valueOf(((Integer) content.get("thour")).toString()));
            info.setCredit((Float) content.get("credit"));
            info.setSeldOid((Integer) content.get("soid")); // Seld Oid
            String opt = (String) content.get("opt");
            info.setOpt(opt);
            info.setOptName(Toolket.getCourseOpt(opt));
            info.setDtimeOid(dtimeOid); // Dtime Oid
            info.setPosition(Integer.valueOf(position++));
            info.setTerm((String) content.get("sterm"));
            hours += ((Integer) content.get("thour")).intValue();
            credit += ((Float) content.get("credit")).floatValue();
            result.add(info);
          }
          session.setAttribute(SELD_LIST_COUNT, Integer.valueOf(seldList.size()));
          session.setAttribute(SELD_LIST_HOURS, Integer.valueOf(hours));
          session.setAttribute(
              SELD_LIST_CREDITS, Float.valueOf(new DecimalFormat("0.0").format(credit)));
          session.setAttribute(SELD_LIST_NAME, result);
          session.setAttribute("mode", "ALL");
        } else {
          // 查無資料則回傳空白List
          session.setAttribute(SELD_LIST_NAME, Collections.EMPTY_LIST);
          session.setAttribute("mode", "NONE");
          ActionMessages msg = new ActionMessages();
          msg.add(
              ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Course.messageN1", "查無任何選課資料!!"));
          saveMessages(request, msg);
        }

      } catch (Exception e) {
        ActionMessages errors = new ActionMessages();
        errors.add(
            ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Exception.generic", e.getMessage()));
        saveErrors(request, errors);
        return mapping.findForward(IConstants.ACTION_MAIN_NAME);
      }
    }

    setContentPage(request.getSession(false), "course/OnlineAddRemoveCourse.jsp");
    return mapping.findForward(IConstants.ACTION_MAIN_NAME);
  }
Exemplo n.º 19
0
  /**
   * 查詢
   *
   * @param mapping
   * @param form
   * @param request
   * @param response
   * @return
   * @throws Exception
   */
  public ActionForward query(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    HttpSession session = request.getSession(false);
    DynaActionForm reviewForm = (DynaActionForm) form;
    ActionMessages error = new ActionMessages(); // 建立共用錯誤訊息
    ActionMessages msg = new ActionMessages();
    CourseManager manager = (CourseManager) getBean("courseManager");

    String searchType = (String) reviewForm.get("searchType");
    String classLess = (String) reviewForm.get("classLess");
    String dept = (String) reviewForm.get("dept");
    String schoolType = (String) reviewForm.get("schoolType");
    String techid = (String) reviewForm.get("teacherId");

    if (searchType.equals("sim")) { // 快速搜
      session.setAttribute(
          "allCoansw",
          manager.getCoansw4Empl(techid, classLess, manager.getSchoolTerm().toString()));
    }

    if (searchType.equals("exp")) { // 進階搜

      if (!schoolType.equals("")) { // 以學制

        try {
          session.setAttribute(
              "allCoansw",
              manager.getCoansw4Empl(
                  manager.getDepartClassByType(schoolType), manager.getSchoolTerm().toString()));
        } catch (Exception e) {
          session.setAttribute("allCoansw", null);
        }
      }

      if (!dept.equals("")) { // 以科系

        try {
          session.setAttribute(
              "allCoansw",
              manager.getCoansw4Empl(
                  techid, "___" + dept + "%", manager.getSchoolTerm().toString()));
        } catch (Exception e) {
          session.setAttribute("allCoansw", null);
        }
      }

      if (!techid.equals("")) { // 以教師

        try {
          session.setAttribute(
              "allCoansw",
              manager.getCoansw4Empl(techid, classLess, manager.getSchoolTerm().toString()));
        } catch (Exception e) {
          session.setAttribute("allCoansw", null);
        }
      }
    }

    return mapping.findForward("Main");
  }
Exemplo n.º 20
0
  /**
   * 處理確定加選學生選課內容之方法
   *
   * @param mapping org.apache.struts.action.ActionMapping object
   * @param form org.apache.struts.action.ActionForm object
   * @param request javax.servlet.http.HttpServletRequest object
   * @param response javax.servlet.http.HttpServletResponse object
   * @return org.apache.struts.action.ActionForward object
   * @exception java.lang.Exception
   */
  public ActionForward add(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    CourseManager cm = (CourseManager) getBean(COURSE_MANAGER_BEAN_NAME);
    HttpSession session = request.getSession(false);
    DynaActionForm aForm = (DynaActionForm) form;
    Seld seld = processSeldByForm(aForm);
    session.setAttribute("seldInfoForOnline", seld);
    Dtime dtime = cm.findDtimeBy(seld.getDtimeOid());

    ActionMessages messages = validateInputForUpdate(aForm, Toolket.getBundle(request));
    if (!messages.isEmpty()) {
      saveErrors(request, messages);
      return mapping.findForward(IConstants.ACTION_MAIN_NAME);
    } else {
      try {
        // 會以紙本作業完成加選,無需考慮衝堂問題
        // 選課人數上線於前端JavaScript判斷
        // 跨選設定不允許須阻擋並顯示訊息
        // 會顯示衝堂訊息
        MemberManager mm = (MemberManager) getBean(MEMBER_MANAGER_BEAN_NAME);
        ScoreManager sm = (ScoreManager) getBean(IConstants.SCORE_MANAGER_BEAN_NAME);
        Student student = mm.findStudentByNo(seld.getStudentNo());
        ScoreHist scoreHist = new ScoreHist(student.getStudentNo());
        List<ScoreHist> scoreHistList = sm.findScoreHistBy(scoreHist);
        String[] cscodeHist = new String[0];
        Float[] scoreList = new Float[0];
        float passScore = Toolket.getPassScoreByDepartClass(student.getDepartClass());
        for (ScoreHist hist : scoreHistList) {
          cscodeHist = (String[]) ArrayUtils.add(cscodeHist, hist.getCscode().toUpperCase());
          // 抵免要給分數,不然就會被當做無修課記錄而被加選成功
          if ("6".equals(hist.getEvgrType()))
            scoreList =
                (Float[])
                    ArrayUtils.add(
                        scoreList, hist.getScore() != null ? hist.getScore() : passScore);
          else scoreList = (Float[]) ArrayUtils.add(scoreList, hist.getScore());
        }

        int ind = 0, startIndex = 0;
        boolean isHist = false;
        do {
          ind = ArrayUtils.indexOf(cscodeHist, seld.getCscode().toUpperCase(), startIndex);
          startIndex = ind + 1;
          // 判斷是否選過且及格
          isHist =
              ind != StringUtils.INDEX_NOT_FOUND
                  && scoreList[ind] != null
                  && scoreList[ind] >= passScore;
        } while (!isHist && ind != StringUtils.INDEX_NOT_FOUND);

        // 特殊班級(跨校生等)無條件加選
        String[] specialDepartClass = {"1152A", "1220", "122A", "122B", "2220"};
        String[] addGrade = {"42", "52"}; // 2技學生年級要+2
        int stuGrade =
            ArrayUtils.contains(specialDepartClass, student.getDepartClass())
                ? 9
                : Integer.parseInt(StringUtils.substring(student.getDepartClass(), 4, 5));
        stuGrade =
            ArrayUtils.contains(addGrade, StringUtils.substring(student.getDepartClass(), 1, 3))
                ? stuGrade + 2
                : stuGrade;
        int dtimeGrade = Integer.parseInt(StringUtils.substring(dtime.getDepartClass(), 4, 5));

        if (isHist) {
          messages.add(
              ActionMessages.GLOBAL_MESSAGE,
              new ActionMessage("Course.errorN1", "歷年資料查詢到已修過該科目,請確認,謝謝!!"));
          saveErrors(request, messages);
        } else if (stuGrade >= dtimeGrade) {
          // 判斷學生年級與課程所開班級年級
          cm.txAddSelectedSeld(seld, student, "1", true);
          String idno = getUserCredential(request.getSession(false)).getMember().getIdno();
          cm.txSaveAdcdHistory(seld.getDtimeOid(), student.getStudentNo().toUpperCase(), idno, "A");
          if (ind != StringUtils.INDEX_NOT_FOUND)
            messages.add(
                ActionMessages.GLOBAL_MESSAGE,
                new ActionMessage("Course.errorN1", "該科目於歷年資料有查詢到,但該科目未及格,所以加選成功。"));
          else
            messages.add(
                ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Message.CreateSuccessful"));
          saveMessages(request, messages);
        } else {
          messages.add(
              ActionMessages.GLOBAL_MESSAGE,
              new ActionMessage(
                  "Course.messageN1",
                  "注意:學生低修高年級課程,加選作業尚未完成!<br/>"
                      + "&nbsp;&nbsp;&nbsp;&nbsp;按下[再次確定]鍵後課程才會加入學生選課資料中。"));
          saveErrors(request, messages);
          setContentPage(request.getSession(false), "course/OnlineAddHigherCourse.jsp");
          return mapping.findForward(IConstants.ACTION_MAIN_NAME);
        }

        Toolket.resetCheckboxCookie(response, SELD_LIST_NAME);
        return list(mapping, form, request, response);
      } catch (SeldException se) {
        ActionMessages errors = new ActionMessages();
        errors.add(
            ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Course.errorN1", se.getMessage()));
        saveErrors(request, errors);
        if (se.getMessage().indexOf("衝堂") != StringUtils.INDEX_NOT_FOUND) {
          // 目前會拒絕衝堂課程進行加選
          dtime = cm.findDtimeBy(seld.getDtimeOid());
          Csno csno = cm.findCourseInfoByCscode(dtime.getCscode());
          request.setAttribute("csnoInfo", csno);
          request.setAttribute("classInfo", Toolket.getClassFullName(dtime.getDepartClass()));
          setContentPage(request.getSession(false), "course/ConflictList.jsp");
          return list(mapping, form, request, response);
        } else return list(mapping, form, request, response);
      }
    }
  }
Exemplo n.º 21
0
  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");
  }
Exemplo n.º 22
0
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    WebApplicationContext ctx =
        WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServletContext());

    CourseManager manager = (CourseManager) ctx.getBean("courseManager");
    HttpSession session = request.getSession(false);

    List selectFilterCouList = (List) session.getAttribute("selectFilterCouList");

    Date date = new Date();
    DateFormat dateFormat = new SimpleDateFormat("yyyy年 MM月 dd日 HH:mm");

    String stuTmp[] = new String[selectFilterCouList.size()];
    List students = new ArrayList();

    for (int i = 0; i < selectFilterCouList.size(); i++) {
      stuTmp[i] = ((Map) selectFilterCouList.get(i)).get("dtimeOid").toString();
    }
    students = manager.getSeldStuFilterBy(stuTmp, true);

    Document document = new Document(PageSize.A4, 72, 72, 35, 35);
    ByteArrayOutputStream ba = new ByteArrayOutputStream();

    String year = manager.getNowBy("School_year");
    String term = manager.getNowBy("School_term");

    // 如果是下學期, 學年要+1
    if (Integer.parseInt(term) == 2) {
      Integer tmpYear = (Integer.parseInt(year) + 1);
      year = tmpYear.toString();
      term = "1";
    } else {
      term = "2";
    }

    try {

      PdfWriter writer = PdfWriter.getInstance(document, ba);
      // TODO 路徑

      // Image
      // image=Image.getInstance("http://cap.chit.edu.tw/CIS/pages/images/2002chitWatermark.gif");
      // Watermark wamark=new Watermark(image, ((PageSize.A4).width()-image.plainHeight())/2,
      // ((PageSize.A4).height()-image.plainHeight())/2);
      // document.add(wamark);

      Phrase now = doEncode("課程管理系統 " + dateFormat.format(date));
      HeaderFooter header = new HeaderFooter(now, false);
      document.setHeader(header);
      document.setFooter(header);

      // Image logo=Image.getInstance("http://192.192.231.32:8080/CIS/pages/images/art.gif");
      document.open();

      for (int i = 0; i < students.size(); i++) {

        String buf[] = {((Map) students.get(i)).get("student_no").toString()};
        List tmp = manager.getSeldStuFilterBy(buf, false);

        if (i % 2 != 0) {
          document.add(new Paragraph(doEncode("\n")));
          document.add(new Paragraph(doEncode("\n")));
          document.add(new Paragraph(doEncode("\n")));
        }

        document.add(new Paragraph(""));

        Table table = new Table(6);
        table.setWidth(100);

        table.setBorderWidth(0);
        table.setPadding(5);
        // table.setSpacing(5);
        // table.setDefaultHorizontalAlignment(table.ALIGN_CENTER);
        // table.setDefaultHorizontalAlignment(table.ALIGN_MIDDLE);

        // table.setDefaultCellBorderColor(new Color(255, 255, 255));

        Cell cell = new Cell();
        cell.add(doEncode(year));
        cell.add(doEncode("學年 第"));
        cell.add(doEncode(term));
        cell.add(doEncode("學期 網路預選失敗通知單"));
        // cell.addElement(logo);
        cell.setColspan(6);
        cell.setHorizontalAlignment(cell.ALIGN_CENTER);
        cell.setBorderColor(new Color(255, 255, 255));
        table.addCell(cell);

        // ((Map)students.get(i)).get("ClassName2");

        cell = new Cell();
        // cell.add(doEncode("學生班級: "));
        cell.add(doEncode(((Map) students.get(i)).get("ClassName").toString()));
        cell.add(doEncode("\t學號: "));
        cell.add(doEncode(((Map) students.get(i)).get("student_no").toString()));
        cell.add(doEncode("\t姓名: "));
        cell.add(doEncode(((Map) students.get(i)).get("student_name").toString()));

        cell.setColspan(6);
        cell.setHorizontalAlignment(cell.ALIGN_LEFT);
        cell.setBorderColor(new Color(255, 255, 255));
        table.addCell(cell);

        cell = new Cell();
        cell.add(doEncode("您在第一階段網路選課所選的下列課程並未成功,請按照規定時間進行網路第二階段選課,以免影響您的權益。"));

        cell.setColspan(6);
        cell.setHorizontalAlignment(cell.ALIGN_LEFT);
        cell.setBorderColor(new Color(255, 255, 255));
        table.addCell(cell);

        document.add(table);

        float[] widths = {0.2f, 0.3f, 0.1f, 0.1f, 0.1f, 0.2f};
        PdfPTable tables = new PdfPTable(widths);
        tables.setWidthPercentage(100);

        PdfPCell cells = new PdfPCell(doEncode("開課班級"));
        tables.addCell(cells);

        cells = new PdfPCell(doEncode("科目名稱"));
        tables.addCell(cells);
        cells = new PdfPCell(doEncode("選別"));
        tables.addCell(cells);
        cells = new PdfPCell(doEncode("學分"));
        tables.addCell(cells);
        cells = new PdfPCell(doEncode("時數"));
        tables.addCell(cells);
        cells = new PdfPCell(doEncode("上課時間"));
        tables.addCell(cells);

        for (int j = 0; j < tmp.size(); j++) {
          cells = new PdfPCell();
          cells = new PdfPCell(doEncode(((Map) tmp.get(j)).get("ClassName2").toString()));
          tables.addCell(cells);
          cells = new PdfPCell(doEncode(((Map) tmp.get(j)).get("chi_name").toString()));
          tables.addCell(cells);
          cells = new PdfPCell(doEncode(getOpt(((Map) tmp.get(j)).get("opt").toString())));
          tables.addCell(cells);
          cells = new PdfPCell(doEncode(((Map) tmp.get(j)).get("credit").toString()));
          tables.addCell(cells);
          cells = new PdfPCell(doEncode(((Map) tmp.get(j)).get("thour").toString()));
          tables.addCell(cells);

          List dcTmp =
              manager.getDtimeClassListForOpenCourse(((Map) tmp.get(j)).get("dtimeOid").toString());

          StringBuffer strBuf = new StringBuffer();
          DtimeClass dtimeClass;
          for (int x = 0; x < dcTmp.size(); x++) {
            dtimeClass = (DtimeClass) dcTmp.get(x);
            strBuf.append("週" + dtimeClass.getWeek() + ":");
            strBuf.append(dtimeClass.getBegin() + "~" + dtimeClass.getEnd() + " ");
          }

          cells = new PdfPCell(doEncode(strBuf.toString()));
          tables.addCell(cells);
        }

        for (int k = 13; k > tmp.size(); k--) {
          cells = new PdfPCell(doEncode("\t"));
          tables.addCell(cells);
          cells = new PdfPCell(doEncode("\t"));
          tables.addCell(cells);
          cells = new PdfPCell(doEncode("\t"));
          tables.addCell(cells);
          cells = new PdfPCell(doEncode("\t"));
          tables.addCell(cells);
          cells = new PdfPCell(doEncode("\t"));
          tables.addCell(cells);
          cells = new PdfPCell(doEncode("\t"));
          tables.addCell(cells);
        }

        document.add(tables);

        if (i % 2 == 1) {
          document.newPage();
        }
      }

    } catch (DocumentException de) {
      de.printStackTrace();
      System.err.println("A Document error:" + de.getMessage());
    }

    document.close();
    response.setContentType("application/pdf");
    response.setContentLength(ba.size());
    ServletOutputStream out = response.getOutputStream();
    ba.writeTo(out);
    ba.close();
    out.flush();
    out.close();
  }