コード例 #1
0
ファイル: Task.java プロジェクト: mzd/JavaIfttt
  public void getMemberTask(long code) throws ClassNotFoundException, SQLException {
    System.out.println("**in get member task func");
    String[] temp = TaskManager.getInstance().getTasksByUser(code);

    int tasknum = UserManager.getInstance().getLoginUserByHashcode(code).getUserTask().size();

    for (int i = 0; i < tasknum; i++) {
      TaskId[i] = temp[0 + 5 * i];
      ThisId[i] = temp[1 + 5 * i];
      ThatId[i] = temp[2 + 5 * i];
      time[i] = temp[3 + 5 * i];
      IfRun[i] = temp[4 + 5 * i];
    }
  }
コード例 #2
0
ファイル: Task.java プロジェクト: mzd/JavaIfttt
  public void createTask(
      long authCode,
      String taskname,
      String taskDscrip,
      String thisDscrip,
      String thisType,
      String thatDscrip,
      String thatType,
      boolean repeat)
      throws SQLException, ClassNotFoundException {
    /** thisType: time-after, thisDscrip: thatDscrip: */
    System.out.println(
        authCode + taskname + taskDscrip + thisDscrip + thisType + thatDscrip + thatType + repeat);
    This event = null;
    That action = null;
    String thisTypeString = "";
    String thatTypeString = "";
    String thisParams = "";
    String thatParams = "";
    CommonUser currentUser = UserManager.getInstance().getLoginUserByHashcode(authCode);
    String[] thisPara = thisDscrip.split("#&#");
    String[] thatPara = thatDscrip.split("#&#");

    if (thisType.equals("time-after")) {
      String time[] = thisPara[0].split("-");
      event = new TimeEvent(time[0], time[1], time[2], time[3], time[4]);
      System.out.println(time[0] + "," + time[1] + "," + time[2] + "," + time[3] + "," + time[4]);
      thisTypeString = "EVENT-time-after";
      thisParams = thisParams + thisPara[0];
    } else if (thisType.equals("weibo-update")) {

      event = new GetWeiboEvent(thisPara[0], null, thisPara[1]);
      thisTypeString = "EVENT-weibo-get";
      thisParams = thisParams + thisPara[0];
    } else if (thisType.equals("email-receive")) {
      try {
        event = new MailEvent(currentUser);
        thisTypeString = "EVENT-mail-receive";

      } catch (MessagingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }

    if (thatType.equals("weibo-update")) {
      CommonContent content = new CommonContent();
      ChannelUser weiboUser = new ChannelUser();
      weiboUser.setUsername(thatPara[0]);
      weiboUser.setPassword(thatPara[1]);
      UserManager.getInstance().addChannel(authCode, "weibo", weiboUser);
      System.out.println(thatPara[0] + "," + thatPara[1]);
      content.setTextString(thatPara[2]);
      action = new UpdateWeiboAction(currentUser, content);
      thatTypeString = "ACTION-weibo-update";
      thatParams = thatParams + thatPara[2];
      System.out.println("***IN TASK.java, thatParams :" + thatParams);
    } else if (thatType.equals("gmail-send")) {
      CommonContent content = new CommonContent();
      ChannelUser mailUser = new ChannelUser();
      mailUser.setUsername(thatPara[0]);
      mailUser.setPassword(thatPara[1]);
      UserManager.getInstance().addChannel(authCode, "mail", mailUser);

      content.setTextString(thatPara[2]);
      action = new SendMailAction(currentUser, content, thatPara[3]);
      thatTypeString = "ACTION-mail-send";
      thatParams = thatParams + thatPara[2] + "|" + thatPara[3];
    }
    System.out.println("A NEW TASK: thisType: " + thisTypeString + "thatType: " + thatTypeString);
    long taskId =
        TaskManager.getInstance()
            .insertTask(
                authCode,
                taskname,
                event,
                thisTypeString,
                thisParams,
                action,
                thatTypeString,
                thatParams,
                repeat);
    // TaskManager.getInstance().startTask(taskId);
  }
コード例 #3
0
ファイル: Task.java プロジェクト: mzd/JavaIfttt
  public int getTaskCountByAuthcode(long authcode) {

    taskCount = 3; /*need to add the impl to get the count of the task*/
    int tasknum = UserManager.getInstance().getLoginUserByHashcode(authcode).getUserTask().size();
    return tasknum;
  }