コード例 #1
0
  public void addJsonReporte(String ordenId, String status, String coment, String costales) {
    String jsonReportes = "";
    JSONObject jsonFinal = new JSONObject();
    JSONArray arrayFinal = new JSONArray();
    JSONObject reporte_json = new JSONObject();

    if (files.existsFile(Datos.REPORTES_FIN_FILE_NAME, files.BACHES_CACHE_DIRECTORY)) {
      jsonReportes = files.readFile(Datos.REPORTES_FIN_FILE_NAME, files.BACHES_CACHE_DIRECTORY);

      try {
        JSONObject json = new JSONObject(jsonReportes);
        arrayFinal = json.getJSONArray("solicitudes");
      } catch (JSONException e) {
        e.printStackTrace();
      }
    }

    try {
      reporte_json.put("id", ordenId);
      reporte_json.put("idEstatus", status);
      reporte_json.put("comentario", coment);
      reporte_json.put("costales", costales);

      arrayFinal.put(reporte_json);
      jsonFinal.put("solicitudes", arrayFinal);

      files.saveFile(
          Datos.REPORTES_FIN_FILE_NAME, jsonFinal.toString(), files.BACHES_CACHE_DIRECTORY);
    } catch (JSONException e) {
      e.printStackTrace();
    }
  }
コード例 #2
0
  public void addJsonImage(
      String image_name, String path, String image_url, String id, String estatus) {
    String jsonImage = "";
    JSONObject jsonFinal = new JSONObject();
    JSONArray arrayFinal = new JSONArray();
    JSONObject image_json = new JSONObject();

    if (files.existsFile(Datos.IMAGENES_FILE_NAME, files.BACHES_CACHE_DIRECTORY)) {
      jsonImage = files.readFile(Datos.IMAGENES_FILE_NAME, files.BACHES_CACHE_DIRECTORY);

      try {
        JSONObject json = new JSONObject(jsonImage);
        arrayFinal = json.getJSONArray("images");
      } catch (JSONException e) {
        e.printStackTrace();
      }
    }

    try {
      image_json.put("ImageName", image_name);
      image_json.put("ImageUrl", image_url);
      image_json.put("ImagePath", path);
      image_json.put("ImageID", id);
      image_json.put("ImageEstatus", estatus);

      arrayFinal.put(image_json);
      jsonFinal.put("images", arrayFinal);

      files.saveFile(Datos.IMAGENES_FILE_NAME, jsonFinal.toString(), files.BACHES_CACHE_DIRECTORY);
    } catch (JSONException e) {
      e.printStackTrace();
    }
  }
コード例 #3
0
  @Override
  public void onClickConcluirReporte(
      String new_status, String coment, Bitmap img, String costales) {
    // TODO Auto-generated method stub
    Orden or = datos.adapter.getOrden(orden_position);
    String image_name = datos.getOrdenName(or, Datos.TIPO_IMAGEN_FIN, "jpg");
    String image_url = datos.createOrdenName(or, Datos.TIPO_IMAGEN_FIN, "jpg");
    String ordenId = or.getIdSolicitud();

    files.saveImage(image_name, files.BACHES_PHOTOS_DIRECTORY, img);

    or.setEstatus("Orden Finalizada");
    or.setEstatusId(new_status);

    addJsonReporte(ordenId, new_status, coment, costales);
    addJsonImage(
        image_name, files.BACHES_PHOTOS_DIRECTORY + image_name, image_url, ordenId, new_status);

    String ordenJson = CreateOrdenJson.createFromAdapter(datos.adapter);
    files.saveFile("ordenes.txt", ordenJson, files.BACHES_CACHE_DIRECTORY);

    createAlert("Reporte", "Se ha finalizado el reporte!!");
  }