Example #1
0
        public void QueryKeywords(string keyword)
        {
            if (arrayOfAllQueriedWordStrsIndex == null)
            {
                return;
            }
            CollectionMatchedOfKeywordsByBookName.Clear();

            int pointer = 0;

            foreach (WordStrsIndex WordStrsIndex in arrayOfAllQueriedWordStrsIndex)
            {
                if (WordStrsIndex != null)
                {
                    WordStrsIndex filteredKeywordIndex = WordStrsIndex.FilterWordStrs(keyword);

                    string bookname = connection.Get <Dict>(WordStrsIndex.DictId).BookName;
                    WordStrByBookName[] arrayOfWordStrByBookName =
                        filteredKeywordIndex.GetWordStrsByBookName(bookname);

                    int minItems = arrayOfWordStrByBookName.Count();
                    for (int i = pointer; i < pointer + minItems; i++)
                    {
                        CollectionMatchedOfKeywordsByBookName.Add(arrayOfWordStrByBookName[i]);
                    }
                }
            }
        }
Example #2
0
        private void populatearrayOfAllQueriedWordStrsIndexesAsync()
        {
            TableQuery <Dict>           dicts            = connection.Table <Dict>().Where(p => p.IsQueried);
            TableQuery <WordStrDBIndex> wordStrDBIndexes = connection.Table <WordStrDBIndex>();

            if (wordStrDBIndexes.Count() < 1)
            {
                arrayOfAllQueriedWordStrsIndex = new WordStrsIndex[0];
                return;
            }
            WordStrsIndex[] arrayOfWordStrsIndexes = new WordStrsIndex[dicts.Max(p => p.DictID) + 1];

            foreach (Dict dict in dicts)
            {
                try
                {
                    var wordStrs = wordStrDBIndexes
                                   .Where(p => p.DictId == dict.DictID);
                    var _wordStrs = wordStrs.Select(p => p.WordStr);

                    arrayOfWordStrsIndexes[dict.DictID] = new WordStrsIndex(_wordStrs, dict.DictID);
                }
                catch { }
            }
            arrayOfAllQueriedWordStrsIndex = arrayOfWordStrsIndexes;
        }
Example #3
0
        static public WordStrByBookName[] GetWordStrsByBookName(this WordStrsIndex self, string bookName)
        {
            WordStrByBookName[] arrayOfWordStrsByBookName = new WordStrByBookName[self.WordStrs.Count()];
            for (int i = 0; i < self.WordStrs.Count(); i++)
            {
                arrayOfWordStrsByBookName[i] = new WordStrByBookName()
                {
                    WordStr  = self.WordStrs[i],
                    BookName = bookName
                };
            }

            return(arrayOfWordStrsByBookName);
        }