Exemplo n.º 1
0
 /**
  * 记录日志数据
  *
  * @param userAccount SfUserDTO
  * @param logData SfUserLogDTO
  * @throws DataHandleException
  */
 private void logData(SfUserDTO userAccount, SfUserLogDTO logData) throws DataHandleException {
   Connection conn = null;
   try {
     conn = DBManager.getDBConnection();
     SfUserLogDAO logDAO = new SfUserLogDAO(userAccount, logData, conn);
     logDAO.createData();
   } catch (PoolException ex) {
     ex.printLog();
     throw new DataHandleException(ex);
   } finally {
     DBManager.closeDBConnection(conn);
   }
 }
Exemplo n.º 2
0
 public static void main(String args[]) {
   SfUserDTO userAccount = new SfUserDTO();
   ServletConfigDTO configDTO = new ServletConfigDTO();
   SSOUserLoginDAO ssoUserLoginDAO = new SSOUserLoginDAO(configDTO);
   userAccount = ssoUserLoginDAO.validateUser("SINOADMIN");
   SrvDAO sr = new SrvDAO();
   try {
     Connection conn = DBManager.getDBConnection();
     sr.synFaLocation(conn, userAccount);
   } catch (PoolException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   //        String na = "AA";
   //        sr.truncateData(na, null);
 }
Exemplo n.º 3
0
 public void performTask(HttpServletRequest req, HttpServletResponse res)
     throws ServletException, IOException {
   String forwardURL = "";
   Message message = SessionUtil.getMessage(req);
   String act = req.getParameter("act");
   act = StrUtil.nullToString(act);
   Connection conn = null;
   try {
     SfUserDTO user = (SfUserDTO) SessionUtil.getUserAccount(req);
     AmsAssetsInfoDTO dtoParameter = null;
     Request2DTO req2DTO = new Request2DTO();
     req2DTO.setDTOClassName(AmsAssetsInfoDTO.class.getName());
     dtoParameter = (AmsAssetsInfoDTO) req2DTO.getDTO(req);
     conn = getDBConnection(req);
     AmsPractInfoDAO practDAO = new AmsPractInfoDAO(user, dtoParameter, conn);
     if (act.equals("")) {
       req.setAttribute(WebAttrConstant.ETS_PRACTINFO_DTO, dtoParameter);
       forwardURL = URLDefineList.PRACT_PAGE;
     } else if (act.equals(WebActionConstant.QUERY_ACTION)) {
       BaseSQLProducer sqlProducer = new AmsPractInfoModel(user, dtoParameter);
       PageQueryDAO pageDAO = new PageQueryDAO(req, conn, sqlProducer);
       pageDAO.produceWebData();
       req.setAttribute(WebAttrConstant.ETS_PRACTINFO_DTO, dtoParameter);
       forwardURL = URLDefineList.PRACT_PAGE;
     }
   } catch (PoolException e) {
     e.printLog();
     message = getMessage(MsgKeyConstant.POOL_PASSIVATE_ERROR);
     message.setIsError(true);
     forwardURL = MessageConstant.MSG_PRC_SERVLET;
   } catch (DTOException e) {
     e.printLog();
     message = getMessage(MsgKeyConstant.DTO_ERROR);
     message.setIsError(true);
     forwardURL = MessageConstant.MSG_PRC_SERVLET;
   } catch (QueryException e) {
     e.printLog();
     message = getMessage(MsgKeyConstant.QUERY_ERROR);
     message.setIsError(true);
     forwardURL = MessageConstant.MSG_PRC_SERVLET;
   } finally {
     DBManager.closeDBConnection(conn);
     setHandleMessage(req, message);
     ServletForwarder forwarder = new ServletForwarder(req, res);
     forwarder.forwardView(forwardURL);
   }
 }
Exemplo n.º 4
0
 public void performTask(HttpServletRequest req, HttpServletResponse res)
     throws ServletException, IOException {
   String forwardURL = "";
   Message message = null;
   Connection conn = null;
   res.setContentType(sContentType);
   try {
     conn = DBManager.getDBConnection();
     SfUserDTO userAccount = (SfUserDTO) SessionUtil.getUserAccount(req);
     Logger.logInfo("Excel submit servlet begin....");
     RequestParser reqPar = new RequestParser();
     reqPar.transData(req);
     UploadFile[] upFiles = null;
     UploadRow uploadRow;
     String conFilePath = PDAUtil.getCurUploadFilePath(conn);
     UploadFileSaver uploadFileSaver = reqPar.getFileSaver();
     uploadFileSaver.saveFiles(conFilePath);
     uploadRow = uploadFileSaver.getRow();
     upFiles = uploadRow.getFiles();
     if (upFiles == null) {
       return;
     } else if (upFiles.length != 1 || upFiles[0].getFileName().equals("")) {
       return;
     }
     UploadFile uploadFile = upFiles[0];
     String fileName = uploadFile.getAbsolutePath();
     fileName = fileName.replaceAll("\\\\", "/");
     forwardURL = "/public/windowClose.jsp?retValue=" + fileName;
   } catch (PoolException e) {
     e.printStackTrace();
   } catch (UploadException e) {
     e.printStackTrace();
   } catch (FileSizeException e) {
     e.printStackTrace();
   } catch (ContainerException e) {
     e.printStackTrace();
   } finally {
     DBManager.closeDBConnection(conn);
     setHandleMessage(req, message);
     ServletForwarder forwarder = new ServletForwarder(req, res);
     forwarder.forwardView(forwardURL);
   }
 }
Exemplo n.º 5
0
  public void run() {
    Connection conn = null;
    DTOSet messages = null;
    SfMsgDefineDTO message = null;
    int msgCount = 0;
    DTOSet sendInfos = null;
    SfMsgSendInfoDTO sendDTO = null;
    String cellPhone = "";

    boolean needSend = false;
    System.out.println("启动消息服务...");
    while (true) {
      try {
        sleep(300000);

        AmsEmailSend send = new AmsEmailSend();
        send.sendEmail();

        conn = DBManager.getDBConnection();
        msgProcessService.finishMessages(conn); // 更新已经处理过的消息的状态。

        messages = msgProcessService.getNeedSendMessages(conn);
        if (messages == null || messages.isEmpty()) {
          continue;
        }
        msgCount = messages.getSize();
        for (int i = 0; i < msgCount; i++) {
          message = (SfMsgDefineDTO) messages.getDTO(i);
          sendInfos = msgProcessService.getMsgSendInfos(conn, message);
          if (sendInfos == null || sendInfos.isEmpty()) {
            continue;
          }
          sendService.setMessage(message.getMsgContent());
          for (int j = 0; j < sendInfos.getSize(); j++) {
            sendDTO = (SfMsgSendInfoDTO) sendInfos.getDTO(j);
            cellPhone = sendDTO.getMsgCellPhone();

            needSend = msgProcessService.needSend(conn, sendDTO);

            if (needSend) { // 需要发送
              sendService.addPhoneNum(cellPhone);
              if (sendService.getPhoneCount() >= sendService.getMaxPhoneNum()) {
                sendService.sendMessage();
                sendService.clearPhoneList();
              }
            }
            if (needSend) {
              msgProcessService.processSendLog(conn, sendDTO, cellPhone);
            }
          }
          if (sendService.getPhoneCount() > 0) {
            sendService.sendMessage();
            sendService.clearPhoneList();
          }
        }
      } catch (PoolException ex) {
        ex.printLog();
      } catch (InterruptedException ex) {
        Logger.logError(ex);
      } catch (QueryException ex) {
        ex.printLog();
      } catch (DataHandleException ex) {
        ex.printLog();
      } catch (OutOfBoundsException ex) {
        Logger.logError(ex);
      } catch (NoSuchProviderException e) {
        Logger.logError(e);
      } finally {
        DBManager.closeDBConnection(conn);
      }
    }
  }