Пример #1
0
  @SuppressWarnings("unchecked")
  @Override
  public ResultInfo<DataDefine> getResponseData() {
    ResultInfo<DataDefine> result = new ResultInfo<DataDefine>();

    if (mData != null) {
      String str = new String(mData);
      if (!TextUtils.isEmpty(str)) {
        try {
          JSONObject json = new JSONObject(str.toString());
          if (json.getString("Success").equals("false")) {
            result.Success = false;
            result.Message = json.getString("Message");
          } else {
            json = new JSONObject(json.getString("Data"));
            result.Data = new DataDefine(json);
          }
        } catch (JSONException e) {
          result.Success = false;
          result.Message = "服务器异常,获取勘察表失败";
          DataLogOperator.taskHttp(
              "GetDataDefineDataTask=>获取勘察匹配表完整信息失败(getResponseData)", e.getMessage());
        }
      } else {
        result.Success = false;
        result.Message = "没有返回数据";
      }
    }

    return result;
  }
Пример #2
0
  /**
   * 获取指定勘察匹配表完整信息
   *
   * @param currentUser
   * @param dataDefine
   * @return
   */
  public ResultInfo<DataDefine> request(UserInfo currentUser, DataDefine dataDefine) {
    ResultInfo<DataDefine> result = new ResultInfo<DataDefine>();

    String url = currentUser.LatestServer + "/apis/GetAllDataFieldDefine/" + dataDefine.DDID;
    // 填充参数,key-value。key是接口要求传的变量名称
    Hashtable<String, Object> params = new Hashtable<String, Object>(1);
    params.put("token", currentUser.Token);

    CommonRequestPackage requestPackage =
        new CommonRequestPackage(url, RequestTypeEnum.GET, params);
    try {
      YFHttpClient.request(requestPackage, this);
      result = getResponseData();
    } catch (Exception e) {
      result.Success = false;
      result.Message = "服务器异常,获取勘察表失败";
      DataLogOperator.taskHttp("GetDataDefineDataTask=>获取指定勘察匹配表完整信息失败(request)", e.getMessage());
    }

    return result;
  }