Ejemplo 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);*/
  }
Ejemplo n.º 2
0
  public boolean onKeyDown(int keyCode, KeyEvent event) { // 捕捉返回鍵
    if ((keyCode == KeyEvent.KEYCODE_BACK)) {
      // orm account
      DatabaseHelper mDatabaseHelper4 = DatabaseHelper.getHelper(Steprecording.this);
      member_accountDao mmember_accountDao = new member_accountDao();
      List<member_accountVo> memberlist = null;
      memberlist = mmember_accountDao.selectColumns(mDatabaseHelper4, "FIELD_Account");
      TAG_ACCOUNT = memberlist.get(0).getAccount();

      Bundle bundle = new Bundle();
      bundle.putString("TAG_ACCOUNT", TAG_ACCOUNT);
      Intent it = new Intent(this, Mysop.class);
      it.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
      it.putExtras(bundle); // 將參數放入intent
      startActivity(it);
      finish();

      return true;
    }
    return super.onKeyDown(keyCode, event);
  }
Ejemplo n.º 3
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_steprecording);

    // 手錶
    String fromwear = getIntent().getStringExtra("reply");
    if (fromwear == null) {
      Bundle remoteInput = RemoteInput.getResultsFromIntent(getIntent());
      if (remoteInput != null) {
        fromwear = remoteInput.getCharSequence(Steprecording.EXTRA_VOICE_REPLY).toString();
        Log.d("fromwear", fromwear);
        wearcontent = fromwear.split(" ");
        TAG_FROM_WEAR = true;
      }
    }

    TextView ss = (TextView) findViewById(R.id.textView6);
    Intent intent = this.getIntent();
    Bundle bundle = intent.getExtras(); // 取得Bundle

    /*//是否來過
    if(intent.hasExtra("TAG_BACK_TO_RECORDING")){
        TAG_BACK_TO_RECORDING = true;
        Log.d("抓3","backtorecording");
    }*/

    TAG_CASE_NUMBER = bundle.getString("TAG_CASE_NUMBER");
    TAG_STEP_NUMBER = bundle.getString("TAG_STEP_NUMBER");
    TAG_STEP_ORDER = bundle.getInt("TAG_STEP_ORDER");

    Log.d("StepRecording", TAG_STEP_NUMBER);
    //        TAG_CASE_NUMBER = "15";
    //        TAG_STEP_NUMBER = "10";
    //        TAG_STEP_ORDER = 1;
    ss.setText(Integer.toString(TAG_STEP_ORDER));

    // 是否來過
    DatabaseHelper mDBACK = DatabaseHelper.getHelper(this);
    case_recordDao mcase_recordDao = new case_recordDao();
    List<case_recordVo> listBACK = null;
    listBACK =
        mcase_recordDao.selectRaw(
            mDBACK, "Case_number=" + TAG_CASE_NUMBER + " and Step_order=" + TAG_STEP_ORDER);
    if (listBACK.size() != 0) {
      TAG_BACK_TO_RECORDING = true;
    }

    // Hashmap for ListView
    productsList = new ArrayList<HashMap<String, String>>();
    // Loading products in Background Thread
    // new LoadInput().execute();

    // SELECT record_order,record_text FROM step_record WHERE step_number='"+Stepnumber+"'"
    DatabaseHelper mDatabaseHelper = DatabaseHelper.getHelper(this);
    mstep_recordDao = new step_recordDao();
    List<step_recordVo> list = null;
    list = mstep_recordDao.selectRaw(mDatabaseHelper, "Step_number =\"" + TAG_STEP_NUMBER + "\"");

    //  Log.d("抓", list.get(0).getRecord_order());
    //  Log.d("抓2", list.get(0).getRecord_text());

    count = list.size();
    LinearLayout ly = (LinearLayout) findViewById(R.id.linearlayoutinput);
    for (int i = 0; i < count; i++) {
      TextView text1 = new TextView(Steprecording.this);
      text1.setText(list.get(i).getRecord_text() + "(" + list.get(i).getRecord_unit() + ")");
      // 1數字2文字
      if (Integer.valueOf(list.get(i).getRecord_type()) == 1) {
        text1.setText(
            text1.getText()
                + "("
                + list.get(i).getRecord_min()
                + "~"
                + list.get(i).getRecord_max()
                + ")");
      }

      edit1[i] = new EditText(Steprecording.this.getApplicationContext());
      edit1[i].setTextColor(Color.rgb(0, 0, 0));
      edit1[i].setOnFocusChangeListener(new MyOnFocusChangeListener());
      edit1[i].setSingleLine(true);
      edit1[i].setBackgroundColor(Color.parseColor("#FDDCB9")); // #FEFBE6黃
      if (TAG_FROM_WEAR) {
        if (i < wearcontent.length) {
          edit1[i].setText(wearcontent[i]);
        }
      }
      // edit1[0].setText("eee");
      ly.addView(text1);
      ly.addView(edit1[i]);
    }

    goright = (ImageButton) findViewById(R.id.imageButton);
    goleft = (ImageButton) findViewById(R.id.imageButton2);

    detector = new GestureDetector(new MySimpleOnGestureListener());

    ScrollView sv = (ScrollView) findViewById(R.id.scrollView);
    sv.setOnTouchListener(new MyOnTouchListener());
    // LinearLayout llb = (LinearLayout)findViewById(R.id.linearLayoutbackground);
    // llb.setOnTouchListener(new MyOnTouchListener());

    messageList = new ArrayList<>();

    // 手錶
    if (!TAG_BACK_TO_RECORDING) {
      String replyLabel = getResources().getString(R.string.reply_label);
      RemoteInput remoteInput =
          new RemoteInput.Builder(EXTRA_VOICE_REPLY).setLabel(replyLabel).build();
      // Create an intent for the reply action
      Intent replyIntent = new Intent(this, Steprecording.class);
      Bundle wb = new Bundle();
      wb.putString("TAG_CASE_NUMBER", TAG_CASE_NUMBER);
      wb.putString("TAG_STEP_NUMBER", TAG_STEP_NUMBER);
      wb.putInt("TAG_STEP_ORDER", TAG_STEP_ORDER);
      replyIntent.putExtras(wb);
      // replyIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
      PendingIntent replyPendingIntent =
          PendingIntent.getActivity(this, 0, replyIntent, PendingIntent.FLAG_UPDATE_CURRENT);

      NotificationCompat.Action action =
          new NotificationCompat.Action.Builder(
                  R.drawable.cast_ic_notification_0,
                  getString(R.string.reply_label),
                  replyPendingIntent)
              .addRemoteInput(remoteInput)
              .build();

      // Create builder for the main notification
      NotificationCompat.Builder notificationBuilder =
          new NotificationCompat.Builder(this)
              .setSmallIcon(R.mipmap.ic_launcher)
              .setContentTitle("Step" + Integer.toString(TAG_STEP_ORDER))
              .setContentText("紀錄項(請往左滑):");

      /*        // Create a big text style for the second page
              NotificationCompat.BigTextStyle secondPageStyle = new NotificationCompat.BigTextStyle();
              secondPageStyle.setBigContentTitle("Page 2")
                      .bigText("A lot of text...");

              // Create second page notification
              Notification secondPageNotification =
                      new NotificationCompat.Builder(this)
                              .setStyle(secondPageStyle)
                              .build();
      */
      List extras = new ArrayList();
      for (int i = 0; i < count; i++) {

        NotificationCompat.BigTextStyle extraPageStyle = new NotificationCompat.BigTextStyle();
        extraPageStyle
            .setBigContentTitle("第" + String.valueOf(i) + "項")
            .bigText(list.get(i).getRecord_text());
        Notification extraPageNotification =
            new NotificationCompat.Builder(this).setStyle(extraPageStyle).build();
        extras.add(extraPageNotification);
      }
      /*      //如果要跳頁
              Intent mainIntent = new Intent(this, MyDisplayActivity.class);
              PendingIntent mainPendingIntent = PendingIntent.getActivity(this, 0,
                      mainIntent, PendingIntent.FLAG_CANCEL_CURRENT);
      */

      // Extend the notification builder with the second page
      Notification notification =
          notificationBuilder
              .extend(new NotificationCompat.WearableExtender().addPages(extras).addAction(action))
              // .addPage(secondPageNotification))
              // .addAction(android.R.drawable.ic_media_play, "Speak", mainPendingIntent)
              .build();

      // Issue the notification
      NotificationManagerCompat notificationManager =
          NotificationManagerCompat.from(getApplication());
      Random random = new Random();
      int notificationId = random.nextInt(9999 - 1000) + 1000;
      notificationManager.notify(notificationId, notification);

      /*        mGoogleApiClient = new GoogleApiClient.Builder(this)
              .addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
                  @Override
                  public void onConnected(Bundle connectionHint) {
                      Log.d(TAG, "onConnected: " + connectionHint);
                  }
                  @Override
                  public void onConnectionSuspended(int cause) {
                      Log.d(TAG, "onConnectionSuspended: " + cause);
                  }
              })
              .addOnConnectionFailedListener(new GoogleApiClient.OnConnectionFailedListener() {
                  @Override
                  public void onConnectionFailed(ConnectionResult result) {
                      Log.d(TAG, "onConnectionFailed: " + result);
                  }
              })
              .addApi(Wearable.API)
              .build();
      mGoogleApiClient.connect();
      sendNotification();*/
    }
  }
Ejemplo n.º 4
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();
        }
      }
    }
Ejemplo n.º 5
0
  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();
    }
  }