@ -206,15 +206,15 @@ public class MySynchronizationOld
String fname ;
String fname ;
fname = cursor . getString ( cursor . getColumnIndex ( " image_name1 " ) ) ;
fname = cursor . getString ( cursor . getColumnIndex ( " image_name1 " ) ) ;
if ( fname ! = null & & ! fname . equals ( " " ) )
if ( fname ! = null & & ! fname . equals ( " " ) )
myThread . addRequest ( MySynchronizationOld . URL + " /get/?fn=6 " , null , Environment . getExternalStorageDirectory ( ) . getAbsolutePath ( ) + " /Pictures/Locust/ " + fname , null ) ;
myThread . addRequest ( " pic1 " , MySynchronizationOld . URL + " /get/?fn=6 " , null , Environment . getExternalStorageDirectory ( ) . getAbsolutePath ( ) + " /Pictures/Locust/ " + fname , null ) ;
fname = cursor . getString ( cursor . getColumnIndex ( " image_name2 " ) ) ;
fname = cursor . getString ( cursor . getColumnIndex ( " image_name2 " ) ) ;
if ( fname ! = null & & ! fname . equals ( " " ) )
if ( fname ! = null & & ! fname . equals ( " " ) )
myThread . addRequest ( MySynchronizationOld . URL + " /get/?fn=6 " , null , Environment . getExternalStorageDirectory ( ) . getAbsolutePath ( ) + " /Pictures/Locust/ " + fname , null ) ;
myThread . addRequest ( " pic2 " , MySynchronizationOld . URL + " /get/?fn=6 " , null , Environment . getExternalStorageDirectory ( ) . getAbsolutePath ( ) + " /Pictures/Locust/ " + fname , null ) ;
fname = cursor . getString ( cursor . getColumnIndex ( " image_name3 " ) ) ;
fname = cursor . getString ( cursor . getColumnIndex ( " image_name3 " ) ) ;
if ( fname ! = null & & ! fname . equals ( " " ) )
if ( fname ! = null & & ! fname . equals ( " " ) )
myThread . addRequest ( MySynchronizationOld . URL + " /get/?fn=6 " , null , Environment . getExternalStorageDirectory ( ) . getAbsolutePath ( ) + " /Pictures/Locust/ " + fname , null ) ;
myThread . addRequest ( " pic2 " , MySynchronizationOld . URL + " /get/?fn=6 " , null , Environment . getExternalStorageDirectory ( ) . getAbsolutePath ( ) + " /Pictures/Locust/ " + fname , null ) ;
xml = " <?xml version= \" 1.0 \" encoding= \" UTF-8 \" ?> " ;
xml = " <?xml version= \" 1.0 \" encoding= \" UTF-8 \" ?> " ;
xml + = " <metadata fn= \" 4 \" > " ;
xml + = " <metadata fn= \" 4 \" > " ;
@ -245,7 +245,7 @@ public class MySynchronizationOld
cursor2 . close ( ) ;
cursor2 . close ( ) ;
xml + = " </metadata> " ;
xml + = " </metadata> " ;
rid_sendFrmLocust = myThread . addRequest ( MySynchronizationOld . URL + " /get/ " , xml , null , null ) ;
rid_sendFrmLocust = myThread . addRequest ( " sendFrmLocust " , MySynchronizationOld . URL + " /get/ " , xml , null , null ) ;
} while ( cursor . moveToNext ( ) ) ;
} while ( cursor . moveToNext ( ) ) ;
}
}
@ -281,15 +281,15 @@ public class MySynchronizationOld
String fname ;
String fname ;
fname = cursor . getString ( cursor . getColumnIndex ( " image_name1 " ) ) ;
fname = cursor . getString ( cursor . getColumnIndex ( " image_name1 " ) ) ;
if ( fname ! = null & & ! fname . equals ( " " ) )
if ( fname ! = null & & ! fname . equals ( " " ) )
myThread . addRequest ( MySynchronizationOld . URL + " /get/?fn=6 " , null , Environment . getExternalStorageDirectory ( ) . getAbsolutePath ( ) + " /Pictures/Locust/ " + fname , null ) ;
myThread . addRequest ( " pic1 " , MySynchronizationOld . URL + " /get/?fn=6 " , null , Environment . getExternalStorageDirectory ( ) . getAbsolutePath ( ) + " /Pictures/Locust/ " + fname , null ) ;
fname = cursor . getString ( cursor . getColumnIndex ( " image_name2 " ) ) ;
fname = cursor . getString ( cursor . getColumnIndex ( " image_name2 " ) ) ;
if ( fname ! = null & & ! fname . equals ( " " ) )
if ( fname ! = null & & ! fname . equals ( " " ) )
myThread . addRequest ( MySynchronizationOld . URL + " /get/?fn=6 " , null , Environment . getExternalStorageDirectory ( ) . getAbsolutePath ( ) + " /Pictures/Locust/ " + fname , null ) ;
myThread . addRequest ( " pic2 " , MySynchronizationOld . URL + " /get/?fn=6 " , null , Environment . getExternalStorageDirectory ( ) . getAbsolutePath ( ) + " /Pictures/Locust/ " + fname , null ) ;
fname = cursor . getString ( cursor . getColumnIndex ( " image_name3 " ) ) ;
fname = cursor . getString ( cursor . getColumnIndex ( " image_name3 " ) ) ;
if ( fname ! = null & & ! fname . equals ( " " ) )
if ( fname ! = null & & ! fname . equals ( " " ) )
myThread . addRequest ( MySynchronizationOld . URL + " /get/?fn=6 " , null , Environment . getExternalStorageDirectory ( ) . getAbsolutePath ( ) + " /Pictures/Locust/ " + fname , null ) ;
myThread . addRequest ( " pic3 " , MySynchronizationOld . URL + " /get/?fn=6 " , null , Environment . getExternalStorageDirectory ( ) . getAbsolutePath ( ) + " /Pictures/Locust/ " + fname , null ) ;
xml = " <?xml version= \" 1.0 \" encoding= \" UTF-8 \" ?> " ;
xml = " <?xml version= \" 1.0 \" encoding= \" UTF-8 \" ?> " ;
@ -320,7 +320,7 @@ public class MySynchronizationOld
cursor2 . close ( ) ;
cursor2 . close ( ) ;
xml + = " </metadata> " ;
xml + = " </metadata> " ;
rid_sendFrmLocust = myThread . addRequest ( MySynchronizationOld . URL + " /get/ " , xml , null , null ) ;
rid_sendFrmLocust = myThread . addRequest ( " sendFrmLocust " , MySynchronizationOld . URL + " /get/ " , xml , null , null ) ;
//Отправляю данные координат отдельно (без подтверждения доставки, потом нужно добавить поле send boolean и отправлять отдельно от frmlocustdel)
//Отправляю данные координат отдельно (без подтверждения доставки, потом нужно добавить поле send boolean и отправлять отдельно от frmlocustdel)
/* Cursor cursor3 = rdb.rawQuery("select uid,del,seq,frmlocustdel_uid,pos,lon,lat from frmlocustdel_locations where frmlocustdel_uid=? order by pos", new String[] { String.valueOf(uid) });
/* Cursor cursor3 = rdb.rawQuery("select uid,del,seq,frmlocustdel_uid,pos,lon,lat from frmlocustdel_locations where frmlocustdel_uid=? order by pos", new String[] { String.valueOf(uid) });
@ -354,8 +354,7 @@ public class MySynchronizationOld
}
}
cursor3 . close ( ) ;
cursor3 . close ( ) ;
//Отправляю пакет данных на сервер для вставки либо обновления
//Отправляю пакет данных на сервер для вставки либо обновления
myThread . addRequest ( MySynchronizationOld . URL + " /asdc/tctable/ " , null , null , outStream . toByteArray ( ) ) ;
myThread . addRequest ( tbl . name , MySynchronizationOld. URL + " /asdc/tctable/ " , null , null , outStream . toByteArray ( ) ) ;
} while ( cursor . moveToNext ( ) ) ;
} while ( cursor . moveToNext ( ) ) ;
}
}
@ -391,19 +390,19 @@ public class MySynchronizationOld
String fname ;
String fname ;
fname = cursor . getString ( cursor . getColumnIndex ( " image_name1 " ) ) ;
fname = cursor . getString ( cursor . getColumnIndex ( " image_name1 " ) ) ;
if ( fname ! = null & & ! fname . equals ( " " ) )
if ( fname ! = null & & ! fname . equals ( " " ) )
myThread . addRequest ( MySynchronizationOld . URL + " /get/?fn=6 " , null , Environment . getExternalStorageDirectory ( ) . getAbsolutePath ( ) + " /Pictures/Locust/ " + fname , null ) ;
myThread . addRequest ( " pic1 " , MySynchronizationOld . URL + " /get/?fn=6 " , null , Environment . getExternalStorageDirectory ( ) . getAbsolutePath ( ) + " /Pictures/Locust/ " + fname , null ) ;
fname = cursor . getString ( cursor . getColumnIndex ( " image_name2 " ) ) ;
fname = cursor . getString ( cursor . getColumnIndex ( " image_name2 " ) ) ;
if ( fname ! = null & & ! fname . equals ( " " ) )
if ( fname ! = null & & ! fname . equals ( " " ) )
myThread . addRequest ( MySynchronizationOld . URL + " /get/?fn=6 " , null , Environment . getExternalStorageDirectory ( ) . getAbsolutePath ( ) + " /Pictures/Locust/ " + fname , null ) ;
myThread . addRequest ( " pic2 " , MySynchronizationOld . URL + " /get/?fn=6 " , null , Environment . getExternalStorageDirectory ( ) . getAbsolutePath ( ) + " /Pictures/Locust/ " + fname , null ) ;
fname = cursor . getString ( cursor . getColumnIndex ( " image_name3 " ) ) ;
fname = cursor . getString ( cursor . getColumnIndex ( " image_name3 " ) ) ;
if ( fname ! = null & & ! fname . equals ( " " ) )
if ( fname ! = null & & ! fname . equals ( " " ) )
myThread . addRequest ( MySynchronizationOld . URL + " /get/?fn=6 " , null , Environment . getExternalStorageDirectory ( ) . getAbsolutePath ( ) + " /Pictures/Locust/ " + fname , null ) ;
myThread . addRequest ( " pic3 " , MySynchronizationOld . URL + " /get/?fn=6 " , null , Environment . getExternalStorageDirectory ( ) . getAbsolutePath ( ) + " /Pictures/Locust/ " + fname , null ) ;
fname = cursor . getString ( cursor . getColumnIndex ( " image_name4 " ) ) ;
fname = cursor . getString ( cursor . getColumnIndex ( " image_name4 " ) ) ;
if ( fname ! = null & & ! fname . equals ( " " ) )
if ( fname ! = null & & ! fname . equals ( " " ) )
myThread . addRequest ( MySynchronizationOld . URL + " /get/?fn=6 " , null , Environment . getExternalStorageDirectory ( ) . getAbsolutePath ( ) + " /Pictures/Locust/ " + fname , null ) ;
myThread . addRequest ( " pic4 " , MySynchronizationOld . URL + " /get/?fn=6 " , null , Environment . getExternalStorageDirectory ( ) . getAbsolutePath ( ) + " /Pictures/Locust/ " + fname , null ) ;
fname = cursor . getString ( cursor . getColumnIndex ( " image_name5 " ) ) ;
fname = cursor . getString ( cursor . getColumnIndex ( " image_name5 " ) ) ;
if ( fname ! = null & & ! fname . equals ( " " ) )
if ( fname ! = null & & ! fname . equals ( " " ) )
myThread . addRequest ( MySynchronizationOld . URL + " /get/?fn=6 " , null , Environment . getExternalStorageDirectory ( ) . getAbsolutePath ( ) + " /Pictures/Locust/ " + fname , null ) ;
myThread . addRequest ( " pic5 " , MySynchronizationOld . URL + " /get/?fn=6 " , null , Environment . getExternalStorageDirectory ( ) . getAbsolutePath ( ) + " /Pictures/Locust/ " + fname , null ) ;
for ( int i = 0 ; i < cursor . getColumnCount ( ) ; i + + )
for ( int i = 0 ; i < cursor . getColumnCount ( ) ; i + + )
@ -416,7 +415,7 @@ public class MySynchronizationOld
throw new RuntimeException ( e ) ;
throw new RuntimeException ( e ) ;
}
}
}
}
rid_sendFrmLocustHealth = myThread . addRequest ( MySynchronizationOld . URL + " /asdc/FrmLocustHealth/ " , jsonObject . toString ( ) , null , null ) ;
rid_sendFrmLocustHealth = myThread . addRequest ( " sendFrmLocustHealth " , MySynchronizationOld . URL + " /asdc/FrmLocustHealth/ " , jsonObject . toString ( ) , null , null ) ;
} while ( cursor . moveToNext ( ) ) ;
} while ( cursor . moveToNext ( ) ) ;
}
}
@ -450,9 +449,9 @@ public class MySynchronizationOld
}
}
dboh . close ( ) ;
dboh . close ( ) ;
if ( days ! = null & & ! days . isEmpty ( ) & & country_id ! = null & & ! country_id . isEmpty ( ) ) {
if ( days ! = null & & ! days . isEmpty ( ) & & country_id ! = null & & ! country_id . isEmpty ( ) ) {
return myThread . addRequest ( MySynchronizationOld . URL + " /get/?fn=1&r=0&n= " + tableName + " &s= " + seq + " &l=1000&days= " + days + " &country_id= " + country_id + " &android_id= " + android_id , " " , null , null ) ;
return myThread . addRequest ( tableName , MySynchronizationOld. URL + " /get/?fn=1&r=0&n= " + tableName + " &s= " + seq + " &l=1000&days= " + days + " &country_id= " + country_id + " &android_id= " + android_id , " " , null , null ) ;
} else {
} else {
return myThread . addRequest ( MySynchronizationOld . URL + " /get/?fn=1&r=0&n= " + tableName + " &s= " + seq + " &l=1000 " , " " , null , null ) ;
return myThread . addRequest ( tableName , MySynchronizationOld. URL + " /get/?fn=1&r=0&n= " + tableName + " &s= " + seq + " &l=1000 " , " " , null , null ) ;
}
}
}
}
@ -806,6 +805,7 @@ class MyThread extends Thread
class Tsk //Задание отправки данных
class Tsk //Задание отправки данных
{
{
String name = " " ; //Название запроса для дебага
String url = " " ; //URL куда отправлять данные
String url = " " ; //URL куда отправлять данные
String str = " " ; //Отправляемая строка
String str = " " ; //Отправляемая строка
String file = " " ; //Отправляемый файл
String file = " " ; //Отправляемый файл
@ -875,13 +875,14 @@ class MyThread extends Thread
// Добавление в задание на отправку до того как не получен ответ от предедущего запроса следующий не отсылается те. последовательно это делает (обработка результатов не в потоке загрузки а в основном потоке)
// Добавление в задание на отправку до того как не получен ответ от предедущего запроса следующий не отсылается те. последовательно это делает (обработка результатов не в потоке загрузки а в основном потоке)
//return id запроса
//return id запроса
public int addRequest ( String url , String str , String file , byte [ ] data )
public int addRequest ( String name , String url , String str , String file , byte [ ] data )
{
{
mId + + ; //Инкрементируем идентификатор запроса
mId + + ; //Инкрементируем идентификатор запроса
try
try
{
{
mSemaphore . acquire ( ) ;
mSemaphore . acquire ( ) ;
Tsk t = new Tsk ( ) ;
Tsk t = new Tsk ( ) ;
t . name = name ;
t . url = url ;
t . url = url ;
t . str = str ;
t . str = str ;
t . file = file ;
t . file = file ;
@ -943,6 +944,10 @@ class MyThread extends Thread
//Выполняем задание на отправку/приём данных
//Выполняем задание на отправку/приём данных
if ( tsk ! = null )
if ( tsk ! = null )
{
{
Log . i ( " igor " , " download task = " + tsk . name ) ;
//if(tsk.name.equals("frmlocustdel_locations")){
// Log.i("igor", "download task = "+tsk.name);
//}
boolean bError = false ;
boolean bError = false ;
tsk . s = true ; //Признак отправляемости запроса на сервер
tsk . s = true ; //Признак отправляемости запроса на сервер
@ -1042,7 +1047,8 @@ class MyThread extends Thread
BufferedInputStream bis = new BufferedInputStream ( conn . getInputStream ( ) ) ;
BufferedInputStream bis = new BufferedInputStream ( conn . getInputStream ( ) ) ;
BufferedOutputStream bos = new BufferedOutputStream ( new FileOutputStream ( new File ( filePath ) ) ) ;
BufferedOutputStream bos = new BufferedOutputStream ( new FileOutputStream ( new File ( filePath ) ) ) ;
int inByte ;
int inByte ;
while ( ( inByte = bis . read ( ) ) ! = - 1 ) bos . write ( inByte ) ;
while ( ( inByte = bis . read ( ) ) ! = - 1 )
bos . write ( inByte ) ;
bis . close ( ) ;
bis . close ( ) ;
bos . close ( ) ;
bos . close ( ) ;
} catch ( Exception ex )
} catch ( Exception ex )