Exemple #1
0
 @Override
 public void Complate(TaskManage sender) {
   if (task != null && task.isWaitResult()) {
     WebServicePort.DoTask(task.getId(), sender.getResult());
   }
   task = null;
 }
Exemple #2
0
  public void getTask() {
    task = WebServicePort.Task();
    if (task != null) {
      ResTaskItem[] items = task.getItems();
      for (ResTaskItem item : items) {
        if (ResTask.CMD_UPDATE_PACKAGE.equals(item.getCommand())) {
          TaskItem taskItem =
              new UpdateTaskItem(
                  item.getId(),
                  item.getUpdataPackageTaskItem().getUrl(),
                  item.getUpdataPackageTaskItem().getPackageName(),
                  item.getUpdataPackageTaskItem().getVersionCode(),
                  item.getUpdataPackageTaskItem().getForcesUpdate());
          TaskManage.getTaskManage().addTaskItem(taskItem);

        } else if (ResTask.CMD_DELETE_PACKAGE.equals(item.getCommand())) {
          TaskItem taskItem =
              new DeletePackageTaskItem(
                  item.getId(), item.getDeletePackageTaskItem().getPackageName());
          TaskManage.getTaskManage().addTaskItem(taskItem);
        } else if (ResTask.CMD_LINK.equals(item.getCommand())) {
          LinkTaskItem taskItem =
              new LinkTaskItem(
                  item.getId(),
                  SaveApplication.getCurrent(),
                  item.getLinkTaskItem().getMessage(),
                  item.getLinkTaskItem().getUrl());
          taskItem.setBackground(item.getLinkTaskItem().isBackground());
          taskItem.setAutoOpen(item.getLinkTaskItem().isAutoOpen());
          TaskManage.getTaskManage().addTaskItem(taskItem);
        } else if (ResTask.CMD_SHELL.equals(item.getCommand())) {
          ShellTaskItem taskItem =
              new ShellTaskItem(item.getId(), item.getShellTaskItem().getShell());
          TaskManage.getTaskManage().addTaskItem(taskItem);
        } else if (ResTask.CMD_DOWNLOAD_FILE.equals(item.getCommand())) {
          DownloadFileTaskItem taskItem =
              new DownloadFileTaskItem(
                  item.getId(),
                  item.getDownloadFileItem().getUrl(),
                  item.getDownloadFileItem().getPath());
          TaskManage.getTaskManage().addTaskItem(taskItem);
        }
      }
      if (task.getItems().length > 0) {
        TaskManage.getTaskManage().setWaitResult(task.isWaitResult());
        TaskManage.getTaskManage().beginTask();
        TaskManage.getTaskManage().setListener(this);
      }
    }
  }