Search in sources :

Example 1 with TbSysMailHelper

use of com.netsteadfast.greenstep.po.hbm.TbSysMailHelper in project bamboobsc by billchen198318.

the class SysMailHelperServiceImpl method findForJobList.

@Override
public DefaultResult<List<TbSysMailHelper>> findForJobList(String mailId, String successFlag) throws ServiceException, Exception {
    if (StringUtils.isBlank(mailId) || StringUtils.isBlank(successFlag)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    DefaultResult<List<TbSysMailHelper>> result = new DefaultResult<List<TbSysMailHelper>>();
    List<TbSysMailHelper> searchList = this.sysMailHelperDAO.findForJobList(mailId, successFlag);
    if (searchList != null && searchList.size() > 0) {
        result.setValue(searchList);
    } else {
        result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.SEARCH_NO_DATA)));
    }
    return result;
}
Also used : TbSysMailHelper(com.netsteadfast.greenstep.po.hbm.TbSysMailHelper) SystemMessage(com.netsteadfast.greenstep.base.model.SystemMessage) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) List(java.util.List) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult)

Example 2 with TbSysMailHelper

use of com.netsteadfast.greenstep.po.hbm.TbSysMailHelper in project bamboobsc by billchen198318.

the class ExpressionJobExecuteCallable method sendMail.

private void sendMail() {
    try {
        if (ExpressionJobConstants.CONTACT_MODE_NO.equals(this.jobObj.getSysExprJob().getContactMode())) {
            return;
        }
        if (ExpressionJobConstants.CONTACT_MODE_ONLY_FAULT.equals(this.jobObj.getSysExprJob().getContactMode()) && !ExpressionJobConstants.RUNSTATUS_FAULT.equals(this.jobObj.getSysExprJob().getRunStatus())) {
            return;
        }
        if (ExpressionJobConstants.CONTACT_MODE_ONLY_SUCCESS.equals(this.jobObj.getSysExprJob().getContactMode()) && !ExpressionJobConstants.RUNSTATUS_SUCCESS.equals(this.jobObj.getSysExprJob().getRunStatus())) {
            return;
        }
        String contact = StringUtils.defaultString(this.jobObj.getSysExprJob().getContact()).trim();
        if (StringUtils.isBlank(contact)) {
            return;
        }
        String subject = this.jobObj.getSysExprJob().getId() + " - " + this.jobObj.getSysExprJob().getName();
        String content = subject + Constants.HTML_BR;
        content += "Run status: " + this.jobObj.getSysExprJob().getRunStatus() + Constants.HTML_BR;
        content += "Start: " + this.jobObj.getSysExprJobLog().getBeginDatetime().toString() + Constants.HTML_BR;
        content += "End: " + this.jobObj.getSysExprJobLog().getEndDatetime().toString() + Constants.HTML_BR;
        if (ExpressionJobConstants.RUNSTATUS_FAULT.equals(this.jobObj.getSysExprJob().getRunStatus())) {
            content += Constants.HTML_BR;
            content += "Fault: " + Constants.HTML_BR;
            content += this.jobObj.getSysExprJobLog().getFaultMsg();
        }
        @SuppressWarnings("unchecked") ISysMailHelperService<SysMailHelperVO, TbSysMailHelper, String> sysMailHelperService = (ISysMailHelperService<SysMailHelperVO, TbSysMailHelper, String>) AppContext.getBean("core.service.SysMailHelperService");
        String mailId = SimpleUtils.getStrYMD("");
        SysMailHelperVO mailHelper = new SysMailHelperVO();
        mailHelper.setMailId(sysMailHelperService.findForMaxMailIdComplete(mailId));
        mailHelper.setMailFrom(MailClientUtils.getDefaultFrom());
        mailHelper.setMailTo(contact);
        mailHelper.setSubject(subject);
        mailHelper.setText(content.getBytes("utf8"));
        mailHelper.setRetainFlag(YesNo.NO);
        mailHelper.setSuccessFlag(YesNo.NO);
        sysMailHelperService.saveObject(mailHelper);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : TbSysMailHelper(com.netsteadfast.greenstep.po.hbm.TbSysMailHelper) SysMailHelperVO(com.netsteadfast.greenstep.vo.SysMailHelperVO) ISysMailHelperService(com.netsteadfast.greenstep.service.ISysMailHelperService) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException)

Aggregations

ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)2 TbSysMailHelper (com.netsteadfast.greenstep.po.hbm.TbSysMailHelper)2 DefaultResult (com.netsteadfast.greenstep.base.model.DefaultResult)1 SystemMessage (com.netsteadfast.greenstep.base.model.SystemMessage)1 ISysMailHelperService (com.netsteadfast.greenstep.service.ISysMailHelperService)1 SysMailHelperVO (com.netsteadfast.greenstep.vo.SysMailHelperVO)1 List (java.util.List)1