예제 #1
0
  /* selectRaw */
  public static List<system_messageVo> selectRaw2(DatabaseHelper databaseHelper) {
    RuntimeExceptionDao<system_messageVo, Integer> system_messageDao =
        databaseHelper.getSystem_messageDao();
    QueryBuilder<system_messageVo, Integer> queryBuilder = system_messageDao.queryBuilder();
    try {

      return queryBuilder.query();
    } catch (SQLException e) {
      e.printStackTrace();
    }
    return null;
  }
예제 #2
0
  /* exist */
  public static boolean exist(DatabaseHelper databaseHelper, system_messageVo system_messageVo) {
    RuntimeExceptionDao<system_messageVo, Integer> system_messageDao =
        databaseHelper.getSystem_messageDao();
    QueryBuilder<system_messageVo, Integer> queryBuilder = system_messageDao.queryBuilder();
    try {
      queryBuilder.where().eq(system_messageVo.FIELD_Id, String.valueOf(system_messageVo.getId()));
      //	.and()
      //	.eq(AccountVo.FIELD_Device, aAccountVo.getDevice());
      return queryBuilder.query().size() > 0 ? true : false;

    } catch (SQLException e) {
      e.printStackTrace();
    }
    return false;
  }
예제 #3
0
  /* selectRaw */
  public static system_messageVo getSystem_messageVo(DatabaseHelper databaseHelper) {
    RuntimeExceptionDao<system_messageVo, Integer> system_messageDao =
        databaseHelper.getSystem_messageDao();
    QueryBuilder<system_messageVo, Integer> queryBuilder = system_messageDao.queryBuilder();
    try {

      List<system_messageVo> data = queryBuilder.where().raw("1=1").query();
      if (data.size() > 0) {
        return data.get(0);
      }
      return null;
    } catch (Exception e) {
      e.printStackTrace();
    }
    return null;
  }
예제 #4
0
  public double getWeight() {
    RuntimeExceptionDao<WeightDiaryEntry, Integer> diaryDao =
        DataHelper.getDatabaseHelper().getDiaryDao(WeightDiaryEntry.class);

    List<WeightDiaryEntry> entries;
    try {
      entries =
          diaryDao
              .queryBuilder()
              .orderBy(DiaryEntry.DATESTAMP_FIELD_NAME, true)
              .where()
              .eq(DiaryEntry.DELETED_FIELD_NAME, false)
              .query();

      if (entries != null && entries.size() > 0) {
        WeightDiaryEntry weightEntry = (WeightDiaryEntry) entries.get(entries.size() - 1);
        this.weight = weightEntry.getWeight();
      }
    } catch (SQLException e) {
      e.printStackTrace();
    }

    return this.weight;
  }
예제 #5
0
 private void callsTunnel() {
   Cursor cursor = null;
   String calls_id = null; // 数据处理标记,存入SharedPreferences
   try {
     RuntimeExceptionDao<CallsStructure, Long> dao =
         QualityApplication.getApplication(this).getDatabaseHelper().getCallsStructureDAO();
     cursor =
         getContentResolver()
             .query(
                 CallsContentObserver.CALLS_URI,
                 null,
                 "_id > ?",
                 new String[] {
                   sharedPreferences.getString(CallsContentObserver.CALLS_FLAG_ID, "0")
                 },
                 CallLog.Calls._ID + " ASC");
     while (cursor.moveToNext()) {
       calls_id = cursor.getString(cursor.getColumnIndex(CallLog.Calls._ID));
       int type = cursor.getInt(cursor.getColumnIndex(CallLog.Calls.TYPE));
       String number = cursor.getString(cursor.getColumnIndex(CallLog.Calls.NUMBER));
       String name =
           Contacts.lookupPersonName(
               getApplicationContext(),
               number,
               cursor.getString(cursor.getColumnIndex(CallLog.Calls.CACHED_NAME)));
       long duration = cursor.getLong(cursor.getColumnIndex(CallLog.Calls.DURATION));
       DateTime ddate = new DateTime(cursor.getLong(cursor.getColumnIndex(CallLog.Calls.DATE)));
       CallsStructure structure =
           new CallsStructure(
               MobileNetType.getPhoneType(getApplicationContext()),
               MobileNetType.getMobileTypeValue(getApplicationContext()),
               name,
               number,
               type,
               CallDropCause.UNKNOW.toString(),
               duration,
               ddate);
       dao.create(structure);
     }
   } catch (Exception e) {
     Log.w(TAG, "未能处理当前通话记录数据", e);
   } finally {
     try {
       if (null != cursor) cursor.close();
     } catch (Exception e) {
     }
     if (!Strings.isEmpty(calls_id))
       sharedPreferences.edit().putString(CallsContentObserver.CALLS_FLAG_ID, calls_id).commit();
   }
   try {
     RuntimeExceptionDao<CallCauseCache, Long> dao =
         QualityApplication.getApplication(this).getDatabaseHelper().getCallCauseCacheDAO();
     RuntimeExceptionDao<CallsStructure, Long> callDao =
         QualityApplication.getApplication(this).getDatabaseHelper().getCallsStructureDAO();
     List<CallCauseCache> caches = dao.queryForAll();
     // 遍历
     if (null != caches && caches.size() > 0) {
       for (CallCauseCache cache : caches) {
         CallsStructure struct =
             callDao
                 .queryBuilder()
                 .orderBy("ddate", false)
                 .where()
                 .eq("ddate", cache.getDdate())
                 .queryForFirst();
         if (null != struct) {
           // 更新断开原因
           struct.setCause(cache.getCause());
           callDao.update(struct);
           // 删除
           dao.deleteById(cache.getId());
         }
       }
     }
   } catch (Exception e) {
     Log.d(TAG, "更新通话断开原因时出现异常");
   }
   sendMessage(PhoneStateService.OBSERVER_INSTALL, PhoneStateService.OBSERVER_INSTALL_CALLS);
 }
예제 #6
0
 public static List<Person> getAllPeople(ZulipApp app) throws SQLException {
   RuntimeExceptionDao<Person, Object> dao = app.getDao(Person.class);
   return dao.queryBuilder().where().eq(Person.ISBOT_FIELD, false).query();
 }