/** After completing background task Dismiss the progress dialog * */ protected void onPostExecute(Integer ans) { pDialog.dismiss(); // Log.d("test1",productsList.get(10).get("finish_value1")); // Log.d("test1",String.valueOf(productsList.size())); if (ans == 2) { AlertDialog.Builder ad = new AlertDialog.Builder(SplashActivity.this); ad.setTitle("系統異常!"); ad.setMessage("系統異常,請聯繫系統管理員。"); ad.setPositiveButton( "是", new DialogInterface.OnClickListener() { // 退出按鈕 public void onClick(DialogInterface dialog, int i) { // TODO Auto-generated method stub SplashActivity.this.finish(); // 關閉activity } }); ad.show(); // 示對話框 } else { DatabaseHelper mDatabaseHelper2 = DatabaseHelper.getHelper(SplashActivity.this); sop_detailDao msop_detailDao2 = new sop_detailDao(); sop_detailVo msop_detailVo2 = new sop_detailVo(); /* DatabaseHelper[] mDatabaseHelper2 = new DatabaseHelper[20]; sop_detailDao[] msop_detailDao2 = new sop_detailDao[20]; sop_detailVo[] msop_detailVo2 = new sop_detailVo[20]; for (int i = 0; i < 4; i++){ mDatabaseHelper2[i] = DatabaseHelper.getHelper(SplashActivity.this); msop_detailVo2[i].setSop_number("www"); msop_detailVo2[i].setStep_order("123"+i); msop_detailDao2[i].insert(mDatabaseHelper2[i], msop_detailVo2[i]); Log.d("products",String.valueOf(i)); }*/ // msop_detailDao2.insert(mDatabaseHelper2, msop_detailVo2); Log.d("length", String.valueOf(products.length())); Log.d("size", String.valueOf(productsList.size())); // dismiss the dialog after getting all products for (int i = 0; i < productsList.size(); i++) { msop_detailVo2.setSop_number(productsList.get(i).get("sop_number")); msop_detailVo2.setStep_order(productsList.get(i).get("step_order")); msop_detailVo2.setStep_number(productsList.get(i).get("step_number")); Log.d("countproducts" + String.valueOf(i), productsList.get(i).get("step_number")); msop_detailVo2.setStep_name(productsList.get(i).get("step_name")); msop_detailVo2.setStep_purpose(productsList.get(i).get("step_purpose")); msop_detailVo2.setStep_intro(productsList.get(i).get("step_intro")); Log.d("countproducts" + String.valueOf(i), productsList.get(i).get("step_intro")); msop_detailVo2.setStart_rule(productsList.get(i).get("start_rule")); msop_detailVo2.setStart_value1(productsList.get(i).get("start_value1")); msop_detailVo2.setStart_value2(productsList.get(i).get("start_value2")); msop_detailVo2.setFinish_rule(productsList.get(i).get("finish_rule")); msop_detailVo2.setFinish_value1(productsList.get(i).get("finish_value1")); msop_detailVo2.setFinish_value2(productsList.get(i).get("finish_value2")); msop_detailVo2.setNext_step_number(productsList.get(i).get("next_step_number")); msop_detailVo2.setNext_step_rule(productsList.get(i).get("next_step_rule")); msop_detailVo2.setStep_remind(productsList.get(i).get("step_remind")); msop_detailVo2.setStart_remind(productsList.get(i).get("start_remind")); msop_detailVo2.setStart_message(productsList.get(i).get("start_message")); msop_detailDao2.insert(mDatabaseHelper2, msop_detailVo2); } DatabaseHelper mDatabaseHelper4 = DatabaseHelper.getHelper(SplashActivity.this); case_masterDao mcase_masterDao4 = new case_masterDao(); case_masterVo mcase_masterVo4 = new case_masterVo(); Log.d("eee", String.valueOf(products2.length())); // dismiss the dialog after getting all products for (int i = 0; i < productsList2.size(); i++) { mcase_masterVo4.setSop_number(productsList2.get(i).get("sop_number")); mcase_masterVo4.setStep_number(productsList2.get(i).get("step_number")); mcase_masterVo4.setAccount(productsList2.get(i).get("account")); mcase_masterVo4.setCase_number(productsList2.get(i).get("case_number")); mcase_masterVo4.setCase_mark("0"); mcase_masterDao4.insert(mDatabaseHelper4, mcase_masterVo4); } DatabaseHelper mDatabaseHelper5 = DatabaseHelper.getHelper(SplashActivity.this); sop_masterDao msop_masterDao5 = new sop_masterDao(); sop_masterVo msop_masterVo5 = new sop_masterVo(); // dismiss the dialog after getting all products for (int i = 0; i < products1.length(); i++) { msop_masterVo5.setSop_number(productsList1.get(i).get("sop_number")); msop_masterVo5.setSop_name(productsList1.get(i).get("sop_name")); msop_masterVo5.setSop_graph_src(productsList1.get(i).get("sop_graph_src")); msop_masterVo5.setSop_intro(productsList1.get(i).get("sop_intro")); msop_masterVo5.setSop_detail(productsList1.get(i).get("sop_detail")); msop_masterVo5.setAccount(productsList1.get(i).get("account")); msop_masterVo5.setStart_rule(productsList1.get(i).get("start_rule")); msop_masterDao5.insert(mDatabaseHelper5, msop_masterVo5); } DatabaseHelper mDatabaseHelper6 = DatabaseHelper.getHelper(SplashActivity.this); step_recordDao mstep_recordDao6 = new step_recordDao(); step_recordVo mstep_recordVo6 = new step_recordVo(); Log.d("length3", String.valueOf(products3.length())); Log.d("size3", String.valueOf(productsList3.size())); // dismiss the dialog after getting all products for (int i = 0; i < products3.length(); i++) { mstep_recordVo6.setId(Integer.valueOf(productsList3.get(i).get("id"))); mstep_recordVo6.setStep_number(productsList3.get(i).get("step_number")); mstep_recordVo6.setRecord_order(productsList3.get(i).get("record_order")); mstep_recordVo6.setRecord_text(productsList3.get(i).get("record_text")); Log.d("countproducts3" + i, productsList3.get(i).get("record_text")); mstep_recordVo6.setRecord_type(productsList3.get(i).get("record_type")); mstep_recordVo6.setRecord_unit(productsList3.get(i).get("record_unit")); mstep_recordVo6.setRecord_max(productsList3.get(i).get("record_max")); mstep_recordVo6.setRecord_min(productsList3.get(i).get("record_min")); mstep_recordVo6.setRecord_standard(productsList3.get(i).get("record_standard")); mstep_recordDao6.insert(mDatabaseHelper6, mstep_recordVo6); } download(); /* //測試 DatabaseHelper mDatabaseHelper = DatabaseHelper.getHelper(SplashActivity.this); step_recordDao mstep_recordDao11 = new step_recordDao(); List<step_recordVo>step_recordlist11 = null; //sopdetaillist = msop_detailDao.selectRaw(mDatabaseHelper,"Step_number IN(SELECT Last_do_order FROM case_masterVo WHERE Account='"+TAG_ACCOUNT+"')"); step_recordlist11 = mstep_recordDao11.selectRawByNest(mDatabaseHelper,"Sop_number","20150803","Step_number"); Log.d("onpost_test",String.valueOf(step_recordlist11.size())); Log.d("00",step_recordlist11.get(0).getStep_number()); Log.d("1",step_recordlist11.get(0).getRecord_text()); Log.d("2",step_recordlist11.get(1).getRecord_text()); Log.d("3",step_recordlist11.get(2).getRecord_text()); Log.d("4",step_recordlist11.get(3).getRecord_text()); Log.d("5",step_recordlist11.get(4).getRecord_text()); Log.d("6",step_recordlist11.get(5).getRecord_text()); Log.d("7",step_recordlist11.get(6).getRecord_text()); DatabaseHelper mDatabaseHelper15 = DatabaseHelper.getHelper(SplashActivity.this); sop_detailDao msop_detailDao15 = new sop_detailDao(); List<sop_detailVo> list15 = null; list15 = msop_detailDao15.selectRaw(mDatabaseHelper15, "Step_number ='1'"); Log.d("User1", list15.get(0).getSop_number()); //測試 //測試 DatabaseHelper mDatabaseHelper = DatabaseHelper.getHelper(SplashActivity.this); sop_detailDao msop_detailDao9 = new sop_detailDao(); List<sop_detailVo>sopdetaillist9 = null; //sopdetaillist = msop_detailDao.selectRaw(mDatabaseHelper,"Step_number IN(SELECT Last_do_order FROM case_masterVo WHERE Account='"+TAG_ACCOUNT+"')"); sopdetaillist9 = msop_detailDao9.selectRawByNest(mDatabaseHelper,"Account",TAG_ACCOUNT,"Step_number"); Log.d("onpost_test",String.valueOf(sopdetaillist9.size())); Log.d("1",sopdetaillist9.get(0).getStep_number()); Log.d("2",sopdetaillist9.get(1).getStep_number()); Log.d("3",sopdetaillist9.get(2).getStep_number()); Log.d("4",sopdetaillist9.get(3).getStep_number()); Log.d("5",sopdetaillist9.get(4).getStep_number()); //Log.d("6",sopdetaillist9.get(5).getStep_number()); //測試 DatabaseHelper mDatabaseHelper = DatabaseHelper.getHelper(SplashActivity.this); sop_masterDao msop_masterDao11 = new sop_masterDao(); List<sop_masterVo>sop_masterlist11 = null; //sopdetaillist = msop_detailDao.selectRaw(mDatabaseHelper,"Step_number IN(SELECT Last_do_order FROM case_masterVo WHERE Account='"+TAG_ACCOUNT+"')"); sop_masterlist11 = msop_masterDao11.selectRaw(mDatabaseHelper,"Sop_number=Z79Fm2af"); Log.d("onpost_test",sop_masterlist11.get(0).getSop_name()); //測試 DatabaseHelper mDatabaseHelper10 = DatabaseHelper.getHelper(SplashActivity.this); sop_detailDao msop_detailDao10 = new sop_detailDao(); List<sop_detailVo>sopdetaillist10 = null; sopdetaillist10 = msop_detailDao10.selectRaw(mDatabaseHelper10,"Step_number=1"); Log.d("onpost_test2",sopdetaillist10.get(0).getStep_number()); Log.d("onpost_test2",sopdetaillist10.get(0).getStep_intro()); //測試 */ // startActivity(new Intent().setClass(SplashActivity.this, Login.class)); if (DetectDownload == 0) { Bundle bundle = new Bundle(); bundle.putString("TAG_ACCOUNT", TAG_ACCOUNT); startActivity(new Intent().setClass(SplashActivity.this, Mysop.class).putExtras(bundle)); finish(); } } }
public void getAccount() { DatabaseHelper mDatabaseHelper = DatabaseHelper.getHelper(this); member_accountDao mmember_accountDao = new member_accountDao(); List<member_accountVo> account; account = mmember_accountDao.selectColumns(mDatabaseHelper, "FIELD_Account"); ConnectivityManager CM = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = CM.getActiveNetworkInfo(); // null代表沒網路 if (info == null && account.isEmpty()) { Toast.makeText(SplashActivity.this, "請開啟網路,並重新啟動", Toast.LENGTH_LONG).show(); } else if (info == null && !account.isEmpty()) { TAG_ACCOUNT = account.get(0).getAccount(); Bundle bundle = new Bundle(); bundle.putString("TAG_ACCOUNT", TAG_ACCOUNT); startActivity(new Intent().setClass(SplashActivity.this, Mysop.class).putExtras(bundle)); finish(); } else if (info != null && account.isEmpty()) { Bundle bundle = new Bundle(); bundle.putString("TAG_Key", ""); startActivity(new Intent().setClass(SplashActivity.this, Home.class).putExtras(bundle)); finish(); } else if (info != null && !account.isEmpty()) { DatabaseHelper DatabaseHelperupload = DatabaseHelper.getHelper(SplashActivity.this); case_masterDao case_masteruploadDao = new case_masterDao(); List<case_masterVo> uploadlist; uploadlist = case_masteruploadDao.selectRaw(DatabaseHelperupload, "Case_mark=1"); // 此人有無網路結案 if (uploadlist.size() != 0) { DatabaseHelper DatabaseHelperupload1 = DatabaseHelper.getHelper(SplashActivity.this); case_recordDao case_recorduploadDao1 = new case_recordDao(); List<case_recordVo> uploadlist1; for (int i = 0; i < uploadlist.size(); i++) { uploadlist1 = case_recorduploadDao1.selectRaw( DatabaseHelperupload1, "Case_number=" + uploadlist.get(i).getCase_number()); // 上傳記錄值case_record UpLoad1[] upload1 = new UpLoad1[uploadlist1.size()]; for (int j = 0; j < uploadlist1.size(); j++) { upload1[j] = new UpLoad1(); upload1[j].execute( uploadlist1.get(j).getCase_number(), uploadlist1.get(j).getStep_order(), uploadlist1.get(j).getRecord_order(), uploadlist1.get(j).getRecord_value()); } DatabaseHelper mDatabaseHelperupload2 = DatabaseHelper.getHelper(SplashActivity.this); case_detailDao mcase_detailDao = new case_detailDao(); List<case_detailVo> case_detaillist = null; case_detaillist = mcase_detailDao.selectRaw( mDatabaseHelperupload2, "Case_number=" + uploadlist.get(i).getCase_number()); // 上傳case_detail UpLoad3[] upload3 = new UpLoad3[case_detaillist.size()]; Log.d("case_detaillist.size()", String.valueOf(case_detaillist.size())); for (int k = 0; k < case_detaillist.size(); k++) { Log.d("k", String.valueOf(k)); upload3[k] = new UpLoad3(); upload3[k].execute( case_detaillist.get(k).getCase_number(), case_detaillist.get(k).getStep_order(), case_detaillist.get(k).getStep_start_time(), case_detaillist.get(k).getStep_finish_time()); } // 上傳刪除case_master UpLoad2[] upload2 = new UpLoad2[uploadlist.size()]; upload2[i] = new UpLoad2(); upload2[i].execute(uploadlist.get(i).getCase_number()); // 手機刪case_record、case_master DatabaseHelper DatabaseHelperupload2 = DatabaseHelper.getHelper(SplashActivity.this); case_recordDao case_recordupload2 = new case_recordDao(); case_recordupload2.delete( DatabaseHelperupload2, "Case_number", uploadlist.get(i).getCase_number()); DatabaseHelper DatabaseHelperupload3 = DatabaseHelper.getHelper(SplashActivity.this); case_masterDao case_masteruploadDao3 = new case_masterDao(); case_masteruploadDao3.delete( DatabaseHelperupload3, "Case_number", uploadlist.get(i).getCase_number()); DatabaseHelper DatabaseHelperupload4 = DatabaseHelper.getHelper(SplashActivity.this); case_detailDao case_detailuploadDao4 = new case_detailDao(); case_detailuploadDao4.delete( DatabaseHelperupload4, "Case_number", uploadlist.get(i).getCase_number()); } } TAG_ACCOUNT = account.get(0).getAccount(); new LoadAllProducts().execute(); } }