Beispiel #1
0
        /// <summary>
        /// 获取所有已学习过的单词
        /// </summary>
        /// <returns>The all learned words.</returns>
        public List <HLHWord> GetAllLearnedWords()
        {
            List <HLHWord> learnedWords = new List <HLHWord>();

            string tableName = GetCurrentLearningWordsTabelName();

            MySQLiteHelper sql = MySQLiteHelper.Instance;

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

            string[] ungraspedCondition = { "learnedTimes>0" };

            // 读取器
            IDataReader reader = sql.ReadSpecificRowsOfTable(tableName, null, ungraspedCondition, true);

            // 从表中读取数据
            while (reader.Read())
            {
                if (reader == null)
                {
                    sql.CloseAllConnections();
                    return(null);
                }

                HLHWord word = HLHWord.GetWordFromReader(reader);

                learnedWords.Add(word);
            }

            sql.CloseAllConnections();

            return(learnedWords);
        }
Beispiel #2
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);
        }
Beispiel #3
0
        /// <summary>
        /// 获取所有不熟悉的单词
        /// </summary>
        /// <returns>The all unfamiliar word.</returns>
        public List <HLHWord> GetAllUnfamiliarWord()
        {
            List <HLHWord> unfamiliarWords = new List <HLHWord>();

            string tableName = GetCurrentLearningWordsTabelName();

            MySQLiteHelper sql = MySQLiteHelper.Instance;

            sql.GetConnectionWith(CommonData.dataBaseName);

            string[] graspedCondition = { "learnedTimes>0", "isFamiliar=0" };

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

            while (reader.Read())
            {
                if (reader == null)
                {
                    sql.CloseConnection(CommonData.dataBaseName);
                    return(null);
                }

                HLHWord word = HLHWord.GetWordFromReader(reader);

                unfamiliarWords.Add(word);
            }


            sql.CloseAllConnections();

            return(unfamiliarWords);
        }
Beispiel #4
0
        public List <LearnWord> GetAllUngraspedWords()
        {
            List <LearnWord> ungraspWords = new List <LearnWord>();

            string tableName = GetCurrentLearningWordsTabelName();

            MySQLiteHelper sql = MySQLiteHelper.Instance;

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

            string[] ungraspedCondition = new string[] { "ungraspTimes>0" };

            // 读取器
            IDataReader reader = sql.ReadSpecificRowsOfTable(tableName, null, ungraspedCondition, true);

            // 从表中读取数据
            while (reader.Read())
            {
                if (reader == null)
                {
                    return(null);
                }

                int    wordId         = reader.GetInt32(0);
                string spell          = reader.GetString(1);
                string explaination   = reader.GetString(2);
                string phoneticSymble = reader.GetString(3);
                string example        = reader.GetString(4);
                int    learnedTimes   = reader.GetInt16(5);
                int    ungraspTimes   = reader.GetInt16(6);

                LearnWord w = new LearnWord(wordId, spell, explaination, phoneticSymble, example, learnedTimes, ungraspTimes);

                ungraspWords.Add(w);
            }

            sql.CloseAllConnections();

            return(ungraspWords);
        }
        /// <summary>
        /// 初始化本次要学习的单词数组
        /// </summary>
        private void InitWordsToLearn()
        {
            ungraspedWordsList.Clear();

            mySql = MySQLiteHelper.Instance;

            mySql.GetConnectionWith(CommonData.dataBaseName);

//			int totalLearnTimeCount = GameManager.Instance.gameDataCenter.learnInfo.totalLearnTimeCount;
//
//			int totalWordsCount = mySql.GetItemCountOfTable (CommonData.CET4Table,null,true);
//
//			// 大循环的次数
//			int bigCycleCount = totalLearnTimeCount * singleLearnWordsCount / (totalWordsCount * recycleLearnTimeBase);
//
//			currentWordsLearnedTime = totalLearnTimeCount % (recycleLearnTimeBase * recycleGroupBase) / recycleGroupBase + recycleLearnTimeBase * bigCycleCount;

            mySql.BeginTransaction();

            // 边界条件
            string[] condition = new string[] { "learnedTimes=0" };


            IDataReader reader = mySql.ReadSpecificRowsOfTable(currentWordsTableName, null, condition, true);


            // 从数据库中读取当前要学习的单词
            for (int i = 0; i < singleLearnWordsCount; i++)
            {
                reader.Read();

                if (reader == null)
                {
                    string[] colFields  = new string[] { "learnedTimes" };
                    string[] values     = new string[] { "0" };
                    string[] conditions = new string[] { "learnedTimes=1" };

                    mySql.UpdateValues(currentWordsTableName, colFields, values, conditions, true);

                    mySql.EndTransaction();

                    mySql.CloseAllConnections();

                    InitWordsToLearn();

                    return;
                }

                int wordId = reader.GetInt32(0);

                string spell = reader.GetString(1);

                string phoneticSymble = reader.GetString(2);

                string explaination = reader.GetString(3);

                string example = reader.GetString(4);

                int learnedTimes = reader.GetInt16(5);

                int ungraspTimes = reader.GetInt16(6);

                LearnWord word = new LearnWord(wordId, spell, phoneticSymble, explaination, example, learnedTimes, ungraspTimes);

                Debug.LogFormat("{0}---{1}次", word, learnedTimes);

                wordsToLearnArray [i] = word;
            }

            mySql.EndTransaction();

            mySql.CloseAllConnections();

            // 当前要学习的单词全部加入到未掌握单词列表中,用户选择掌握或者学习过该单词后从未掌握单词列表中移除
            for (int i = 0; i < wordsToLearnArray.Length; i++)
            {
                ungraspedWordsList.Add(wordsToLearnArray [i]);
            }

//			firstIdOfCurrentLearningWords = wordsToLearnArray [0].wordId;
        }