⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 crmsdaemon.java

📁 发泄网! 发泄网! 发泄网! 发泄网! 发泄网! 发泄网! 发泄网! 发泄网!
💻 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    *//* * CRMSDaemon.java * * Java class responsible for scheduling email and SMS reminders by * constantly checking the CRMS database for appropriate actions. * */package crms.daemon;import crms.dao.*;import java.util.*;import java.io.*;import java.text.*;import org.apache.log4j.*;/** * * @author  Administrator */public class CRMSDaemon {        public Logger logger = Logger.getLogger(CRMSDaemon.class);        /** Creates a new instance of CRMSDaemon */        private String dbServer = null;    private String dbUser = null;    private String dbPassword = null;        private static String LOG4J_CONF_PATH = "log4j-daemon.config";    private static SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");        public CRMSDaemon(String server, String user, String password, String ldap_url) {        logger.debug("System time is: " + df.format(new Date()));        logger.debug("System time from Calendar: " + df.format(Calendar.getInstance().getTime()));                File f = new File(LOG4J_CONF_PATH);        PropertyConfigurator.configureAndWatch(f.toString());                  this.dbServer = server;        this.dbUser = user;        this.dbPassword = password;                       DAOFactory.getInstance().registerDatabase(server, "crms", user, password, "1", "1");		// second two paramaters arent used		LDAPDAOFactory.getInstance(ldap_url, null, null); 		// "ldap://ldap.test:389/o=TEST,c=AU");                while (true) {            sendReminders();            sendCalls();            try {                Thread.sleep(60000);            }            catch (InterruptedException ex) {                ex.printStackTrace();               }        }    }        /**     * @param args the command line arguments     */    public static void main(String[] args) {        if (args.length == 0) {         System.out.println("Usage: java crms.daemon.CRMSDaemon <postgres-server> <user> <password> <ldap url>");           }        CRMSDaemon daemon = new CRMSDaemon(args[0], args[1], args[2], args[3]);    }        public void sendReminders() {        ReminderDAO dao = DAOFactory.getInstance().getReminderDAO();        Calendar cal = Calendar.getInstance();        cal.set(Calendar.SECOND, 0);        cal.set(Calendar.MILLISECOND, 0);                logger.debug("Looking for reminders to send at: " + cal.getTime());        ArrayList active = (ArrayList) dao.getRemindersForMinute(cal.getTime());                if (active.size() > 0) {            logger.debug("Reminders due to be sent: " + active.size());            SendRemindersThread thread = new SendRemindersThread(active);            thread.run();        } else {            logger.debug("No reminders to send now.");           }    }    public void sendCalls() {        CallDAO dao = DAOFactory.getInstance().getCallDAO();        /*Calendar cal = Calendar.getInstance();        cal.set(Calendar.SECOND, 0);        cal.set(Calendar.MILLISECOND, 0);*/                logger.debug("Looking for new calls to send");        ArrayList active = (ArrayList) dao.getCallNotifications();                if (active.size() > 0) {            logger.debug("Calls due to be sent: " + active.size());            SendCallsThread thread = new SendCallsThread(active);            thread.run();        } else {            logger.debug("No calls to send now.");           }    }    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -