示例#1
0
  /** Return Login status with DataTable instance */
  @Override
  public Object run() {
    SoapObject rpc = new SoapObject(SCWebService.SC_NAME_SPACE, SCWebService.SC_METHOD_GETDETAILS);

    rpc.addProperty("User_dm", mUserDM);
    rpc.addProperty("Task_contentid", mContentID);
    rpc.addProperty("Task_lx", mTaskLX);

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER10);

    envelope.bodyOut = rpc;
    envelope.dotNet = true;
    envelope.setOutputSoapObject(rpc);

    HttpTransportSE transport = new HttpTransportSE(SCWebService.getEndPoint(mContext));
    try {
      transport.call(SCWebService.SC_NAME_SPACE + SCWebService.SC_METHOD_GETDETAILS, envelope);
    } catch (Exception e) {
      e.printStackTrace();
      LogUtils.logE("GetDetailsTask: " + e);
      return null;
    }
    SoapObject object = (SoapObject) envelope.bodyIn;
    List<TaskContent> taskContents = new ArrayList<TaskContent>();
    TaskContent.parseTaskContent(object, mUserDM, mContentID, mMessageID, taskContents);
    if (taskContents.size() == 0) {
      LogUtils.logD(
          "There is no taskcontent for ContentID" + mContentID + " MessageID " + mMessageID);
    }
    return taskContents;
  }
示例#2
0
  private void run() {
    if (sRun) {
      LogUtils.logE("TaskEngine has been running!");
      return;
    }
    sRun = true;
    LogUtils.logD("ReportTaskEngine.run, ID" + sID);
    new Thread(
            new Runnable() {

              @Override
              public void run() {
                while (true) {
                  if (canceled) {
                    return;
                  }
                  BaseTask task = mTaskQueue.poll();
                  if (task == null) {
                    try {
                      Thread.sleep(SLEEP_TIME_MS);
                      LogUtils.logE("To sleep " + SLEEP_TIME_MS);
                    } catch (InterruptedException e) {
                      e.printStackTrace();
                      LogUtils.logE(e.toString());
                    }
                    continue;
                  }

                  if (canceled) {
                    return;
                  }

                  Object result = null;
                  if (!task.isCanceled()) {
                    result = task.run();
                    LogUtils.logD("task.run()" + task.toString());
                  }

                  if (canceled) {
                    return;
                  }

                  if (!task.isCanceled()) {
                    task.onCallback(result);
                  }
                }
              }
            },
            "ReportTaskEngine" + sID++)
        .start();
  }
示例#3
0
 public void appendTask(BaseTask task) {
   LogUtils.logD("ReportTaskEngine.appendTask" + task);
   if (task == null) {
     return;
   }
   mTaskQueue.add(task);
 }
示例#4
0
 public void cancelTask(BaseTask task) {
   LogUtils.logD("ReportTaskEngine.cancelTask" + task);
   if (task == null) {
     return;
   }
   task.markAsCanceled();
   mTaskQueue.remove(task);
 }
示例#5
0
  /** Return ReplyTasks status with Integer Value 1 : success 0 : fail */
  @Override
  public Object run() {
    if (mDebug) {
      return 0;
    }
    SoapObject rpc = new SoapObject(SCWebService.SC_NAME_SPACE, SCWebService.SC_METHOD_REPLY_TASKS);

    rpc.addProperty("User_dm", mUserDM);
    SoapObject soap =
        new SoapObject(SCWebService.SC_NAME_SPACE, SCWebService.SC_METHOD_REPLY_TASKS);
    for (String id : mMessageIds) {
      soap.addProperty("string", id);
    }
    rpc.addProperty("messageids", soap);

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER10);

    envelope.bodyOut = rpc;
    envelope.dotNet = true;
    envelope.setOutputSoapObject(rpc);

    HttpTransportSE transport = new HttpTransportSE(SCWebService.getEndPoint(mContext));
    try {
      transport.call(SCWebService.SC_NAME_SPACE + SCWebService.SC_METHOD_REPLY_TASKS, envelope);
    } catch (Exception e) {
      e.printStackTrace();
      LogUtils.logE("ReplyTasksTask: " + e);
      return null;
    }
    int result = 0;
    if (envelope.bodyIn instanceof SoapObject) {
      SoapObject object = (SoapObject) envelope.bodyIn;
      result = Integer.parseInt(object.getProperty(0).toString());
      if (result != 1) {
        // Report it automatically if failed
        ReportTaskEngine.getInstance().appendTask(this);
      }
    } else {
      LogUtils.logE("ReplyTasksTask: " + envelope.bodyIn);
    }
    return result;
  }
示例#6
0
 public static ReportTaskEngine getInstance() {
   LogUtils.logD("ReportTaskEngine.getInstance");
   return sTaskEngineInstance;
 }