Esempio n. 1
1
  public void download() {

    DatabaseHelper DatabaseHelperDL = DatabaseHelper.getHelper(this);
    sop_detailDao sopdetailDaoDL = new sop_detailDao();
    List<sop_detailVo> sop_detailDL;
    sop_detailDL = sopdetailDaoDL.selectRaw(DatabaseHelperDL, "Start_remind=1");
    DownloadManager.Request[] down = new DownloadManager.Request[50];

    for (int i = 0; i < sop_detailDL.size(); i++) {

      File file =
          new File(
              URI.create(
                      "file:///mnt/sdcard/MYSOPTEST/start"
                          + sop_detailDL.get(i).getStep_number()
                          + ".mp3")
                  .getPath());
      if (file.exists()) {
        continue;
      }
      DetectDownload = DetectDownload + 1;
      down[i] =
          new DownloadManager.Request(
              Uri.parse(
                  "http://140.115.82.211/front/download/start"
                      + sop_detailDL.get(i).getStep_number()
                      + ".mp3"));
      // 允許網路類型
      down[i].setAllowedNetworkTypes(
          DownloadManager.Request.NETWORK_MOBILE | DownloadManager.Request.NETWORK_WIFI);
      // 禁止發通知
      down[i].setShowRunningNotification(false);
      // 不顯示下載頁面
      down[i].setVisibleInDownloadsUi(false);
      // 下載後存放位置
      // down.setDestinationInExternalFilesDir(mContext, null, "testhtml.html");
      // 在sdcard裡面的MYSOPTEST資料夾
      down[i].setDestinationInExternalPublicDir(
          "MYSOPTEST", "start" + sop_detailDL.get(i).getStep_number() + ".mp3");
      // 將請求加入
      manager.enqueue(down[i]);
    }

    DatabaseHelper DatabaseHelperDL1 = DatabaseHelper.getHelper(this);
    sop_detailDao sopdetailDaoDL1 = new sop_detailDao();
    List<sop_detailVo> sop_detailDL1;
    sop_detailDL1 = sopdetailDaoDL1.selectRaw(DatabaseHelperDL1, "Step_remind=1");
    DownloadManager.Request[] down1 = new DownloadManager.Request[50];

    for (int i = 0; i < sop_detailDL1.size(); i++) {

      File file =
          new File(
              URI.create(
                      "file:///mnt/sdcard/MYSOPTEST/step"
                          + sop_detailDL1.get(i).getStep_number()
                          + ".mp3")
                  .getPath());
      if (file.exists()) {
        continue;
      }
      DetectDownload = DetectDownload + 1;
      down1[i] =
          new DownloadManager.Request(
              Uri.parse(
                  "http://140.115.82.211/front/download/step"
                      + sop_detailDL1.get(i).getStep_number()
                      + ".mp3"));
      // 允許網路類型
      down1[i].setAllowedNetworkTypes(
          DownloadManager.Request.NETWORK_MOBILE | DownloadManager.Request.NETWORK_WIFI);
      // 禁止發通知
      down1[i].setShowRunningNotification(false);
      // 不顯示下載頁面
      down1[i].setVisibleInDownloadsUi(false);
      // 下載後存放位置
      // down.setDestinationInExternalFilesDir(mContext, null, "testhtml.html");
      // 在sdcard裡面的MYSOPTEST資料夾
      down1[i].setDestinationInExternalPublicDir(
          "MYSOPTEST", "step" + sop_detailDL1.get(i).getStep_number() + ".mp3");
      // 將請求加入
      manager.enqueue(down1[i]);
    }

    DatabaseHelper DatabaseHelperDL2 = DatabaseHelper.getHelper(this);
    sop_masterDao sopmasterDaoDL2 = new sop_masterDao();
    List<sop_masterVo> sop_masterDL2;
    sop_masterDL2 = sopmasterDaoDL2.selectAll(DatabaseHelperDL2);
    DownloadManager.Request[] down2 = new DownloadManager.Request[50];

    for (int i = 0; i < sop_masterDL2.size(); i++) {

      String[] graph = sop_masterDL2.get(i).getSop_graph_src().split("/");

      File file =
          new File(URI.create("file:///mnt/sdcard/MYSOPTEST/" + graph[graph.length - 1]).getPath());
      if (file.exists()) {
        continue;
      }
      DetectDownload = DetectDownload + 1;
      // down2[i] = new DownloadManager.Request(Uri.parse("http://140.115.82.211/front/picture/" +
      // graph[graph.length-1]));
      down2[i] =
          new DownloadManager.Request(
              Uri.parse("http://140.115.82.211/img/" + graph[graph.length - 1]));
      // 允許網路類型
      down2[i].setAllowedNetworkTypes(
          DownloadManager.Request.NETWORK_MOBILE | DownloadManager.Request.NETWORK_WIFI);
      // 禁止發通知
      down2[i].setShowRunningNotification(false);
      // 不顯示下載頁面
      down2[i].setVisibleInDownloadsUi(false);
      // 下載後存放位置
      // down.setDestinationInExternalFilesDir(mContext, null, "testhtml.html");
      // 在sdcard裡面的MYSOPTEST資料夾
      down2[i].setDestinationInExternalPublicDir("MYSOPTEST", graph[graph.length - 1]);
      // 將請求加入
      manager.enqueue(down2[i]);
    }

    /*        DownloadManager.Request down=new DownloadManager.Request (Uri.parse("http://140.115.82.211/front/download/testhtml.html"));
    //允許網路類型
    down.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_MOBILE|DownloadManager.Request.NETWORK_WIFI);
    //禁止發通知
    down.setShowRunningNotification(false);
    //不顯示下載頁面
    down.setVisibleInDownloadsUi(false);
    //下載後存放位置
    //down.setDestinationInExternalFilesDir(mContext, null, "testhtml.html");
    //在sdcard裡面的MYSOPTEST資料夾
    down.setDestinationInExternalPublicDir("MYSOPTEST", "testhtml.html");
    //將請求加入
    manager.enqueue(down);*/
  }
Esempio n. 2
0
    /** 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();
        }
      }
    }