public void createAllSchedular() { // For Free Trial Schedular Email, 4x Trial Signup (start, 3 days remaining, expired, 3 days // after) // create 3 days before the free trial finishes addSchedulerTimeBasedOnExpiredTime( -3 * WebConstants.MINI_SECONDS_EACH_DAY, EmailNotificationFactory.getNotificationTemplate( WebConstants.THREE_DAYS_BEFORE_EXPIRED_TEMPLATE)); // create free trial finish addSchedulerTimeBasedOnExpiredTime( 0, EmailNotificationFactory.getNotificationTemplate(WebConstants.FREE_TRIAL_EXPIRED_TEMPLATE)); // create 3 day after the free trial finishes addSchedulerTimeBasedOnExpiredTime( 3 * WebConstants.MINI_SECONDS_EACH_DAY, EmailNotificationFactory.getNotificationTemplate( WebConstants.THREE_DAYS_AFTER_EXPIRED_TEMPLATE)); // create 7 days after the free trial finishes if they have not become a member still // addSchedulerTimeBasedOnExpiredTime(7*WebConstants.MINI_SECONDS_EACH_DAY, // EmailNotificationFactory.getNotificationTemplate(WebConstants.SEVEN_DAYS_AFTER_EXPRED_TEMPLATE)); }
/** load all scheduler notifications while init this Handler */ public void loadAllNotificationSchedulers() { List<SchedulerNotificationsBean> pendingNotifications = DBAccessor.getInstance().getAllSchedulerNotification(); LogTools.getInstance() .insertLog( DebugLevel.INFO, "Load all notification schedulers, size:" + pendingNotifications.size()); for (int i = 0; i < pendingNotifications.size(); i++) { SchedulerNotificationsBean notification = pendingNotifications.get(i); NotificationTemplate emailTemplate = EmailNotificationFactory.getNotificationTemplate(notification.getTemplate_type()); // get user info UserBean userBean = DBAccessor.getInstance().getUserInfoByID(notification.getUser_id()); if (null == userBean) { // this user is not exist DBAccessor.getInstance().removeAllExpiredSchedulersForUser(notification.getUser_id()); } else { EmailBean notificatonEmail = createEmailByTemplate(userBean, emailTemplate); NotificationScheduler scheduler = null; if (notification.getTemplate_type() == WebConstants.FREE_TRIAL_EXPIRED_TEMPLATE) { scheduler = new EmailNotificationSechedularOfFreeTrialEnd( notification.getTime(), notificatonEmail, EmailHandler.getInstance()); } else { scheduler = new EmailNotificationScheduler( notification.getTime(), notificatonEmail, EmailHandler.getInstance()); } addNotificationSchedulear(notification.getUser_id(), scheduler); } } }
private EmailBean createEmailByTemplate(UserBean userBean, NotificationTemplate template) { return EmailNotificationFactory.getNotificationEmail(userBean, template.getTemplateType()); }