/** 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);
      }
    }
  }
Ejemplo n.º 2
0
  protected ActionForward executeAction(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws IOException, ServletException {
    SearchMemberForm searchMemberForm = (SearchMemberForm) form;

    String memberName = searchMemberForm.getSearch_name();
    String memberEmail = searchMemberForm.getSearch_email();

    // for log info
    UserBean currentAdmin = (UserBean) request.getSession().getAttribute(AdminConstants.USER_KEY);
    LogTools.getInstance()
        .insertLog(
            DebugLevel.INFO,
            "Request SearchMemberAction from Account:"
                + currentAdmin.getLogin_name()
                + ", search member name:"
                + memberName
                + ", search email:"
                + memberEmail);

    String forwardName = AdminConstants.FORWARD_SUCCESS;

    List<UserBean> searchResult =
        new MemberController().searchMember(memberName, memberEmail, CommonDefine.ALL_MEMBER_TYPE);

    Comparator<UserBean> comp = new UserBeanAToZComparator();
    Collections.sort(searchResult, comp);

    request.setAttribute(AdminConstants.MEMBER_LIST, searchResult);

    Map<Long, List<StrategyBean>> marketStrategy = new MemberController().getMarketStrategyMap();
    request.setAttribute(AdminConstants.MARKET_STRATEGY_MAP, marketStrategy);

    return mapping.findForward(forwardName);
  }