Example #1
0
        public ICollection <ISearch> GetFullHistory()
        {
            DataTable dataTable = _sqLiteDatabase.GetDataTable("SELECT * FROM [searches]");

            return
                ((from DataRow row in dataTable.Rows select new HistorySearch(row, _sqLiteDatabase)).Cast <ISearch>()
                 .ToList());
        }
Example #2
0
        public override IEnumerator <MatchingFile> GetEnumerator()
        {
            if (_searchTable == null)
            {
                _searchTable = _database.GetDataTable("SELECT * " +
                                                      "    FROM [files]" +
                                                      "    INNER JOIN [matches] USING ([file_id])" +
                                                      "    WHERE search_id=\"" + _id +
                                                      "\"  ORDER BY file_id");
            }

            int     previousFileId = -1;
            var     matches        = new LinkedList <Match>();
            DataRow previousRow    = null;

            foreach (DataRow row in _searchTable.Rows)
            {
                int newFileId = int.Parse(row["file_id"].ToString());
                if (previousFileId != newFileId)
                {
                    if (previousRow != null)
                    {
                        yield return(new MatchingFile(previousRow, matches));
                    }
                    previousRow = row;

                    matches        = new LinkedList <Match>();
                    previousFileId = newFileId;
                }
                matches.AddLast(new Match(int.Parse(row["index"].ToString()), row["value"].ToString()));
            }

            if (previousRow != null)
            {
                yield return(new MatchingFile(previousRow, matches));
            }
        }