From 56debb7bc70a2d658f93c1fb2b641071b4854b7c Mon Sep 17 00:00:00 2001 From: sujinwen <sujinwen@454eff88-639b-444f-9e54-f578c98de674> Date: 星期三, 19 七月 2017 20:17:36 +0800 Subject: [PATCH] --- VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/RegisterMng.java | 203 ++++++++++++++++++++++++++++---------------------- 1 files changed, 112 insertions(+), 91 deletions(-) diff --git a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/RegisterMng.java b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/RegisterMng.java index 2fcd314..0e9dfeb 100644 --- a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/RegisterMng.java +++ b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/RegisterMng.java @@ -6,6 +6,8 @@ import cn.com.basic.face.discern.common.CommonVariables; import cn.com.basic.face.fragment.AttenderRegisterFragment; import cn.com.basic.face.fragment.VisitorRegisterFragment; +import cn.com.basic.face.service.sqlite.RegisterDao; +import cn.com.basic.face.service.sqlite.VisitDao; import cn.com.basic.face.util.AppApi; import org.xutils.http.RequestParams; @@ -30,54 +32,61 @@ if (!BaseApplication.deviceAvailable) { return; } - try { - File path = BaseApplication.getInstance().getFilesDir(); - File rawSurveillancePhotoFile = new File(path, "rawSurveillancePhoto"); - if (!rawSurveillancePhotoFile.exists()) { - rawSurveillancePhotoFile.createNewFile(); - } - File f0 = new File(path, "f0"); - if (!f0.exists()) { - f0.createNewFile(); - } - File surveillancePhotoFile = new File(path, "surveillancePhoto"); - if (!surveillancePhotoFile.exists()) { - surveillancePhotoFile.createNewFile(); - } - File uploadCustomPhotoFile = new File(path, "uploadCustomPhoto"); - if (!uploadCustomPhotoFile.exists()) { - uploadCustomPhotoFile.createNewFile(); - } - File idCardPhotoFile = new File(path, "idCardPhoto"); - if (!idCardPhotoFile.exists()) { - idCardPhotoFile.createNewFile(); - } + if (BaseApplication.getInstance().networkAvailable()) { + try { + File path = BaseApplication.getInstance().getFilesDir(); + File rawSurveillancePhotoFile = new File(path, "rawSurveillancePhoto"); + if (!rawSurveillancePhotoFile.exists()) { + rawSurveillancePhotoFile.createNewFile(); + } + File f0 = new File(path, "f0"); + if (!f0.exists()) { + f0.createNewFile(); + } + File surveillancePhotoFile = new File(path, "surveillancePhoto"); + if (!surveillancePhotoFile.exists()) { + surveillancePhotoFile.createNewFile(); + } + File uploadCustomPhotoFile = new File(path, "uploadCustomPhoto"); + if (!uploadCustomPhotoFile.exists()) { + uploadCustomPhotoFile.createNewFile(); + } + File idCardPhotoFile = new File(path, "idCardPhoto"); + if (!idCardPhotoFile.exists()) { + idCardPhotoFile.createNewFile(); + } - FileWriter fw0 = new FileWriter(f0); - fw0.write("test1"); - fw0.close(); - params.setUri(AppApi.BASE_URL +AppApi.REGISTER_ADD); - params.addBodyParameter("f0", f0); - params.addBodyParameter("rawSurveillancePhoto", rawSurveillancePhotoFile); - params.addBodyParameter("surveillancePhoto", surveillancePhotoFile); - params.addBodyParameter("uploadCustomPhoto", uploadCustomPhotoFile); - params.addBodyParameter("idCardPhoto", idCardPhotoFile); - if (idCardHeadPhoto != null && !"".equals(idCardHeadPhoto)) { - File f5 = new File(idCardHeadPhoto); - if (!f5.exists()) { - f5.createNewFile(); + FileWriter fw0 = new FileWriter(f0); + fw0.write("test1"); + fw0.close(); + params.setUri(AppApi.BASE_URL +AppApi.REGISTER_ADD); + params.addBodyParameter("f0", f0); + params.addBodyParameter("rawSurveillancePhoto", rawSurveillancePhotoFile); + params.addBodyParameter("surveillancePhoto", surveillancePhotoFile); + params.addBodyParameter("uploadCustomPhoto", uploadCustomPhotoFile); + params.addBodyParameter("idCardPhoto", idCardPhotoFile); + if (idCardHeadPhoto != null && !"".equals(idCardHeadPhoto)) { + File f5 = new File(idCardHeadPhoto); + if (!f5.exists()) { + f5.createNewFile(); + } + params.addBodyParameter("idCardHeadPhoto", f5); } - params.addBodyParameter("idCardHeadPhoto", f5); + x.http().post(params, new BaseCommonCallBack() { + @Override + public void success() { + Toast.makeText(BaseApplication.getInstance(),"娣诲姞鎴愬姛", Toast.LENGTH_SHORT).show(); + VisitorRegisterFragment.getInstance().resetForm(); + } + }); + }catch(Exception e) { + e.printStackTrace(); } - x.http().post(params, new BaseCommonCallBack() { - @Override - public void success() { - Toast.makeText(BaseApplication.getInstance(),"娣诲姞鎴愬姛", Toast.LENGTH_SHORT).show(); - VisitorRegisterFragment.getInstance().resetForm(); - } - }); - }catch(Exception e) { - e.printStackTrace(); + } else { + RegisterDao.getInstance().add(params, idCardHeadPhoto); + VisitDao.getInstance().findLeftVisitorList("", 1); + Toast.makeText(BaseApplication.getInstance(),"娣诲姞鎴愬姛", Toast.LENGTH_SHORT).show(); + VisitorRegisterFragment.getInstance().resetForm(); } } @@ -115,7 +124,7 @@ ) { return; } - List<Double> percents = resultBean.getListBeanOfType(Double.class); + List<Double> percents = resultBean.getList(Double.class); if (percents != null && percents.size() > 0) { double percent = percents.get(0); if (percent >= 70) { @@ -145,55 +154,67 @@ if (!BaseApplication.deviceAvailable) { return; } - try { - File path = BaseApplication.getInstance().getFilesDir(); - File rawSurveillancePhotoFile = new File(path, "rawSurveillancePhoto_attender"); - if (!rawSurveillancePhotoFile.exists()) { - rawSurveillancePhotoFile.createNewFile(); - } - File f0 = new File(path, "f0"); - if (!f0.exists()) { - f0.createNewFile(); - } - File surveillancePhotoFile = new File(path, "surveillancePhoto_attender"); - if (!surveillancePhotoFile.exists()) { - surveillancePhotoFile.createNewFile(); - } - File uploadCustomPhotoFile = new File(path, "uploadCustomPhoto_attender"); - if (!uploadCustomPhotoFile.exists()) { - uploadCustomPhotoFile.createNewFile(); - } - File idCardPhotoFile = new File(path, "idCardPhoto_attender"); - if (!idCardPhotoFile.exists()) { - idCardPhotoFile.createNewFile(); - } + if (BaseApplication.getInstance().networkAvailable()) { + try { + File path = BaseApplication.getInstance().getFilesDir(); + File rawSurveillancePhotoFile = new File(path, "rawSurveillancePhoto_attender"); + if (!rawSurveillancePhotoFile.exists()) { + rawSurveillancePhotoFile.createNewFile(); + } + File f0 = new File(path, "f0"); + if (!f0.exists()) { + f0.createNewFile(); + } + File surveillancePhotoFile = new File(path, "surveillancePhoto_attender"); + if (!surveillancePhotoFile.exists()) { + surveillancePhotoFile.createNewFile(); + } + File uploadCustomPhotoFile = new File(path, "uploadCustomPhoto_attender"); + if (!uploadCustomPhotoFile.exists()) { + uploadCustomPhotoFile.createNewFile(); + } + File idCardPhotoFile = new File(path, "idCardPhoto_attender"); + if (!idCardPhotoFile.exists()) { + idCardPhotoFile.createNewFile(); + } - FileWriter fw0 = new FileWriter(f0); - fw0.write("test1"); - fw0.close(); - params.setUri(AppApi.BASE_URL +AppApi.ATTENDER_REGISTER_ADD); - params.addBodyParameter("f0", f0); - params.addBodyParameter("rawSurveillancePhoto", rawSurveillancePhotoFile); - params.addBodyParameter("surveillancePhoto", surveillancePhotoFile); - params.addBodyParameter("uploadCustomPhoto", uploadCustomPhotoFile); - params.addBodyParameter("idCardPhoto", idCardPhotoFile); - if (idCardHeadPhoto != null && !"".equals(idCardHeadPhoto)) { - File f5 = new File(idCardHeadPhoto); - if (!f5.exists()) { - f5.createNewFile(); + FileWriter fw0 = new FileWriter(f0); + fw0.write("test1"); + fw0.close(); + params.setUri(AppApi.BASE_URL +AppApi.ATTENDER_REGISTER_ADD); + params.addBodyParameter("f0", f0); + params.addBodyParameter("rawSurveillancePhoto", rawSurveillancePhotoFile); + params.addBodyParameter("surveillancePhoto", surveillancePhotoFile); + params.addBodyParameter("uploadCustomPhoto", uploadCustomPhotoFile); + params.addBodyParameter("idCardPhoto", idCardPhotoFile); + if (idCardHeadPhoto != null && !"".equals(idCardHeadPhoto)) { + File f5 = new File(idCardHeadPhoto); + if (!f5.exists()) { + f5.createNewFile(); + } + params.addBodyParameter("idCardHeadPhoto_attender", f5); } - params.addBodyParameter("idCardHeadPhoto_attender", f5); + x.http().post(params, new BaseCommonCallBack() { + @Override + public void success() { + Toast.makeText(BaseApplication.getInstance(),"娣诲姞鎴愬姛", Toast.LENGTH_SHORT).show(); + AttenderRegisterFragment.getInstance().resetForm(); + } + }); + }catch(Exception e) { + e.printStackTrace(); } - x.http().post(params, new BaseCommonCallBack() { - @Override - public void success() { - Toast.makeText(BaseApplication.getInstance(),"娣诲姞鎴愬姛", Toast.LENGTH_SHORT).show(); - AttenderRegisterFragment.getInstance().resetForm(); - } - }); - }catch(Exception e) { - e.printStackTrace(); + } else { + RegisterDao.getInstance().add(params, idCardHeadPhoto); + Toast.makeText(BaseApplication.getInstance(),"娣诲姞鎴愬姛", Toast.LENGTH_SHORT).show(); } + } + public void sendOfflineRegisterToServer() { + } + + public boolean hasOfflineRegisterData() { + return false; + } } -- Gitblit v1.8.0