📄 sendsmsthread.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 *//* * SendSMSThread.java * * Created on 20 June 2003, 11:48 */package crms.daemon;import crms.vo.Call;import crms.vo.Reminder;import crms.vo.StaffMember;import java.io.*;import crms.dao.*;import org.apache.log4j.Logger;/** * * @author Administrator */public class SendSMSThread { public Logger logger = Logger.getLogger(SendSMSThread.class); LDAPDAO ldapDAO = LDAPDAOFactory.getInstance().getLDAPDAO(); private Reminder reminder = null; private Call call = null; /** Creates a new instance of SendSMSThread */ public SendSMSThread(Reminder reminder) { this.reminder = reminder; } public SendSMSThread(Call call) { this.call = call; } public void run() { try { File f = new File("gnokii.message"); PrintWriter out = new PrintWriter(new FileOutputStream(f)); StaffMember sm = null; if (reminder != null) { sm = ldapDAO.getUser(reminder.getOwner()); out.print("Reminder from "); out.print(reminder.getCreator()); out.print(": "); out.print(reminder.getReminderMessage()); } else if (call != null) { sm = ldapDAO.getUser(call.getOwner()); out.print("Message from "); String person = (call.getFromFirstName() + " " + call.getFromLastName()).trim(); person = (person + " " + call.getNumber()).trim(); out.print(person); out.print(": "); out.print(call.getNote()); if (call.checkFlag(Call.CALL_FLAG_URGENT)) { out.print(" [URG]"); } if (call.checkFlag(Call.CALL_FLAG_PLEASECALL)) { out.print(" [PC]"); } else if (call.checkFlag(Call.CALL_FLAG_CALLBACK)) { out.print(" [WCB]"); } } out.flush(); out.close(); Process p = Runtime.getRuntime().exec("/bin/sh sendsms.sh " + sm.getMobile()); BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream())); BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream())); // read the output from the command String s = ""; logger.debug("Here is the standard output of the command:\n"); while ((s = stdInput.readLine()) != null) { logger.debug(s); } // read any errors from the attempted command logger.debug("Here is the standard error of the command (if any):\n"); while ((s = stdError.readLine()) != null) { logger.debug(s); } f.delete(); } catch (IOException e) { logger.debug("exception happened - here's what I know: "); logger.fatal(e); } } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -