use of com.axelor.apps.message.db.Message in project axelor-open-suite by axelor.
the class ActionEmailBuilderService method sendEmail.
@CallMethod
public ActionResponse sendEmail(Long objectId, String model, String tag, Long templateId, int sendOption) throws ClassNotFoundException, InstantiationException, IllegalAccessException, AxelorException, IOException, MessagingException {
Template template = templateRepo.find(templateId);
Message message = templateMessageService.generateMessage(objectId, model, tag, template);
ActionResponse response = new ActionResponse();
if (sendOption == 0) {
messageService.sendByEmail(message);
} else {
response.setView(ActionView.define(I18n.get(IExceptionMessage.MESSAGE_3)).model(Message.class.getName()).add("form", "message-form").param("forceEdit", "true").context("_showRecord", message.getId().toString()).map());
}
return response;
}
use of com.axelor.apps.message.db.Message in project axelor-open-suite by axelor.
the class BatchTimesheetReminder method sendReminderUsingEmployees.
protected void sendReminderUsingEmployees(Template template) throws AxelorException, MessagingException, IOException, ClassNotFoundException, InstantiationException, IllegalAccessException {
for (Employee employee : getEmployeesWithoutRecentTimesheet(Optional.ofNullable(AuthUtils.getUser()).map(User::getActiveCompany).orElse(null)).stream().filter(Objects::nonNull).collect(Collectors.toList())) {
Message message = templateMessageService.generateMessage(employee, template);
messageService.sendByEmail(message);
incrementDone();
}
}
use of com.axelor.apps.message.db.Message in project axelor-open-suite by axelor.
the class BatchTimesheetReminder method sendReminderUsingTimesheets.
protected void sendReminderUsingTimesheets(Template template) throws AxelorException, MessagingException, IOException, ClassNotFoundException, InstantiationException, IllegalAccessException {
for (Employee employee : getEmployeesWithoutRecentTimesheet(Optional.ofNullable(AuthUtils.getUser()).map(User::getActiveCompany).orElse(null)).stream().filter(Objects::nonNull).collect(Collectors.toList())) {
if (employee == null || EmployeeHRRepository.isEmployeeFormerNewOrArchived(employee)) {
continue;
}
Timesheet timeSheet = getRecentEmployeeTimesheet(employee);
if (timeSheet != null) {
Message message = templateMessageService.generateMessage(timeSheet, template);
messageService.sendByEmail(message);
} else {
throw new AxelorException(Timesheet.class, TraceBackRepository.CATEGORY_NO_VALUE, I18n.get(IExceptionMessage.NO_TIMESHEET_FOUND_FOR_EMPLOYEE), employee.getName());
}
incrementDone();
}
}
use of com.axelor.apps.message.db.Message in project axelor-open-suite by axelor.
the class MessageController method printMessage.
/**
* Method that generate message as a pdf
*
* @param request
* @param response
* @return
* @throws BirtException
* @throws IOException
*/
public void printMessage(ActionRequest request, ActionResponse response) throws AxelorException {
Message message = request.getContext().asType(Message.class);
message = Beans.get(MessageRepository.class).find(message.getId());
String pdfPath = Beans.get(MessageService.class).printMessage(message);
if (pdfPath != null) {
response.setView(ActionView.define("Message " + message.getSubject()).add("html", pdfPath).map());
} else
response.setFlash(I18n.get(IExceptionMessage.MESSAGE_1));
}
use of com.axelor.apps.message.db.Message in project axelor-open-suite by axelor.
the class MailAccountServiceTalentImpl method createMessage.
@Transactional(rollbackOn = { Exception.class })
@Override
public Message createMessage(EmailAccount mailAccount, MailParser parser, Date date) throws MessagingException {
Message message = super.createMessage(mailAccount, parser, date);
AppRecruitment appRecruitment = appRecruitmentRepo.all().fetchOne();
if (appRecruitment != null && appRecruitment.getApp().getActive() && message.getMailAccount() != null && message.getMailAccount().getServerTypeSelect() > 1) {
String lastEmailId = appRecruitment.getLastEmailId();
if (lastEmailId == null || message.getId() > Long.parseLong(lastEmailId)) {
jobPositionService.createJobApplication(message);
}
}
return message;
}
Aggregations