Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void postMyData(final frmListServiceCalls parent, final ArrayList<NameValuePair> postParameters){
- DATASyncStatus = DATA_PROCESSING;
- Log.i("PremSCNBlob","postMyData() : processing : Blob.getSCN()=`"+ getSCN()+"` DATASyncStatus=`"+DATASyncStatus+"`");
- /***
- * initialise with id because SECURITY was added in the CONSTRUCTOR
- */
- final String getstring = "http://home.pfsp.co.uk:8043/app/uploadData.php?id=" + getId();
- /*****
- * send Images and content / add fields where neccesary
- */
- if (isPendArrivalDateTime()){
- postParameters.add(new BasicNameValuePair("arrival_datetime", URLEncoder.encode(getArrivalDateTime())));
- }
- if (isPendTravelTime()){
- postParameters.add(new BasicNameValuePair("traveltime", URLEncoder.encode(getTravelTime())));
- }
- if (isPendCompletedDateTime()){
- postParameters.add(new BasicNameValuePair("completed_datetime", URLEncoder.encode(getCompletedDateTime())));
- }
- if (isPendWorksRequired()){
- postParameters.add(new BasicNameValuePair("works_required", URLEncoder.encode(getWorksRequired())));
- }
- if (isPendWorksConducted()){
- postParameters.add(new BasicNameValuePair("works_conducted", URLEncoder.encode(getWorksConducted())));
- }
- if (isPendPartsUsed()){
- postParameters.add(new BasicNameValuePair("parts_used", URLEncoder.encode(getPartsUsed())));
- }
- if (isPendWorkClosedStatusCode()){
- postParameters.add(new BasicNameValuePair("work_closed_status_code", URLEncoder.encode(getWorkClosedStatusCode())));
- }
- if (isPendCallStatus()){
- postParameters.add(new BasicNameValuePair("call_status_code", URLEncoder.encode(getCallStatus())));
- }
- /***
- * normal async "get"
- * - - - - - - -
- * - - - - - - -
- * - - - - - - - - - P O S T A L L E X C E P T I M A G E
- * - - - - - - -
- */
- final class GetUserHttpTask extends AsyncTask<String/* Param */, Boolean /* Progress */, String /* Result */> {
- /*************
- * busy dialog
- */
- private final ProgressDialog dialog = new ProgressDialog(parent);
- protected void onPreExecute() {
- this.dialog.setMessage("DataPosting");
- this.dialog.setCancelable(false);
- this.dialog.show();
- }
- /*************
- * attempt to post
- */
- @Override
- protected String doInBackground(String... params) {
- publishProgress(true);
- Log.i("PremSCNBlob","postMyData() : GetUserHttpTask.doInBackground()=`"+ getSCN()+"` DATASyncStatus=`"+DATASyncStatus+"`");
- try {
- Log.i("PremSCNBlob","postMyData() : GetUserHttpTask.doInBackground()(try)");
- String targetUrl = getstring;
- String response = Include_CustomHttpClient.executeHttpPost(targetUrl, postParameters);
- Log.i("PremSCNBlob","postMyData() : GetUserHttpTask.doInBackground()(try)(response=`"+response+"`)");
- return response;
- } catch (Exception e) {
- DATASyncStatus = DATA_FAILED;
- Log.e("PremSCNBlob","postMyData() : GetUserHttpTask.doInBackground()(catch)\n" + e.getStackTrace());
- return "";
- }
- } // </ doInBackground()>
- /***
- * on complete
- */
- @Override
- protected void onPostExecute(String result) {
- publishProgress(false);
- Log.i("PremSCNBlob","postMyData() : GetUserHttpTask.onPostExecute()(start)=`"+ getSCN()+"` DATASyncStatus=`"+DATASyncStatus+"`");
- try{
- if (result.length()>3 && result.substring(0,3).equals("OK:")){
- /***
- * ALL OK
- */
- //lovely
- DATASyncStatus = DATA_COMPLETED_OK;
- Log.i("PremSCNBlob","postMyData() : GetUserHttpTask.onPostExecute()(done)=`"+ getSCN()+"` DATASyncStatus=`"+DATASyncStatus+"`");
- }
- else{
- /**
- * error: disconnect
- */
- //stall the !refresh!
- httpDataFailedMessage = result;
- DATASyncStatus = DATA_FAILED;
- Log.i("PremSCNBlob","postMyData() : GetUserHttpTask.onPostExecute()(fail)=`"+ getSCN()+"` DATASyncStatus=`"+DATASyncStatus+"`");
- }
- if (this.dialog.isShowing()) {
- this.dialog.dismiss();
- }
- } catch (Exception e) {
- DATASyncStatus = DATA_FAILED;
- Log.e("PremSCNBlob","postMyData() : GetUserHttpTask.onPostExecute()(catch)\n" + e.getStackTrace());
- }
- } // </ onPostExecute()>
- }
- try{
- parent.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- new GetUserHttpTask().execute();
- }
- });
- }
- catch (Exception e){
- DATASyncStatus = DATA_FAILED;
- Log.e("PremSCNBlob","postMyData() : GetUserHttpTask().execute()(catch)\n" + e.getStackTrace());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment