📄 sendremindersthread.java
字号:
/* CRMS, customer relationship management system Copyright (C) 2003 Service To Youth Council This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA For further information contact the SYC ICT department on GPL@syc.net.au 98 Kermode Street North Adelaide South Australia SA 5006 +61 (0)8 8367 0755 *//* * SendRemindersThread.java * * Created on 20 June 2003, 10:18 */package crms.daemon;import java.util.*;import crms.vo.*;import crms.dao.*;//import java.sql.*;import org.apache.log4j.Logger;/** * * @author Administrator */public class SendRemindersThread { Logger logger = Logger.getLogger(SendRemindersThread.class); private ArrayList reminderList = null; private ReminderDAO dao = DAOFactory.getInstance().getReminderDAO(); /** Creates a new instance of SendRemindersThread */ public SendRemindersThread(List reminders) { reminderList = (ArrayList) reminders; } public void run() { logger.debug("Processing " + reminderList.size() + " reminders.."); for (int i=0; i < reminderList.size(); i++) { Reminder reminder = (Reminder) reminderList.get(i); boolean result = sendReminder(reminder); if (result) { updateDBReminderStatus(reminder); } } } public void updateDBReminderStatus(Reminder reminder) { try { MessageLogEntry entry = MessageLogEntry.createFromReminder(reminder); if (reminder.getFrequency() != Reminder.REMINDER_FREQUENCY_SINGLE) { reminder.updateNext(); } else { reminder.setFrequency(Reminder.REMINDER_FREQUENCY_SINGLE_COMPLETE); } dao.updateReminder(reminder, AbstractDAO.SUPER_USER); dao.addReminderLogEntry(entry, null); } catch (Exception ex) { logger.fatal(ex); throw new RuntimeException("Exception updating Reminder status!", ex); } } public boolean sendReminder(Reminder reminder) { boolean result = true; if (reminder.isSMSReminder()) { result = sendSMSReminder(reminder); } if (reminder.isEmailReminder()) { result = result && sendEmailReminder(reminder); } return result; } public boolean sendSMSReminder(Reminder r) { logger.debug("Attempt to send SMS reminder to " + r.getSMSReminderTo()); try { SendSMSThread thread = new SendSMSThread(r); thread.run(); } catch (Exception ex) { logger.fatal(ex); return false; } return true; } public boolean sendEmailReminder(Reminder r) { logger.debug("Attempt to send email reminder to " + r.getEmailReminderTo()); try { SendEmailThread thread = new SendEmailThread(r); thread.run(); }catch (Exception ex) { logger.fatal(ex); return false; } return true; } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -