| | |
| | | File rawSurveillancePhotoFile = FileUtil.writeToFile("rawSurveillancePhotoFile_"+fileIndex, byteArray);
|
| | | File surveillancePhotoFile = FileUtil.writeToFile("surveillancePhotoFile_"+fileIndex, surveillancePhotoBytes);
|
| | |
|
| | | params.addBodyParameter("deviceCompanyId", BaseApplication.getInstance().getAndroidDevice().getCompanyId());
|
| | | params.addBodyParameter("InOrOutCamera", cameraInOrOut + "");
|
| | | params.addBodyParameter("deviceId", BaseApplication.getInstance().getAndroidDevice().getDeviceId());
|
| | | params.addBodyParameter("rawSurveillancePhoto", rawSurveillancePhotoFile);
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | public void sendOfflineUnknownToServer() {
|
| | | if (!BaseApplication.deviceAvailable) {
|
| | | return;
|
| | | }
|
| | | UnknownQueryItem item = SurveillanceDao.getInstance().readOfflineUnknownFromLocal();
|
| | | if (item == null) {
|
| | | return;
|
| | | }
|
| | | syncOfflineData(item);
|
| | | }
|
| | | public void removePhotoFileWhenStorageIsSlow() {
|
| | |
|
| | | private void syncOfflineData(final UnknownQueryItem item) {
|
| | | try {
|
| | | if (fileIndex > 30) {
|
| | | fileIndex = 1;
|
| | | }
|
| | | fileIndex++;
|
| | | RequestParams params = new RequestParams();
|
| | |
|
| | | File rawSurveillancePhotoFile = FileUtil.getFile(item.getRawDataPath());
|
| | |
|
| | | params.addBodyParameter("deviceCompanyId", BaseApplication.getInstance().getAndroidDevice().getCompanyId());
|
| | | params.addBodyParameter("InOrOutCamera", item.getCameraInOrOut() + "");
|
| | | params.addBodyParameter("deviceId", BaseApplication.getInstance().getAndroidDevice().getDeviceId());
|
| | | params.addBodyParameter("rawSurveillancePhoto", rawSurveillancePhotoFile);
|
| | |
|
| | | File path = BaseApplication.getInstance().getFilesDir();
|
| | | File f0 = new File(path, "f0");
|
| | | if (!f0.exists()) {
|
| | | f0.createNewFile();
|
| | | }
|
| | |
|
| | | FileWriter fw0 = new FileWriter(f0);
|
| | | fw0.write("test1");
|
| | | fw0.close();
|
| | | params.setUri(AppApi.BASE_URL + AppApi.SURVEILLANCE_UPLOAD);
|
| | | params.addBodyParameter("f0", f0);
|
| | | params.addBodyParameter("rawSurveillancePhoto", rawSurveillancePhotoFile);
|
| | | params.addBodyParameter("androidCreateTime", item.getCreateTime());
|
| | | params.addBodyParameter("offlineUnknown", CommonVariables.Surveillance.OFFLINE_SURVEILLANCE_ITEM_TYPE +"");
|
| | | params.addBodyParameter("deviceCompanyId", BaseApplication.getInstance().getAndroidDevice().getCompanyId());
|
| | | x.http().post(params, new BaseCommonCallBack() {
|
| | | @Override
|
| | | public void success() {
|
| | | try {
|
| | | if (1==1) {
|
| | | SurveillanceDao.getInstance().removeLocalSqliteRecord(item);
|
| | | }
|
| | | } catch(Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | });
|
| | | }catch(Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | }
|