예제 #1
0
        private int GetWrongWordsCount()
        {
            string tableName = GetCurrentLearningWordsTabelName();

            MySQLiteHelper sql = MySQLiteHelper.Instance;

            // 连接数据库
            sql.GetConnectionWith(CommonData.dataBaseName);

            // 检查存放指定单词类型的表是否存在(目前只做了测试用的CET4这一个表,添加表使用参考editor文件夹下的DataBaseManager)
            if (!sql.CheckTableExist(tableName))
            {
                Debug.Log("查询的表不存在");
                return(0);
            }



            // 查询当前学习的单词类型中所有背错过的单词数量
            string[] ungraspedCondition = new string[] { "ungraspTimes>0" };
            int      count = sql.GetItemCountOfTable(tableName, ungraspedCondition, true);

            sql.CloseAllConnections();

            return(count);
        }
예제 #2
0
        public static GeneralWord RandomGeneralWord()
        {
            string tableName = "AllWordsData";

            MySQLiteHelper sql = MySQLiteHelper.Instance;

            // 连接数据库
            sql.GetConnectionWith(CommonData.dataBaseName);

            int wordsCount = sql.GetItemCountOfTable(tableName, null, true);

            int wordId = Random.Range(0, wordsCount);

            string[] conditions = new string[] { string.Format("wordId={0}", wordId) };

            IDataReader reader = sql.ReadSpecificRowsOfTable(tableName, null, conditions, true);

            reader.Read();

            string spell = reader.GetString(1);

            string explaination = reader.GetString(2);

//			bool valid = reader.GetBoolean (4);

            return(new GeneralWord(wordId, spell, explaination));
        }
예제 #3
0
        /// <summary>
        /// 获取当前词库的单词总数
        /// </summary>
        /// <returns>The total words count.</returns>
        private int GetTotalWordsCount()
        {
            string tableName = GetCurrentLearningWordsTabelName();

            MySQLiteHelper sql = MySQLiteHelper.Instance;

            // 连接数据库
            sql.GetConnectionWith(CommonData.dataBaseName);

            // 检查存放指定单词类型的表是否存在(目前只做了测试用的CET4这一个表,添加表使用参考editor文件夹下的DataBaseManager)
            if (!sql.CheckTableExist(tableName))
            {
                sql.CloseConnection(CommonData.dataBaseName);
                return(0);
            }

            // 查询当前学习的单词类型中的所有单词数量
            int count = sql.GetItemCountOfTable(tableName, null, true);

            sql.CloseConnection(CommonData.dataBaseName);

            return(count);
        }
예제 #4
0
        /// <summary>
        /// 获取当前词库已学习单词总数
        /// </summary>
        /// <returns>The current learned words count.</returns>
        private int GetCurrentLearnedWordsCount()
        {
            string tableName = GetCurrentLearningWordsTabelName();

            MySQLiteHelper sql = MySQLiteHelper.Instance;

            // 连接数据库
            sql.GetConnectionWith(CommonData.dataBaseName);

            if (!sql.CheckTableExist(tableName))
            {
                sql.CloseConnection(CommonData.dataBaseName);
                return(0);
            }

            // 查询当前学习的单词类型中的所有单词数量
            string[] learnedCondition = { "learnedTimes>0" };
            int      count            = sql.GetItemCountOfTable(tableName, learnedCondition, true);

            sql.CloseConnection(CommonData.dataBaseName);

            return(count);
        }
예제 #5
0
        public static LearnWord RandomWord()
        {
            LearningInfo learnInfo = LearningInfo.Instance;

            int wordId = 0;

            if (learnInfo.learnedWordCount != 0)
            {
                wordId = Random.Range(0, learnInfo.learnedWordCount);

                List <LearnWord> learnedWords = learnInfo.GetAllLearnedWords();

                return(learnedWords [wordId]);
            }


            string tableName = string.Empty;

            WordType wt = GameManager.Instance.gameDataCenter.gameSettings.wordType;

            switch (wt)
            {
            case WordType.CET4:
                tableName = CommonData.CET4Table;
                break;

            case WordType.CET6:
                tableName = "CET6";
                break;

            case WordType.Daily:
                tableName = "Daily";
                break;

            case WordType.Bussiness:
                tableName = "Bussiness";
                break;
            }

            MySQLiteHelper sql = MySQLiteHelper.Instance;

            // 连接数据库
            sql.GetConnectionWith(CommonData.dataBaseName);

            int wordsCount = sql.GetItemCountOfTable(tableName, null, true);

            wordId = Random.Range(0, wordsCount);

            string[] conditions = new string[] { string.Format("wordId={0}", wordId) };

            IDataReader reader = sql.ReadSpecificRowsOfTable(tableName, null, conditions, true);

            reader.Read();

            string spell = reader.GetString(1);

            string explaination = reader.GetString(2);

            string phoneticSymbol = reader.GetString(3);

            string example = reader.GetString(4);

            int learnedTimes = reader.GetInt16(5);

            int ungraspTimes = reader.GetInt16(6);

            return(new LearnWord(wordId, spell, explaination, phoneticSymbol, example, learnedTimes, ungraspTimes));
        }