|
|
@@ -0,0 +1,1704 @@
|
|
|
+package com.usai.ratradefiling.dataprovider;
|
|
|
+
|
|
|
+import android.content.Context;
|
|
|
+import android.content.SharedPreferences.Editor;
|
|
|
+import android.content.pm.PackageInfo;
|
|
|
+import android.content.pm.PackageManager;
|
|
|
+import android.content.pm.PackageManager.NameNotFoundException;
|
|
|
+import android.database.Cursor;
|
|
|
+import android.database.sqlite.SQLiteDatabase;
|
|
|
+import android.database.sqlite.SQLiteStatement;
|
|
|
+import android.os.Bundle;
|
|
|
+import android.text.TextUtils;
|
|
|
+import android.util.Log;
|
|
|
+
|
|
|
+//import com.usai.apex.TradeFilingApplication;
|
|
|
+import com.usai.ratradefiling.TradeFilingApplication;
|
|
|
+import com.usai.redant.rautils.utils.FileManager;
|
|
|
+import com.usai.redant.rautils.utils.RAUtil;
|
|
|
+
|
|
|
+import org.apache.http.conn.ssl.SSLSocketFactory;
|
|
|
+import org.json.JSONArray;
|
|
|
+import org.json.JSONException;
|
|
|
+import org.json.JSONObject;
|
|
|
+
|
|
|
+import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
+import java.net.Socket;
|
|
|
+import java.net.UnknownHostException;
|
|
|
+import java.security.KeyManagementException;
|
|
|
+import java.security.KeyStore;
|
|
|
+import java.security.KeyStoreException;
|
|
|
+import java.security.NoSuchAlgorithmException;
|
|
|
+import java.security.UnrecoverableKeyException;
|
|
|
+import java.util.Iterator;
|
|
|
+
|
|
|
+import javax.net.ssl.SSLContext;
|
|
|
+import javax.net.ssl.TrustManager;
|
|
|
+import javax.net.ssl.X509TrustManager;
|
|
|
+import com.usai.ratradefiling.dataprovider.RADataProvider;
|
|
|
+
|
|
|
+public class OnlineDataProvider extends com.usai.redant.rautils.utils.Network
|
|
|
+{
|
|
|
+ public static final String SHORT_VER ="2.92";
|
|
|
+
|
|
|
+ public static final int BEHAVIOR_SEARCH = 0;
|
|
|
+ public static final int BEHAVIOR_RESULT = 1;
|
|
|
+
|
|
|
+ private static final int REQUEST_TIMEOUT = 30 * 1000; // request
|
|
|
+ // time
|
|
|
+
|
|
|
+ // out
|
|
|
+ // 20
|
|
|
+ // secs
|
|
|
+ private static final int SO_TIMEOUT = 30 * 1000; // so
|
|
|
+ // time
|
|
|
+ // out
|
|
|
+ // 20
|
|
|
+ // secs;
|
|
|
+ public static int AP_USER_AUTH = 1;
|
|
|
+ public static int AP_USER_NOT_AUTH = 2;
|
|
|
+ public static int AP_USER_NOT_EXIST = 3;
|
|
|
+ public static int AP_SESSION_EXPIRED = 4;
|
|
|
+
|
|
|
+ public static int AP_MESSAGE_NEW = 5;
|
|
|
+ public static int AP_MESSAGE_NONE = 6;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //DEBUG
|
|
|
+// public static String BASE_URL = "http://10.0.0.123:8888";
|
|
|
+
|
|
|
+ //RELEASE
|
|
|
+ public static String BASE_URL = "https://ra.apexshipping.com";
|
|
|
+
|
|
|
+
|
|
|
+// URL
|
|
|
+ public static String URL_HOME = BASE_URL+"/main_new_29.php";
|
|
|
+ public static String URL_HISTORY = BASE_URL+"/main_new_29.php";
|
|
|
+ public static String URL_KPI = BASE_URL+"/main_new_29.php";
|
|
|
+ public static String URL_UPDATE_AUTH = BASE_URL+"/main_new_29.php";
|
|
|
+ public static String URL_REQUEST_COUNT = BASE_URL+"/main_new_29.php";
|
|
|
+ public static String URL_REQUEST_RECORDS = BASE_URL+"/main_new_29.php";
|
|
|
+ public static String URL_RETRIEVE_PASS = BASE_URL+"/main_new_29.php";
|
|
|
+ public static String URL_ANNOUNCEMENTS = BASE_URL+"/mobile_news.php";
|
|
|
+ public static String URL_NEWS = BASE_URL+"/mobile_news.php";
|
|
|
+ public static String URL_LOCATIONS = BASE_URL+"/mobile_news26.php";
|
|
|
+ public static String URL_PUSH = BASE_URL+"/main_new_29.php";
|
|
|
+ public static String URL_LOG = BASE_URL+"/mobile_news.php";
|
|
|
+ public static String URL_SEND_COMM_EMAIL = BASE_URL+"/main_new_29.php";
|
|
|
+ public static String URL_CHECK_UPDATE = BASE_URL+"/main_new_29.php";
|
|
|
+
|
|
|
+
|
|
|
+ public static String URL_UPLOAD_SQL = BASE_URL+"/main_new_29.php";
|
|
|
+ public static String URL_FETCH_RESULT = BASE_URL+"/main_new_29.php";
|
|
|
+ public static String URL_SAVE_RESULT = BASE_URL+"/main_new_29.php";
|
|
|
+
|
|
|
+
|
|
|
+//
|
|
|
+//
|
|
|
+//////debug
|
|
|
+// public static String URL_HOME = "http://192.168.0.138:8899/main_new_29.php";
|
|
|
+// public static String URL_HISTORY = "http://192.168.0.138:8899/main_new_29.php";
|
|
|
+// public static String URL_KPI = "http://192.168.0.138:8899/main_new_29.php";
|
|
|
+// public static String URL_UPDATE_AUTH = "http://192.168.0.138:8899/main_new_29.php";
|
|
|
+// public static String URL_REQUEST_COUNT = "http://192.168.0.138:8899/main_new_29.php";
|
|
|
+// public static String URL_REQUEST_RECORDS = "http://192.168.0.138:8899/main_new_29.php";
|
|
|
+// public static String URL_RETRIEVE_PASS = "http://192.168.0.138:8899/main_new_29.php";
|
|
|
+// public static String URL_ANNOUNCEMENTS = "http://192.168.0.138:8899/mobile_news.php";
|
|
|
+// public static String URL_NEWS = "http://192.168.0.138:8899/mobile_news.php";
|
|
|
+// public static String URL_LOCATIONS = "http://192.168.0.138:8899/mobile_news26.php";
|
|
|
+// public static String URL_PUSH = "http://192.168.0.138:8899/main_new_29.php";
|
|
|
+// public static String URL_LOG = "http://192.168.0.138:8899/mobile_news.php";
|
|
|
+// public static String URL_SEND_COMM_EMAIL = "http://192.168.0.138:8899/main_new_29.php";
|
|
|
+// public static String URL_CHECK_UPDATE = "http://192.168.0.138:8899/main_new_29.php";
|
|
|
+//
|
|
|
+//
|
|
|
+// public static String URL_UPLOAD_SQL = "http://192.168.0.138:8899/main_new_29.php";
|
|
|
+// public static String URL_FETCH_RESULT = "http://192.168.0.138:8899/main_new_29.php";
|
|
|
+// public static String URL_SAVE_RESULT = "http://192.168.0.138:8899/main_new_29.php";
|
|
|
+//
|
|
|
+
|
|
|
+ public static JSONObject request_login(String user, String password)
|
|
|
+ {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static String get_marketnews(String id, int limit)
|
|
|
+ {
|
|
|
+ String TAG = "net_dbg@get_marketnews";
|
|
|
+
|
|
|
+ if (!OnlineDataProvider.NetworkIsAvailable())
|
|
|
+ {
|
|
|
+ Log.d(TAG, "network not available!");
|
|
|
+ return null; // network not available
|
|
|
+ }
|
|
|
+
|
|
|
+ Bundle parms = new Bundle();
|
|
|
+ parms.putString("module_name", "Market News");
|
|
|
+ parms.putString("action_type", "search");
|
|
|
+ parms.putString("id", id + "");
|
|
|
+ parms.putString("limit", limit + "");
|
|
|
+ String jstr = getJson(OnlineDataProvider.URL_NEWS, parms);
|
|
|
+ if (jstr == null || jstr.length() <= 0)
|
|
|
+ {
|
|
|
+ Log.d(TAG, "json is wrong");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return jstr;
|
|
|
+
|
|
|
+ }
|
|
|
+ private static JSONObject handleJson(String jsonStr) {
|
|
|
+
|
|
|
+ if (jsonStr == null || jsonStr.isEmpty()) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ JSONObject json = new JSONObject(jsonStr);
|
|
|
+ String msg = json.optString("msg");
|
|
|
+ if (msg != null) {
|
|
|
+ json.put("err_msg",msg);
|
|
|
+ }
|
|
|
+
|
|
|
+ return json;
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public static String get_servicelocation()
|
|
|
+ {
|
|
|
+
|
|
|
+ if (!OnlineDataProvider.NetworkIsAvailable())
|
|
|
+ {
|
|
|
+ return null; // network not available
|
|
|
+ }
|
|
|
+
|
|
|
+ Bundle parms = new Bundle();
|
|
|
+ parms.putString("module_name", "Location");
|
|
|
+ parms.putString("action_type", "search");
|
|
|
+ // parms.putString("id", id+"");
|
|
|
+ parms.putString("limit", "999");
|
|
|
+ String jstr = getJson(OnlineDataProvider.URL_LOCATIONS, parms);
|
|
|
+ if (jstr == null || jstr.length() <= 0)
|
|
|
+ {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ JSONObject json = handleJson(jstr);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+// String user = ApexDriverApplication.sharedApplication().user;
|
|
|
+ String path=FileManager.internalStorageFileDir(TradeFilingApplication.get_instance().getApplicationContext())+ File.separator + "service_location.json";
|
|
|
+
|
|
|
+ if(json!=null&& json.optInt("result")!=RESULT_NET_ERROR&& json.optInt("result")!=RESULT_NET_NOTAVAILABLE)
|
|
|
+ {
|
|
|
+ FileManager.writeJson(jstr,path);
|
|
|
+// return jstr;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return jstr;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public static String get_announcements(String id, int limit)
|
|
|
+ {
|
|
|
+
|
|
|
+ if (!OnlineDataProvider.NetworkIsAvailable())
|
|
|
+ {
|
|
|
+ return null; // network not available
|
|
|
+ }
|
|
|
+
|
|
|
+ Bundle parms = new Bundle();
|
|
|
+ parms.putString("module_name", "Announcements");
|
|
|
+ parms.putString("action_type", "search");
|
|
|
+ parms.putString("id", id);
|
|
|
+ parms.putString("limit", limit + "");
|
|
|
+ String jstr = getJson(OnlineDataProvider.URL_ANNOUNCEMENTS, parms);
|
|
|
+ if (jstr == null || jstr.length() <= 0)
|
|
|
+ {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return jstr;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public static int change_pass(String oldpass, String newpass, String user)
|
|
|
+ {
|
|
|
+ String TAG = "net_dbg@change_pass";
|
|
|
+ Log.d(TAG, "old:" + oldpass + ";new:" + newpass);
|
|
|
+ if (!OnlineDataProvider.NetworkIsAvailable())
|
|
|
+ {
|
|
|
+ Log.d(TAG, "network not available!");
|
|
|
+ return OnlineDataProvider.RESULT_NET_NOTAVAILABLE; // network not available
|
|
|
+ }
|
|
|
+ Bundle parms = new Bundle();
|
|
|
+ parms.putString("user", user);
|
|
|
+ parms.putString("oldpass", oldpass);
|
|
|
+ parms.putString("newpass", newpass);
|
|
|
+ parms.putString("module_name", "Change Password");
|
|
|
+// parms.putString("sessionid", ApexTrackingApplication.get_sessionid());
|
|
|
+ parms.putString("action", "handset_search");
|
|
|
+ String jstr = getJson(OnlineDataProvider.URL_RETRIEVE_PASS, parms);
|
|
|
+ /*
|
|
|
+ * error occur while get authorization info from server. include can not
|
|
|
+ * reach server , wrong parms ,server get wrong , etc.
|
|
|
+ */
|
|
|
+ if (jstr == null || jstr.length() <= 0)
|
|
|
+ {
|
|
|
+ Log.d(TAG, "json is wrong");
|
|
|
+ return OnlineDataProvider.RESULT_NET_ERROR;
|
|
|
+ }
|
|
|
+ JSONObject jsobj;
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ jsobj = new JSONObject(jstr);
|
|
|
+ if (jsobj.length() > 0)
|
|
|
+ {
|
|
|
+ int iresult = jsobj.getInt("result");
|
|
|
+ if (iresult == OnlineDataProvider.AP_SESSION_EXPIRED)
|
|
|
+ {
|
|
|
+ Log.e(TAG, "AP_SESSION_EXPIRED");
|
|
|
+ OnlineDataProvider.get_Auth(user, oldpass);
|
|
|
+ jstr = getJson(OnlineDataProvider.URL_RETRIEVE_PASS, parms);
|
|
|
+ jsobj = new JSONObject(jstr);
|
|
|
+ iresult = jsobj.getInt("result");
|
|
|
+ }
|
|
|
+ if (iresult != OnlineDataProvider.AP_USER_AUTH)
|
|
|
+ {
|
|
|
+ // user not authorized return
|
|
|
+ Log.d(TAG,
|
|
|
+ "USER NOT AUTHORIZED CODE="
|
|
|
+ + jsobj.getInt("result"));
|
|
|
+ return RESULT_FALSE;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+
|
|
|
+ return RESULT_TRUE;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return RESULT_NET_ERROR;
|
|
|
+ }
|
|
|
+ catch (JSONException e)
|
|
|
+ {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ return RESULT_NET_ERROR;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static int retrieve_pass(String user, String email)
|
|
|
+ {
|
|
|
+ String TAG = "net_dbg@retrieve_pass";
|
|
|
+ Log.d(TAG, "u:" + user + ";e:" + email);
|
|
|
+ if (!OnlineDataProvider.NetworkIsAvailable())
|
|
|
+ {
|
|
|
+ Log.d(TAG, "network not available!");
|
|
|
+ return OnlineDataProvider.RESULT_NET_NOTAVAILABLE; // network not available
|
|
|
+ }
|
|
|
+ Bundle parms = new Bundle();
|
|
|
+ parms.putString("user", user);
|
|
|
+ parms.putString("email", email);
|
|
|
+ parms.putString("module_name", "Retrieve Password");
|
|
|
+ parms.putString("action", "handset_search");
|
|
|
+ String jstr = getJson(OnlineDataProvider.URL_RETRIEVE_PASS, parms);
|
|
|
+ /*
|
|
|
+ * error occur while get authorization info from server. include can not
|
|
|
+ * reach server , wrong parms ,server get wrong , etc.
|
|
|
+ */
|
|
|
+ if (jstr == null || jstr.length() <= 0)
|
|
|
+ {
|
|
|
+ Log.d(TAG, "json is wrong");
|
|
|
+ return OnlineDataProvider.RESULT_NET_ERROR;
|
|
|
+ }
|
|
|
+ JSONObject jsobj;
|
|
|
+
|
|
|
+ // array = new JSONArray(json);
|
|
|
+ try
|
|
|
+ {
|
|
|
+ jsobj = new JSONObject(jstr);
|
|
|
+ if (jsobj.length() > 0)
|
|
|
+ {
|
|
|
+ int iresult = jsobj.getInt("result");
|
|
|
+
|
|
|
+ if (iresult != OnlineDataProvider.AP_USER_AUTH)
|
|
|
+ {
|
|
|
+ // user not authorized return
|
|
|
+ Log.d(TAG,
|
|
|
+ "USER NOT AUTHORIZED CODE="
|
|
|
+ + jsobj.getInt("result"));
|
|
|
+ return RESULT_FALSE;
|
|
|
+ }
|
|
|
+ return RESULT_TRUE;
|
|
|
+
|
|
|
+ }
|
|
|
+ return RESULT_NET_ERROR;
|
|
|
+ }
|
|
|
+ catch (JSONException e)
|
|
|
+ {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ return RESULT_NET_ERROR;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void prepare_addtional_params(Bundle params) {
|
|
|
+ if (params == null) {
|
|
|
+ params = new Bundle();
|
|
|
+ }
|
|
|
+
|
|
|
+ String user = TradeFilingApplication.get_user();
|
|
|
+ if (user != null && params.getString("user") == null) {
|
|
|
+ params.putString("user",user);
|
|
|
+ }
|
|
|
+
|
|
|
+ String pwd = TradeFilingApplication.get_pass();
|
|
|
+ if (pwd != null && params.getString("pwd") == null) {
|
|
|
+ params.putString("pwd",pwd);
|
|
|
+ }
|
|
|
+
|
|
|
+ params.putString("os","Android");
|
|
|
+ params.putString("app_short_ver",SHORT_VER);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String getJson(String url, Bundle parms)
|
|
|
+ {
|
|
|
+ prepare_addtional_params(parms);
|
|
|
+ return com.usai.redant.rautils.utils.Network.getJson(url, parms, REQUEST_TIMEOUT);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static int get_recordcount(Bundle parms)
|
|
|
+ {
|
|
|
+ String TAG = "net_dbg@get_recordcount";
|
|
|
+
|
|
|
+ parms.putString("action", "handset_search_count");
|
|
|
+// parms.putString("sessionid", ApexTrackingApplication.get_sessionid());
|
|
|
+// Log.d(TAG, "sessionid=" + ApexTrackingApplication.get_sessionid());
|
|
|
+ String jstr = getJson(OnlineDataProvider.URL_REQUEST_COUNT, parms);
|
|
|
+ if (jstr == null || jstr.length() <= 0)
|
|
|
+ {
|
|
|
+ Log.d(TAG, "json is wrong");
|
|
|
+ return OnlineDataProvider.RESULT_NET_ERROR;
|
|
|
+ }
|
|
|
+ JSONObject jsobj;
|
|
|
+
|
|
|
+ // array = new JSONArray(json);
|
|
|
+ try
|
|
|
+ {
|
|
|
+ jsobj = new JSONObject(jstr);
|
|
|
+ if (jsobj.length() > 0)
|
|
|
+ {
|
|
|
+ int iresult = jsobj.getInt("result");
|
|
|
+ if (iresult == OnlineDataProvider.AP_SESSION_EXPIRED)
|
|
|
+ {
|
|
|
+ Log.e(TAG, "AP_SESSION_EXPIRED");
|
|
|
+ String user, pass;
|
|
|
+ user = TradeFilingApplication.get_user();
|
|
|
+ pass = TradeFilingApplication.get_pass();
|
|
|
+ OnlineDataProvider.get_Auth(user, pass);
|
|
|
+ jstr = getJson(OnlineDataProvider.URL_REQUEST_COUNT, parms);
|
|
|
+ jsobj = new JSONObject(jstr);
|
|
|
+ iresult = jsobj.getInt("result");
|
|
|
+ }
|
|
|
+ if (iresult != OnlineDataProvider.AP_USER_AUTH)
|
|
|
+ {
|
|
|
+ // session expired
|
|
|
+ Log.d(TAG,
|
|
|
+ "USER NOT AUTHORIZED CODE="
|
|
|
+ + jsobj.getInt("result"));
|
|
|
+ return RESULT_SESSION_EXPIRED;
|
|
|
+ // if (get_Auth(name, password) == RESULT_TRUE)
|
|
|
+ // {
|
|
|
+ // return get_recordcount(name, password, parms);
|
|
|
+ //
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ //
|
|
|
+ // Log.d(TAG,
|
|
|
+ // "USER NOT AUTHORIZED CODE="
|
|
|
+ // + jsobj.getInt("result"));
|
|
|
+ // return RESULT_SESSION_EXPIRED;
|
|
|
+ // }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ TradeFilingApplication.SetAuthorizeStatus(true);
|
|
|
+ return jsobj.getInt("count");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Log.d(TAG, "json is wrong");
|
|
|
+ return OnlineDataProvider.RESULT_NET_ERROR;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (JSONException e)
|
|
|
+ {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ return RESULT_ERROR;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String get_records(String name, String password, Bundle parms)
|
|
|
+ {
|
|
|
+ String TAG = "net_dbg@get_records";
|
|
|
+ // parms.putString("user", name);
|
|
|
+ // parms.putString("password", password);
|
|
|
+ // if (!Network.NetworkIsAvailable())
|
|
|
+ // {
|
|
|
+ // Log.d(TAG, "network not available!");
|
|
|
+ // return "Network.RESULT_NET_NOTAVAILABLE"; // network not available
|
|
|
+ // }
|
|
|
+ parms.putString("action", "handset_search");
|
|
|
+// parms.putString("sessionid", ApexTrackingApplication.get_sessionid());
|
|
|
+ String jstr = getJson(OnlineDataProvider.URL_REQUEST_RECORDS, parms);
|
|
|
+ if (jstr == null || jstr.length() <= 0)
|
|
|
+ {
|
|
|
+ Log.d(TAG, "json is wrong");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ JSONObject jsobj;
|
|
|
+ //
|
|
|
+ // array = new JSONArray(json);
|
|
|
+ try
|
|
|
+ {
|
|
|
+ jsobj = new JSONObject(jstr);
|
|
|
+ if (jsobj.length() > 0)
|
|
|
+ {
|
|
|
+ int iresult = jsobj.getInt("result");
|
|
|
+ if (iresult == OnlineDataProvider.AP_SESSION_EXPIRED)
|
|
|
+ {
|
|
|
+ Log.e(TAG, "AP_SESSION_EXPIRED");
|
|
|
+ String user, pass;
|
|
|
+ user = TradeFilingApplication.get_user();
|
|
|
+ pass = TradeFilingApplication.get_pass();
|
|
|
+ OnlineDataProvider.get_Auth(user, pass);
|
|
|
+ jstr = getJson(OnlineDataProvider.URL_REQUEST_RECORDS, parms);
|
|
|
+ jsobj = new JSONObject(jstr);
|
|
|
+ iresult = jsobj.getInt("result");
|
|
|
+ }
|
|
|
+ if (iresult != OnlineDataProvider.AP_USER_AUTH)
|
|
|
+ {
|
|
|
+ // session expired
|
|
|
+ Log.d(TAG,
|
|
|
+ "USER NOT AUTHORIZED CODE="
|
|
|
+ + jsobj.getInt("result"));
|
|
|
+ return null;
|
|
|
+ // if (get_Auth(name, password) == RESULT_TRUE)
|
|
|
+ // {
|
|
|
+ // return get_records(name, password, parms);
|
|
|
+ //
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ //
|
|
|
+ // Log.d(TAG,
|
|
|
+ // "USER NOT AUTHORIZED CODE="
|
|
|
+ // + jsobj.getInt("result"));
|
|
|
+ // return null;
|
|
|
+ // }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ TradeFilingApplication.SetAuthorizeStatus(true);
|
|
|
+ return jstr;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Log.d(TAG, "json is wrong");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (JSONException e)
|
|
|
+ {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+
|
|
|
+ // return RESULT_ERROR;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String get_push(String e_id, String s_id, int limit,
|
|
|
+ int offset)
|
|
|
+ {
|
|
|
+ String TAG = "net_dbg@get_push";
|
|
|
+ Bundle parms = new Bundle();
|
|
|
+ parms.putString("action", "handset_search");
|
|
|
+ parms.putString("e_id", e_id);
|
|
|
+ parms.putString("s_id", s_id);
|
|
|
+ parms.putString("limit", limit + "");
|
|
|
+ parms.putString("offset", offset + "");
|
|
|
+ parms.putString("action_type", "detail");
|
|
|
+ parms.putString("module_name", "Pull Message");
|
|
|
+ parms.putString("puid", RAUtil.getDeviceId(TradeFilingApplication.get_instance().getApplicationContext()));
|
|
|
+// String sessionid = ApexTrackingApplication.get_sessionid();
|
|
|
+ // if (TextUtils.isEmpty(sessionid))
|
|
|
+ // {
|
|
|
+ //
|
|
|
+ // Log.d(TAG, "no sessionid return!");
|
|
|
+ // return null;
|
|
|
+ //
|
|
|
+ // }
|
|
|
+ String user = TradeFilingApplication.get_user();
|
|
|
+ // if (TextUtils.isEmpty(user))
|
|
|
+ // {
|
|
|
+ //
|
|
|
+ // Log.d(TAG, "no user name return!");
|
|
|
+ // return null;
|
|
|
+ //
|
|
|
+ // }
|
|
|
+// parms.putString("sessionid", sessionid);
|
|
|
+ parms.putString("user", user);
|
|
|
+ // SQLiteDatabase db =
|
|
|
+ // dbUtil.OpenDB(ApexTrackingApplication.get_instance(), null, false);
|
|
|
+ // Cursor cursor = db.query("push_message", new String[] {"MAX(e_id)"},
|
|
|
+ // "user = '"+ApexTrackingApplication.get_user()+"'", null, null, null,
|
|
|
+ // null, null);
|
|
|
+ // if (cursor.moveToNext())
|
|
|
+ // {
|
|
|
+ // String maxid = cursor.getString(0);
|
|
|
+ // if(!TextUtils.isEmpty(maxid))
|
|
|
+ // parms.putString("id", maxid);
|
|
|
+ // }
|
|
|
+ // dbUtil.CloseCursor(cursor);
|
|
|
+ // dbUtil.CloseDB(db);
|
|
|
+
|
|
|
+ String jstr = getJson(OnlineDataProvider.URL_PUSH, parms);
|
|
|
+ if (jstr == null || jstr.length() <= 0)
|
|
|
+ {
|
|
|
+ Log.d(TAG, "json is wrong");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ JSONObject jsobj;
|
|
|
+ //
|
|
|
+ // array = new JSONArray(json);
|
|
|
+ try
|
|
|
+ {
|
|
|
+ jsobj = new JSONObject(jstr);
|
|
|
+ if (jsobj.length() > 0)
|
|
|
+ {
|
|
|
+ int iresult = jsobj.getInt("result");
|
|
|
+ if (iresult == OnlineDataProvider.AP_SESSION_EXPIRED)
|
|
|
+ {
|
|
|
+ Log.e(TAG, "AP_SESSION_EXPIRED");
|
|
|
+ String pass;
|
|
|
+
|
|
|
+ pass = TradeFilingApplication.get_pass();
|
|
|
+ OnlineDataProvider.get_Auth(user, pass);
|
|
|
+ jstr = getJson(OnlineDataProvider.URL_REQUEST_RECORDS, parms);
|
|
|
+ jsobj = new JSONObject(jstr);
|
|
|
+ iresult = jsobj.getInt("result");
|
|
|
+ }
|
|
|
+ if (iresult != OnlineDataProvider.AP_MESSAGE_NEW)
|
|
|
+ {
|
|
|
+ // session expired
|
|
|
+ Log.d(TAG,
|
|
|
+ "DOSE NOT GET NEW MESSAGE CODE="
|
|
|
+ + jsobj.getInt("result"));
|
|
|
+ return null;
|
|
|
+ // if (get_Auth(name, password) == RESULT_TRUE)
|
|
|
+ // {
|
|
|
+ // return get_records(name, password, parms);
|
|
|
+ //
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ //
|
|
|
+ // Log.d(TAG,
|
|
|
+ // "USER NOT AUTHORIZED CODE="
|
|
|
+ // + jsobj.getInt("result"));
|
|
|
+ // return null;
|
|
|
+ // }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return jstr;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Log.d(TAG, "json is wrong");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (JSONException e)
|
|
|
+ {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+
|
|
|
+ // return RESULT_ERROR;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String check_push()
|
|
|
+ {
|
|
|
+ if(true)
|
|
|
+ return null;
|
|
|
+ String TAG = "net_dbg@check_push";
|
|
|
+ Bundle parms = new Bundle();
|
|
|
+ parms.putString("action", "handset_search");
|
|
|
+ parms.putString("module_name", "Pull Message");
|
|
|
+ parms.putString("puid", RAUtil.getDeviceId(TradeFilingApplication.get_instance().getApplicationContext()));
|
|
|
+// String sessionid = ApexTrackingApplication.get_sessionid();
|
|
|
+ // if (TextUtils.isEmpty(sessionid))
|
|
|
+ // {
|
|
|
+ //
|
|
|
+ // Log.d(TAG, "no sessionid return!");
|
|
|
+ // return null;
|
|
|
+ //
|
|
|
+ // }
|
|
|
+ String user = TradeFilingApplication.get_user();
|
|
|
+ if (TextUtils.isEmpty(user))
|
|
|
+ {
|
|
|
+
|
|
|
+ Log.d(TAG, "no user name return!");
|
|
|
+ return null;
|
|
|
+
|
|
|
+ }
|
|
|
+ // parms.putString("sessionid", sessionid);
|
|
|
+ parms.putString("user", user);
|
|
|
+
|
|
|
+ if(true)
|
|
|
+ throw new AssertionError("OnlinedataProvider::check_push not impl");
|
|
|
+// SQLiteDatabase db = dbUtil.OpenDB(
|
|
|
+// TradeFilingApplication.get_instance(), null, false);
|
|
|
+// Cursor cursor = db.query("push_message", new String[] { "MAX(e_id)" },
|
|
|
+// "user = '" + TradeFilingApplication.get_user() + "'", null,
|
|
|
+// null, null, null, null);
|
|
|
+// if (cursor.moveToNext())
|
|
|
+// {
|
|
|
+// String maxid = cursor.getString(0);
|
|
|
+// if (!TextUtils.isEmpty(maxid))
|
|
|
+// parms.putString("id", maxid);
|
|
|
+// }
|
|
|
+// dbUtil.CloseCursor(cursor);
|
|
|
+// dbUtil.CloseDB(db);
|
|
|
+
|
|
|
+ String jstr = getJson(OnlineDataProvider.URL_PUSH, parms);
|
|
|
+ if (jstr == null || jstr.length() <= 0)
|
|
|
+ {
|
|
|
+ Log.d(TAG, "json is wrong");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ JSONObject jsobj;
|
|
|
+ //
|
|
|
+ // array = new JSONArray(json);
|
|
|
+ try
|
|
|
+ {
|
|
|
+ jsobj = new JSONObject(jstr);
|
|
|
+ if (jsobj.length() > 0)
|
|
|
+ {
|
|
|
+ int iresult = jsobj.getInt("result");
|
|
|
+ if (iresult == OnlineDataProvider.AP_SESSION_EXPIRED)
|
|
|
+ {
|
|
|
+ Log.e(TAG, "AP_SESSION_EXPIRED");
|
|
|
+ String pass;
|
|
|
+
|
|
|
+ pass = TradeFilingApplication.get_pass();
|
|
|
+ OnlineDataProvider.get_Auth(user, pass);
|
|
|
+ jstr = getJson(OnlineDataProvider.URL_PUSH, parms);
|
|
|
+ jsobj = new JSONObject(jstr);
|
|
|
+ iresult = jsobj.getInt("result");
|
|
|
+ }
|
|
|
+ if (iresult != OnlineDataProvider.AP_MESSAGE_NEW)
|
|
|
+ {
|
|
|
+ // session expired
|
|
|
+ Log.d(TAG,
|
|
|
+ "DOSE NOT GET NEW MESSAGE CODE="
|
|
|
+ + jsobj.getInt("result"));
|
|
|
+ return null;
|
|
|
+ // if (get_Auth(name, password) == RESULT_TRUE)
|
|
|
+ // {
|
|
|
+ // return get_records(name, password, parms);
|
|
|
+ //
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ //
|
|
|
+ // Log.d(TAG,
|
|
|
+ // "USER NOT AUTHORIZED CODE="
|
|
|
+ // + jsobj.getInt("result"));
|
|
|
+ // return null;
|
|
|
+ // }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return jstr;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Log.d(TAG, "json is wrong");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (JSONException e)
|
|
|
+ {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+
|
|
|
+ // return RESULT_ERROR;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String get_detail(Bundle parms)
|
|
|
+ {
|
|
|
+ String TAG = "net_dbg@get_detail";
|
|
|
+ parms.putString("action", "handset_search");
|
|
|
+
|
|
|
+ String actionType = parms.getString("action_type");
|
|
|
+ if (actionType != null && actionType.equals("Detail")) {
|
|
|
+ parms.putBoolean("request_communication",true);
|
|
|
+ } else if(actionType != null && (actionType.equals("Tracing") || actionType.equals("Tracking"))) {
|
|
|
+ parms.putBoolean("request_location",true);
|
|
|
+ }
|
|
|
+
|
|
|
+// parms.putString("sessionid", ApexTrackingApplication.get_sessionid());
|
|
|
+ String jstr = getJson(OnlineDataProvider.URL_REQUEST_RECORDS, parms);
|
|
|
+ if (jstr == null || jstr.length() <= 0)
|
|
|
+ {
|
|
|
+ Log.d(TAG, "json is wrong");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ JSONObject jsobj;
|
|
|
+ //
|
|
|
+ // array = new JSONArray(json);
|
|
|
+ try
|
|
|
+ {
|
|
|
+ jsobj = new JSONObject(jstr);
|
|
|
+ if (jsobj.length() > 0)
|
|
|
+ {
|
|
|
+ int iresult = jsobj.getInt("result");
|
|
|
+ if (iresult == OnlineDataProvider.AP_SESSION_EXPIRED)
|
|
|
+ {
|
|
|
+ Log.e(TAG, "AP_SESSION_EXPIRED");
|
|
|
+ String user, pass;
|
|
|
+ user = TradeFilingApplication.get_user();
|
|
|
+ pass = TradeFilingApplication.get_pass();
|
|
|
+ OnlineDataProvider.get_Auth(user, pass);
|
|
|
+ jstr = getJson(OnlineDataProvider.URL_REQUEST_RECORDS, parms);
|
|
|
+ jsobj = new JSONObject(jstr);
|
|
|
+ iresult = jsobj.getInt("result");
|
|
|
+ }
|
|
|
+ if (iresult != OnlineDataProvider.AP_USER_AUTH)
|
|
|
+ {
|
|
|
+ // session expired
|
|
|
+ Log.d(TAG,
|
|
|
+ "USER NOT AUTHORIZED CODE="
|
|
|
+ + jsobj.getInt("result"));
|
|
|
+ return null;
|
|
|
+ // if (get_Auth(name, password) == RESULT_TRUE)
|
|
|
+ // {
|
|
|
+ // return get_records(name, password, parms);
|
|
|
+ //
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ //
|
|
|
+ // Log.d(TAG,
|
|
|
+ // "USER NOT AUTHORIZED CODE="
|
|
|
+ // + jsobj.getInt("result"));
|
|
|
+ // return null;
|
|
|
+ // }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ TradeFilingApplication.SetAuthorizeStatus(true);
|
|
|
+ return jstr;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Log.d(TAG, "json is wrong");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (JSONException e)
|
|
|
+ {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+
|
|
|
+ // return RESULT_ERROR;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static int get_Auth(String name, String password)
|
|
|
+ {
|
|
|
+
|
|
|
+ String TAG = "net_dbg@get_Auth";
|
|
|
+// Log.d(TAG, "u:" + name + ";p:" + password);
|
|
|
+ if (!OnlineDataProvider.NetworkIsAvailable())
|
|
|
+ {
|
|
|
+ Log.d(TAG, "network not available!");
|
|
|
+ return OnlineDataProvider.RESULT_NET_NOTAVAILABLE; // network not available
|
|
|
+ }
|
|
|
+ Bundle parms = new Bundle();
|
|
|
+ parms.putString("user", name);
|
|
|
+ parms.putString("password", password);
|
|
|
+ parms.putString("action", "handset_login");
|
|
|
+ int ver = TradeFilingApplication
|
|
|
+ .get_instance()
|
|
|
+ .getSharedPreferences(name + "_Apex_auth", Context.MODE_PRIVATE)
|
|
|
+ .getInt("AuthInfoVer", 0);
|
|
|
+ parms.putString("auth_ver", ver + "");
|
|
|
+ String jstr = getJson(OnlineDataProvider.URL_UPDATE_AUTH, parms);
|
|
|
+ /*
|
|
|
+ * error occur while get authorization info from server. include can not
|
|
|
+ * reach server , wrong parms ,server get wrong , etc.
|
|
|
+ */
|
|
|
+ if (jstr == null || jstr.length() <= 0)
|
|
|
+ {
|
|
|
+ Log.d(TAG, "json is wrong");
|
|
|
+ return OnlineDataProvider.RESULT_NET_ERROR;
|
|
|
+ }
|
|
|
+
|
|
|
+ return parse_authinfo(jstr, name, password, parms);
|
|
|
+ }
|
|
|
+
|
|
|
+ private static int parse_authinfo(String json, String user, String pass, Bundle parms)
|
|
|
+ {
|
|
|
+ if(true)
|
|
|
+ throw new AssertionError("OnlineDataProvider::parse_authinfo not impl");
|
|
|
+ String TAG = "net_dbg@parse_authinfo";
|
|
|
+ Log.d(TAG, json);
|
|
|
+ // JSONArray array;
|
|
|
+ JSONObject jsobj;
|
|
|
+ SQLiteDatabase db = null;
|
|
|
+ try
|
|
|
+
|
|
|
+ {
|
|
|
+
|
|
|
+ // array = new JSONArray(json);
|
|
|
+ jsobj = new JSONObject(json);
|
|
|
+ if (jsobj.length() > 0)
|
|
|
+ {
|
|
|
+ // JSONObject objresult = jsobj.get.getJSONObject(0);// result
|
|
|
+ // the
|
|
|
+ // server result
|
|
|
+ // ;
|
|
|
+ if (jsobj.getInt("result") != OnlineDataProvider.AP_USER_AUTH)
|
|
|
+ {
|
|
|
+ TradeFilingApplication.logout();
|
|
|
+ // user not authorized return
|
|
|
+ Log.d(TAG,
|
|
|
+ "USER NOT AUTHORIZED CODE="
|
|
|
+ + jsobj.getInt("result"));
|
|
|
+ return RESULT_FALSE;
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject objheader = jsobj.getJSONObject("header");
|
|
|
+ String required_ver = objheader.getString("client_ver");
|
|
|
+ //String ver = objheader.getString("ver");
|
|
|
+ String current_ver = TradeFilingApplication.get_instance()
|
|
|
+ .getPackageManager().getPackageInfo("com.usai.apex", 0).versionName;
|
|
|
+ if (current_ver.compareTo(required_ver) < 0)
|
|
|
+ return RESULT_VER_LOW;
|
|
|
+ // JSONObject objsessionid = jsobj.getJSONObject(1); // session
|
|
|
+ // id
|
|
|
+ // on
|
|
|
+ // server;
|
|
|
+ // ApexTrackingApplication.put_sessionid(objheader
|
|
|
+ // .getString("sessionid"));
|
|
|
+ // ApexTrackingApplication.put_user(user);
|
|
|
+ // ApexTrackingApplication.put_password(pass);
|
|
|
+ // ApexTrackingApplication.put_authorization(true);
|
|
|
+ TradeFilingApplication.login(
|
|
|
+ user, pass,jsobj);
|
|
|
+// Log.d(TAG, "sessionid=" + objheader.getString("sessionid"));
|
|
|
+ // JSONObject objupdate = array.getJSONObject(3); // whether
|
|
|
+ // need
|
|
|
+ // update ;
|
|
|
+ if (objheader.getBoolean("update") == false)
|
|
|
+ {
|
|
|
+ // no update on the server;
|
|
|
+ return RESULT_TRUE;
|
|
|
+ }
|
|
|
+ // JSONObject objver = array.getJSONObject(4); // new version
|
|
|
+ // get
|
|
|
+ // from server;
|
|
|
+
|
|
|
+ Editor editor = TradeFilingApplication
|
|
|
+ .get_instance()
|
|
|
+ .getSharedPreferences(user + "_Apex_auth",
|
|
|
+ Context.MODE_PRIVATE).edit();
|
|
|
+
|
|
|
+ editor.putInt("AuthInfoVer", objheader.getInt("ver"));
|
|
|
+ JSONObject objfuncs = jsobj.getJSONObject("functions");
|
|
|
+ Iterator<?> it = objfuncs.keys();
|
|
|
+// db = dbUtil.OpenDB(TradeFilingApplication.get_instance(),
|
|
|
+// null, true);
|
|
|
+// String sql = "insert into fields_info(name,aname,field_type,function_name,behavior,priority,show,user) values(?,?,?,?,?,?,?,?)";
|
|
|
+// String sql1 = "insert into actions_info(name,function_name,user,priority) values(?,?,?,?)";
|
|
|
+//
|
|
|
+// SQLiteStatement stat = db.compileStatement(sql);
|
|
|
+// SQLiteStatement stat1 = db.compileStatement(sql1);
|
|
|
+//
|
|
|
+// db.beginTransaction();
|
|
|
+// db.execSQL("update fields_info set abandon = 1 where user ='"
|
|
|
+// + user + "'");
|
|
|
+// db.execSQL("update actions_info set abandon = 1 where user ='"
|
|
|
+// + user + "'");
|
|
|
+//
|
|
|
+// String field_name, field_type, alias_name;
|
|
|
+// while (it.hasNext()) // loop for each function
|
|
|
+// {
|
|
|
+// String func_name = (String) it.next();
|
|
|
+//
|
|
|
+// // Set<String> funset = new HashSet<String>();
|
|
|
+// JSONObject objfun = objfuncs.getJSONObject(func_name);
|
|
|
+// int behavior, priority = 999;
|
|
|
+// int show = 1;
|
|
|
+// JSONObject objbehavior = objfun.getJSONObject("search");
|
|
|
+// Iterator<?> itbehavior = objbehavior.keys();
|
|
|
+// behavior = BEHAVIOR_SEARCH;
|
|
|
+// while (itbehavior.hasNext()) // loop for search fields in
|
|
|
+// // certain function
|
|
|
+// {
|
|
|
+// String field = (String) itbehavior.next();
|
|
|
+// JSONObject field_info = objbehavior
|
|
|
+// .getJSONObject(field);
|
|
|
+// field_name = field_info.getString("name");
|
|
|
+// field_type = field_info.getString("type");
|
|
|
+// alias_name = field_info.getString("alias");
|
|
|
+// priority = field_info.getInt("priority");
|
|
|
+// if (priority == 999)
|
|
|
+// show = 0;
|
|
|
+// else
|
|
|
+// show = 1;
|
|
|
+// int id = dbUtil.get_recordid(db, "fields_info",
|
|
|
+// "name='" + field_name + "' and behavior="
|
|
|
+// + behavior + " and function_name='"
|
|
|
+// + func_name + "' and user='" + user
|
|
|
+// + "'");
|
|
|
+// if (id >= 0) // record exist;
|
|
|
+// {
|
|
|
+// db.execSQL("update fields_info set abandon = 0 where _id ="
|
|
|
+// + id);
|
|
|
+// }
|
|
|
+// else
|
|
|
+// {
|
|
|
+// stat.bindString(1, field_name);
|
|
|
+// stat.bindString(2, alias_name);
|
|
|
+// stat.bindString(3, field_type);
|
|
|
+// stat.bindString(4, func_name);
|
|
|
+// stat.bindLong(5, behavior);
|
|
|
+// stat.bindLong(6, priority);
|
|
|
+// stat.bindLong(7, show);
|
|
|
+// stat.bindString(8, user);
|
|
|
+// stat.executeInsert();
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// objbehavior = objfun.getJSONObject("result");
|
|
|
+// Iterator<?> itresult = objbehavior.keys();
|
|
|
+// behavior = BEHAVIOR_RESULT;
|
|
|
+// while (itresult.hasNext()) // loop for result fields in
|
|
|
+// // certain function
|
|
|
+// {
|
|
|
+// String field = (String) itresult.next();
|
|
|
+// JSONObject field_info = objbehavior
|
|
|
+// .getJSONObject(field);
|
|
|
+// field_name = field_info.getString("name");
|
|
|
+// field_type = field_info.getString("type");
|
|
|
+// alias_name = field_info.getString("alias");
|
|
|
+// priority = field_info.getInt("priority");
|
|
|
+// if (priority == 999)
|
|
|
+// show = 0;
|
|
|
+// else
|
|
|
+// show = 1;
|
|
|
+// int id = dbUtil.get_recordid(db, "fields_info",
|
|
|
+// "name='" + field_name + "' and behavior="
|
|
|
+// + behavior + " and function_name='"
|
|
|
+// + func_name + "' and user='" + user
|
|
|
+// + "'");
|
|
|
+// if (id >= 0) // record exist;
|
|
|
+// {
|
|
|
+// db.execSQL("update fields_info set abandon = 0 where _id ="
|
|
|
+// + id);
|
|
|
+// }
|
|
|
+// else
|
|
|
+// {
|
|
|
+// stat.bindString(1, field_name);
|
|
|
+// stat.bindString(2, alias_name);
|
|
|
+// stat.bindString(3, field_type);
|
|
|
+// stat.bindString(4, func_name);
|
|
|
+// stat.bindLong(5, behavior);
|
|
|
+// stat.bindLong(6, priority);
|
|
|
+// stat.bindLong(7, show);
|
|
|
+// stat.bindString(8, user);
|
|
|
+// stat.executeInsert();
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// // objfun.has("actions")
|
|
|
+// objbehavior = objfun.getJSONObject("actions");
|
|
|
+// Iterator<?> itactions = objbehavior.keys();
|
|
|
+// // behavior = BEHAVIOR_RESULT;
|
|
|
+// while (itactions.hasNext()) // loop for result fields in
|
|
|
+// // certain function
|
|
|
+// {
|
|
|
+// String actionname = (String) itactions.next();
|
|
|
+// int action_priority = objbehavior.getInt(actionname);
|
|
|
+//
|
|
|
+// int id = dbUtil.get_recordid(db, "actions_info",
|
|
|
+// "name='" + actionname + "' and function_name='"
|
|
|
+// + func_name + "' and user='" + user
|
|
|
+// + "'");
|
|
|
+// if (id >= 0) // record exist;
|
|
|
+// {
|
|
|
+// db.execSQL("update actions_info set abandon = 0 , priority="
|
|
|
+// + action_priority + " where _id =" + id);
|
|
|
+// }
|
|
|
+// else
|
|
|
+// {
|
|
|
+// stat1.bindString(1, actionname);
|
|
|
+// stat1.bindString(2, func_name);
|
|
|
+// stat1.bindString(3, user);
|
|
|
+// stat1.bindLong(4, action_priority);
|
|
|
+// stat1.executeInsert();
|
|
|
+//
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// db.execSQL("delete from fields_info where abandon = 1");
|
|
|
+// db.execSQL("delete from actions_info where abandon = 1");
|
|
|
+// db.setTransactionSuccessful();
|
|
|
+// db.endTransaction();
|
|
|
+// editor.commit();
|
|
|
+//
|
|
|
+// // 删除Result固定显示字段 及 更新显示最多三条
|
|
|
+// dbUtil.deleteResultFields(db);
|
|
|
+// dbUtil.updateResultDisplayFields(db);
|
|
|
+
|
|
|
+ return RESULT_TRUE;
|
|
|
+ }
|
|
|
+ Log.d(TAG, "json is wrong");
|
|
|
+ return RESULT_USERAUTH_ERROR;
|
|
|
+ }
|
|
|
+ catch (JSONException e1)
|
|
|
+ {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ TradeFilingApplication.logout();
|
|
|
+
|
|
|
+
|
|
|
+ parms.putString("module_name", "Log");
|
|
|
+ parms.putString("action_type", "save");
|
|
|
+ parms.putString("return", json);
|
|
|
+
|
|
|
+ String jstr = getJson(OnlineDataProvider.URL_LOG, parms);
|
|
|
+
|
|
|
+ e1.printStackTrace();
|
|
|
+ Log.d(TAG, "json is wrong");
|
|
|
+ }
|
|
|
+ catch (NameNotFoundException e)
|
|
|
+ {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+
|
|
|
+ TradeFilingApplication.logout();
|
|
|
+
|
|
|
+
|
|
|
+ parms.putString("module_name", "Log");
|
|
|
+ parms.putString("action_type", "save");
|
|
|
+ parms.putString("return", json);
|
|
|
+ String jstr = getJson(OnlineDataProvider.URL_LOG, parms);
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ finally
|
|
|
+ {
|
|
|
+// dbUtil.CloseDB(db);
|
|
|
+ }
|
|
|
+
|
|
|
+ // try
|
|
|
+ // {
|
|
|
+ // m_RemoteVerCode = Integer
|
|
|
+ // .parseInt(obj.getString("verCode"));
|
|
|
+ // m_RemoteVerName = obj.getString("verName");
|
|
|
+ // m_NewVerUrl = obj.getString("URL");
|
|
|
+ // }
|
|
|
+ // catch (Exception e)
|
|
|
+ // {
|
|
|
+ // m_RemoteVerCode = -1;
|
|
|
+ // m_RemoteVerName = "";
|
|
|
+ // m_NewVerUrl = "";
|
|
|
+ // dbgUtil.Log(Log.INFO,TAG, "download failed json file wrong!");
|
|
|
+ // return false;
|
|
|
+ // }
|
|
|
+ Log.d(TAG, "json is wrong");
|
|
|
+ return RESULT_USERAUTH_ERROR;
|
|
|
+ }
|
|
|
+
|
|
|
+ // private void writeData(JSONObject allData)
|
|
|
+ // {
|
|
|
+ //
|
|
|
+ // File file = new File(Environment.getExternalStorageDirectory()
|
|
|
+ // .toString() + File.separator + "live.txt");
|
|
|
+ // if (!file.exists())
|
|
|
+ // {
|
|
|
+ // try
|
|
|
+ // {
|
|
|
+ // file.createNewFile();
|
|
|
+ // }
|
|
|
+ // catch (IOException e)
|
|
|
+ // {
|
|
|
+ // e.printStackTrace();
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // FileOutputStream fos;
|
|
|
+ // OutputStreamWriter osw = null;
|
|
|
+ // try
|
|
|
+ // {
|
|
|
+ // fos = new FileOutputStream(file);
|
|
|
+ //
|
|
|
+ // osw = new OutputStreamWriter(fos, "UTF-8");
|
|
|
+ // osw.write(allData.toString());
|
|
|
+ // osw.flush();
|
|
|
+ // }
|
|
|
+ // catch (FileNotFoundException e)
|
|
|
+ // {
|
|
|
+ // e.printStackTrace();
|
|
|
+ // }
|
|
|
+ // catch (UnsupportedEncodingException e)
|
|
|
+ // {
|
|
|
+ // e.printStackTrace();
|
|
|
+ // }
|
|
|
+ // catch (IOException e)
|
|
|
+ // {
|
|
|
+ // e.printStackTrace();
|
|
|
+ // }
|
|
|
+ // finally
|
|
|
+ // {
|
|
|
+ // if (osw != null)
|
|
|
+ // {
|
|
|
+ // try
|
|
|
+ // {
|
|
|
+ // osw.close();
|
|
|
+ // }
|
|
|
+ // catch (IOException e)
|
|
|
+ // {
|
|
|
+ // e.printStackTrace();
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+ public static boolean NetworkIsAvailable()// Context context)
|
|
|
+ {
|
|
|
+ return com.usai.redant.rautils.utils.Network.isNetworkAvailable(TradeFilingApplication.get_instance());
|
|
|
+ }
|
|
|
+
|
|
|
+// public static class SSLSocketFactoryEx extends SSLSocketFactory
|
|
|
+// {
|
|
|
+//
|
|
|
+// SSLContext sslContext = SSLContext.getInstance("TLS");
|
|
|
+//
|
|
|
+// public SSLSocketFactoryEx(KeyStore truststore)
|
|
|
+// throws NoSuchAlgorithmException, KeyManagementException,
|
|
|
+// KeyStoreException, UnrecoverableKeyException
|
|
|
+// {
|
|
|
+// super(truststore);
|
|
|
+//
|
|
|
+// TrustManager tm = new X509TrustManager()
|
|
|
+// {
|
|
|
+// public java.security.cert.X509Certificate[] getAcceptedIssuers()
|
|
|
+// {
|
|
|
+// return null;
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Override
|
|
|
+// public void checkClientTrusted(
|
|
|
+// java.security.cert.X509Certificate[] chain,
|
|
|
+// String authType)
|
|
|
+// throws java.security.cert.CertificateException
|
|
|
+// {
|
|
|
+// }
|
|
|
+//
|
|
|
+//// @Override
|
|
|
+//// public void checkServerTrusted(
|
|
|
+//// java.security.cert.X509Certificate[] chain,
|
|
|
+//// String authType)
|
|
|
+//// throws java.security.cert.CertificateException
|
|
|
+//// {
|
|
|
+//// }
|
|
|
+//// @Override
|
|
|
+//// public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) throws java.security.cert.CertificateException {
|
|
|
+//// try {
|
|
|
+//// chain[0].checkValidity();
|
|
|
+//// } catch (java.security.cert.CertificateExpiredException e) {
|
|
|
+//// // Logger.e(TAG, "CertificateExpiredException");
|
|
|
+//// throw new java.security.cert.CertificateException("CertificateExpiredException");
|
|
|
+//// } catch (java.security.cert.CertificateNotYetValidException e) {
|
|
|
+//// //Logger.e(TAG, "CertificateNotYetValidException");
|
|
|
+//// throw new java.security.cert.CertificateException("CertificateNotYetValidException");
|
|
|
+//// }
|
|
|
+//// }@Override
|
|
|
+//// public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) throws java.security.cert.CertificateException {
|
|
|
+//// try {
|
|
|
+//// chain[0].checkValidity();
|
|
|
+//// } catch (java.security.cert.CertificateExpiredException e) {
|
|
|
+//// // Logger.e(TAG, "CertificateExpiredException");
|
|
|
+//// throw new java.security.cert.CertificateException("CertificateExpiredException");
|
|
|
+//// } catch (java.security.cert.CertificateNotYetValidException e) {
|
|
|
+//// //Logger.e(TAG, "CertificateNotYetValidException");
|
|
|
+//// throw new java.security.cert.CertificateException("CertificateNotYetValidException");
|
|
|
+//// }
|
|
|
+//// }
|
|
|
+// };
|
|
|
+// sslContext.init(null, new TrustManager[] { tm }, null);
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Override
|
|
|
+// public Socket createSocket(Socket socket, String host, int port,
|
|
|
+// boolean autoClose) throws IOException, UnknownHostException
|
|
|
+// {
|
|
|
+// return sslContext.getSocketFactory().createSocket(socket, host,
|
|
|
+// port, autoClose);
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Override
|
|
|
+// public Socket createSocket() throws IOException
|
|
|
+// {
|
|
|
+// return sslContext.getSocketFactory().createSocket();
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+ public static class SSLSocketFactoryEx extends SSLSocketFactory
|
|
|
+ {
|
|
|
+
|
|
|
+ SSLContext sslContext = SSLContext.getInstance("TLS");
|
|
|
+
|
|
|
+ public SSLSocketFactoryEx(KeyStore truststore)
|
|
|
+ throws NoSuchAlgorithmException, KeyManagementException,
|
|
|
+ KeyStoreException, UnrecoverableKeyException
|
|
|
+ {
|
|
|
+ super(truststore);
|
|
|
+
|
|
|
+ TrustManager tm = new X509TrustManager()
|
|
|
+ {
|
|
|
+ public java.security.cert.X509Certificate[] getAcceptedIssuers()
|
|
|
+ {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void checkClientTrusted(
|
|
|
+ java.security.cert.X509Certificate[] chain,
|
|
|
+ String authType)
|
|
|
+ throws java.security.cert.CertificateException
|
|
|
+ {
|
|
|
+ }
|
|
|
+
|
|
|
+ // @Override
|
|
|
+// public void checkServerTrusted(
|
|
|
+// java.security.cert.X509Certificate[] chain,
|
|
|
+// String authType)
|
|
|
+// throws java.security.cert.CertificateException
|
|
|
+// {
|
|
|
+// }
|
|
|
+ @Override
|
|
|
+ public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) throws java.security.cert.CertificateException {
|
|
|
+ try {
|
|
|
+ chain[0].checkValidity();
|
|
|
+ } catch (java.security.cert.CertificateExpiredException e) {
|
|
|
+ // Logger.e(TAG, "CertificateExpiredException");
|
|
|
+ throw new java.security.cert.CertificateException("CertificateExpiredException");
|
|
|
+ } catch (java.security.cert.CertificateNotYetValidException e) {
|
|
|
+ //Logger.e(TAG, "CertificateNotYetValidException");
|
|
|
+ throw new java.security.cert.CertificateException("CertificateNotYetValidException");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ sslContext.init(null, new TrustManager[] { tm }, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Socket createSocket(Socket socket, String host, int port,
|
|
|
+ boolean autoClose) throws IOException, UnknownHostException
|
|
|
+ {
|
|
|
+ return sslContext.getSocketFactory().createSocket(socket, host,
|
|
|
+ port, autoClose);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Socket createSocket() throws IOException
|
|
|
+ {
|
|
|
+ return sslContext.getSocketFactory().createSocket();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static File downloadFile(Bundle params, String download_url,String dir) {
|
|
|
+ prepare_addtional_params(params);
|
|
|
+ return com.usai.redant.rautils.utils.Network.downloadFile(params, download_url, dir);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static File download_query(String download_url,String path) {
|
|
|
+
|
|
|
+ return downloadFile(null,download_url,path);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static JSONObject query(Bundle params) {
|
|
|
+
|
|
|
+ params.putString("action","handset_search");
|
|
|
+
|
|
|
+ String jstr = getJson(OnlineDataProvider.URL_REQUEST_COUNT, params);
|
|
|
+ try {
|
|
|
+
|
|
|
+ if (jstr == null || jstr.length() <= 0)
|
|
|
+ {
|
|
|
+ JSONObject resultJson = new JSONObject();
|
|
|
+ resultJson.put("err_msg","Net Error. Cannot connect to server for now. Please retry later.");
|
|
|
+ resultJson.put("result",RESULT_NET_ERROR);
|
|
|
+ return resultJson;
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject jsobj = new JSONObject(jstr);
|
|
|
+ return jsobj;
|
|
|
+
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static JSONObject request_result(Bundle params)
|
|
|
+ {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ public static JSONObject request_home() {
|
|
|
+
|
|
|
+ Bundle params = new Bundle();
|
|
|
+ params.putString("action","hand_new_home_list");
|
|
|
+ params.putBoolean("request_location",true);
|
|
|
+ boolean personMode = TradeFilingApplication.get_instance().getPersonMode();
|
|
|
+ if (personMode) {
|
|
|
+ params.putString("personal_mode","true");
|
|
|
+ } else {
|
|
|
+ params.putString("personal_mode","false");
|
|
|
+ }
|
|
|
+
|
|
|
+ String jstr = getJson(URL_HOME,params);
|
|
|
+ Log.d("Network", "request_home: " + jstr);
|
|
|
+ try {
|
|
|
+
|
|
|
+ if (jstr == null || jstr.length() <= 0)
|
|
|
+ {
|
|
|
+ JSONObject resultJson = new JSONObject();
|
|
|
+ resultJson.put("err_msg","Net Error. Cannot connect to server for now. Please retry later.");
|
|
|
+ resultJson.put("result",RESULT_NET_ERROR);
|
|
|
+ return resultJson;
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject jsobj = new JSONObject(jstr);
|
|
|
+ return jsobj;
|
|
|
+
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static JSONObject request_KPI() {
|
|
|
+
|
|
|
+ Bundle params = new Bundle();
|
|
|
+ params.putString("action","hand_new_kpi");
|
|
|
+
|
|
|
+ boolean personMode = TradeFilingApplication.get_instance().getPersonMode();
|
|
|
+ if (personMode) {
|
|
|
+ params.putString("personal_mode","true");
|
|
|
+ } else {
|
|
|
+ params.putString("personal_mode","false");
|
|
|
+ }
|
|
|
+
|
|
|
+ String jstr = getJson(URL_KPI,params);
|
|
|
+ Log.d("Network", "request_kpi: " + jstr);
|
|
|
+ try {
|
|
|
+
|
|
|
+ if (jstr == null || jstr.length() <= 0)
|
|
|
+ {
|
|
|
+ JSONObject resultJson = new JSONObject();
|
|
|
+ resultJson.put("err_msg","Net Error. Cannot connect to server for now. Please retry later.");
|
|
|
+ resultJson.put("result",RESULT_NET_ERROR);
|
|
|
+ return resultJson;
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject jsobj = new JSONObject(jstr);
|
|
|
+ return jsobj;
|
|
|
+
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static JSONObject request_history(Bundle params) {
|
|
|
+
|
|
|
+ if (params == null) {
|
|
|
+ params = new Bundle();
|
|
|
+ }
|
|
|
+ params.putString("action","hand_new_home_list_all");
|
|
|
+
|
|
|
+ boolean personMode = TradeFilingApplication.get_instance().getPersonMode();
|
|
|
+ if (personMode) {
|
|
|
+ params.putString("personal_mode","true");
|
|
|
+ } else {
|
|
|
+ params.putString("personal_mode","false");
|
|
|
+ }
|
|
|
+
|
|
|
+ String jstr = getJson(URL_HISTORY,params);
|
|
|
+ Log.d("Network", "request_home: " + jstr);
|
|
|
+ try {
|
|
|
+
|
|
|
+ if (jstr == null || jstr.length() <= 0)
|
|
|
+ {
|
|
|
+ JSONObject resultJson = new JSONObject();
|
|
|
+ resultJson.put("err_msg","Net Error. Cannot connect to server for now. Please retry later.");
|
|
|
+ resultJson.put("result",RESULT_NET_ERROR);
|
|
|
+ return resultJson;
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject jsobj = new JSONObject(jstr);
|
|
|
+ return jsobj;
|
|
|
+
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static JSONObject sendEmail(String email,String cc, String serialNo) {
|
|
|
+
|
|
|
+ Bundle params = new Bundle();
|
|
|
+ if (email == null) {
|
|
|
+ email = "";
|
|
|
+ }
|
|
|
+ if (serialNo == null) {
|
|
|
+ serialNo = "";
|
|
|
+ }
|
|
|
+
|
|
|
+ params.putString("msg",email);
|
|
|
+ params.putString("action","handset_search");
|
|
|
+ params.putString("action_type","save_communication_email");
|
|
|
+ params.putString("serial_no",serialNo);
|
|
|
+
|
|
|
+ if (cc != null) {
|
|
|
+ params.putString("cc",cc);
|
|
|
+ }
|
|
|
+ String jstr = getJson(URL_SEND_COMM_EMAIL,params);
|
|
|
+
|
|
|
+ return handleResponse(jstr);
|
|
|
+ }
|
|
|
+
|
|
|
+ private static JSONObject handleResponse(String jstr) {
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ if (jstr == null || jstr.length() <= 0)
|
|
|
+ {
|
|
|
+ JSONObject resultJson = new JSONObject();
|
|
|
+ resultJson.put("err_msg","Net Error. Cannot connect to server for now. Please retry later.");
|
|
|
+ resultJson.put("result",RESULT_NET_ERROR);
|
|
|
+ return resultJson;
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject jsobj = new JSONObject(jstr);
|
|
|
+ return jsobj;
|
|
|
+
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String checkUpdate(Context context) {
|
|
|
+
|
|
|
+ if (context == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ String ver_name = null;
|
|
|
+ int ver_code = -1;
|
|
|
+ try {
|
|
|
+ // ---get the package info---
|
|
|
+ PackageManager pm = context.getPackageManager();
|
|
|
+ PackageInfo pi = pm.getPackageInfo(context.getPackageName(), 0);
|
|
|
+ ver_name = pi.versionName;
|
|
|
+ ver_code = pi.versionCode;
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ Log.e("VersionInfo", "Exception", e);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ver_name == null || ver_name.length() <= 0) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ Bundle params = new Bundle();
|
|
|
+ params.putString("ver",ver_name);
|
|
|
+ params.putString("action","current_ver");
|
|
|
+
|
|
|
+ String jsonStr = getJson(URL_CHECK_UPDATE,params);
|
|
|
+
|
|
|
+// String jsonStr = "{\"ver\":\"2.2.1.180519\",\"url\":\"http://192.168.0.130/Apex Mobile.apk\"}";
|
|
|
+
|
|
|
+ return jsonStr;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static JSONObject uploadUserSql(String sql) {
|
|
|
+
|
|
|
+ Bundle params = new Bundle();
|
|
|
+
|
|
|
+ if (sql == null) {
|
|
|
+ sql = "";
|
|
|
+ }
|
|
|
+
|
|
|
+ params.putString("action","handset_search");
|
|
|
+ params.putString("sql",sql);
|
|
|
+
|
|
|
+ String jstr = getJson(URL_UPLOAD_SQL,params);
|
|
|
+
|
|
|
+ return handleResponse(jstr);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static JSONObject fetchResult(Bundle params) {
|
|
|
+
|
|
|
+ if(true)
|
|
|
+ throw new AssertionError("OnlinedataProvider::fetchResult not impl");
|
|
|
+ return null;
|
|
|
+//
|
|
|
+//
|
|
|
+// params.putString("action","handset_search");
|
|
|
+//
|
|
|
+// String module_name = params.getString("module_name");
|
|
|
+//
|
|
|
+//
|
|
|
+//// String url = "http://192.168.1.151:8080/MyWeb/SearchBooking";
|
|
|
+////
|
|
|
+//// if (module_name.equals("Ocean Booking")) {
|
|
|
+////
|
|
|
+//// } else if (module_name.equals("Ocean B/L info.")) {
|
|
|
+////
|
|
|
+//// url = "http://192.168.1.151:8080/MyWeb/SearchBL";
|
|
|
+//// } else if (module_name.equals("Container detail")) {
|
|
|
+////
|
|
|
+//// url = "http://192.168.1.151:8080/MyWeb/SearchContainer";
|
|
|
+//// } else if (module_name.equals("Download Document")) {
|
|
|
+////
|
|
|
+//// url = "http://192.168.1.151:8080/MyWeb/SearchDoc";
|
|
|
+//// }
|
|
|
+////
|
|
|
+//// try {
|
|
|
+//// Thread.sleep(2000);
|
|
|
+//// } catch (InterruptedException e) {
|
|
|
+//// e.printStackTrace();
|
|
|
+//// }
|
|
|
+//
|
|
|
+// String url = URL_FETCH_RESULT;
|
|
|
+// // URL_FETCH_RESULT
|
|
|
+// String jstr = getJson(url, params);
|
|
|
+//
|
|
|
+// JSONObject json = handleResponse(jstr);
|
|
|
+// if (json != null) {
|
|
|
+//
|
|
|
+// JSONArray actions = dbUtil.getActionsForFunction(module_name, TradeFilingApplication.get_user());
|
|
|
+// try {
|
|
|
+// json.put("actions", actions);
|
|
|
+// } catch (JSONException e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+// }
|
|
|
+// return json;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public static JSONObject saveSearchParametersForModuleWithName(String intentStr, String paramStr, String module, String name) {
|
|
|
+
|
|
|
+
|
|
|
+ if(true)
|
|
|
+ throw new AssertionError("OnlinedataProvider::saveSearchParametersForModuleWithName not impl");
|
|
|
+ return null;
|
|
|
+//
|
|
|
+// boolean success = true;
|
|
|
+// try {
|
|
|
+// SQLiteDatabase db = dbUtil.OpenDB(TradeFilingApplication.get_instance(), null, true);
|
|
|
+//
|
|
|
+// db.execSQL("insert into history(params,name,criterion,module_name,user,create_time) values('"
|
|
|
+// + intentStr
|
|
|
+// + "','"
|
|
|
+// + name
|
|
|
+// + "','"
|
|
|
+// + paramStr
|
|
|
+// + "','"
|
|
|
+// + module
|
|
|
+// + "','"
|
|
|
+// + TradeFilingApplication.get_user()
|
|
|
+// + "',"
|
|
|
+// + System.currentTimeMillis() + ")");
|
|
|
+// dbUtil.CloseDB(db);
|
|
|
+//
|
|
|
+// } catch (Exception e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// success = false;
|
|
|
+// }
|
|
|
+//
|
|
|
+// JSONObject json = new JSONObject();
|
|
|
+//
|
|
|
+// try {
|
|
|
+// if (success) {
|
|
|
+//
|
|
|
+// json.put("result", RESULT_TRUE);
|
|
|
+// json.put("err_msg", "save success.");
|
|
|
+//
|
|
|
+// } else {
|
|
|
+//
|
|
|
+// json.put("result", RESULT_FALSE);
|
|
|
+// json.put("err_msg", "Sorry, something is wrong.");
|
|
|
+// }
|
|
|
+// } catch (JSONException e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+//
|
|
|
+// return json;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String getDisplayFieldsForFunction(String function) {
|
|
|
+
|
|
|
+
|
|
|
+ if(true)
|
|
|
+ throw new AssertionError("OnlinedataProvider::getDisplayFieldsForFunction not impl");
|
|
|
+ return null;
|
|
|
+
|
|
|
+// String user = TradeFilingApplication.get_user();
|
|
|
+// return dbUtil.getDisplayFieldsForFunction(function, user);
|
|
|
+
|
|
|
+ }
|
|
|
+}
|