Beispiel #1
0
 /**
  * 创建短消息
  *
  * @param pms 短消息内容
  * @param savetosentbox 设置短消息是否在发件箱保留(0为不保留, 1为保留)
  */
 public void createPrivateMessage(Pms pms, int savetosentbox) {
   if (pms.getFolder() != 0) {
     pms.setMsgfrom(pms.getMsgto());
   } else {
     pmsDAO
         .createQuery(
             "update Users set newpmcount=abs(newpmcount*1)+1,newpm=1 where uid=?",
             pms.getUsersByMsgtoid().getUid())
         .executeUpdate();
   }
   pmsDAO.save(pms);
   if (logger.isDebugEnabled()) {
     logger.debug("创建短消息 {} 成功", pms.getPmid());
   }
   if (savetosentbox == 1 && pms.getFolder() == 0) {
     // 保留在发件箱
     Pms pm = new Pms();
     pm.setFolder(1);
     pm.setMessage(pms.getMessage());
     pm.setMsgfrom(pms.getMsgfrom());
     pm.setMsgto(pms.getMsgto());
     pm.setNew_(pms.getNew_());
     pm.setPostdatetime(pms.getPostdatetime());
     pm.setSubject(pms.getSubject());
     pm.setUsersByMsgfromid(pms.getUsersByMsgfromid());
     pm.setUsersByMsgtoid(pms.getUsersByMsgtoid());
     pmsDAO.save(pm);
     if (logger.isDebugEnabled()) {
       logger.debug("保留短消息 {} 到发件箱成功", pm.getPmid());
     }
   }
 }
Beispiel #2
0
 /**
  * 增加错误次数并返回错误次数, 如不存在登录错误日志则建立
  *
  * @param ip ip地址
  * @param update
  * @return 错误次数
  */
 public int updateLoginLog(String ip, boolean update) {
   Failedlogins loginLog = loginlogDAO.findUniqueByProperty("ip", ip);
   if (loginLog != null) {
     int errcount = loginLog.getErrcount();
     try {
       if (Utils.howLong("m", loginLog.getLastupdate(), Utils.getNowTime()) < 15) {
         if (errcount >= 5 || !update) {
           loginlogDAO.save(loginLog);
           return errcount;
         } else {
           loginLog.setErrcount(errcount + 1);
           loginLog.setLastupdate(Utils.getNowTime());
           loginlogDAO.save(loginLog);
           if (logger.isDebugEnabled()) {
             logger.debug("IP{}登录错误{}次", ip, errcount + 1);
           }
           return errcount + 1;
         }
       } // end if
     } catch (ParseException e) {
       throw new ServiceException("更新失败登录日志失败");
     }
     loginLog.setErrcount(1);
     loginLog.setLastupdate(Utils.getNowTime());
     loginlogDAO.save(loginLog);
     return 1;
   } else {
     if (update) {
       loginLog = new Failedlogins();
       loginLog.setIp(ip);
       loginLog.setErrcount(1);
       loginLog.setLastupdate(Utils.getNowTime());
       loginlogDAO.save(loginLog);
     }
     return 1;
   }
 }
Beispiel #3
0
 /**
  * 设置短信息状态
  *
  * @param pmid 短信息ID
  * @param state 状态值
  */
 public void setPrivateMessageState(int pmid, int state) {
   Pms pms = getPrivateMessageInfo(pmid);
   pms.setNew_(state);
   pmsDAO.save(pms);
 }