Example #1
0
        private void rebuildLucene(String indexPath)
        {
            Analyzer    analyzer = new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30);
            Directory   luceneIndexDirectory;
            IndexWriter writer;

            luceneIndexDirectory = FSDirectory.Open(indexPath);

            writer = new IndexWriter(luceneIndexDirectory, analyzer, true, new IndexWriter.MaxFieldLength(500));

            IEnumerable <RPAResult> dataToIndex;
            ISQLReader dataReader = new SQLDataReader();

            dataToIndex = dataReader.ReadAllRows();

            foreach (var sampleDataFileRow in dataToIndex)
            {
                Document doc = new Document();
                doc.Add(new Field("ID", sampleDataFileRow.ID.ToString(), Field.Store.YES, Field.Index.ANALYZED));
                doc.Add(new Field("KeyWords", sampleDataFileRow.KeyWords.ToString(), Field.Store.YES, Field.Index.ANALYZED));
                doc.Add(new Field("ScriptID", sampleDataFileRow.ScriptID.ToString(), Field.Store.YES, Field.Index.ANALYZED));
                doc.Add(new Field("ScriptText", sampleDataFileRow.ScriptText, Field.Store.YES, Field.Index.ANALYZED));
                doc.Add(new Field("UserConfirmationMsg", sampleDataFileRow.UserConfirmationMsg, Field.Store.YES, Field.Index.ANALYZED));
                writer.AddDocument(doc);
            }
            writer.Optimize();
            writer.Commit();
            writer.Dispose();
        }
Example #2
0
    protected static object ReadList(SQLDataReader dr)
    {
        List <User> retVal = new List <User>();

        while (dr.Read())
        {
            User temp = new User();
            temp.Prop1 = dr.GetString("Prop1");
            temp.Prop2 = dr.GetInt("Prop2");
            retVal.Add(temp);
        }
        return(retVal);
    }
Example #3
0
        private static List <Product> InitializeCollectionOld(string tableName)
        {
            List <Product> list = new();

            OpenDataBaseConnection();

            SQLCommand    = new SqlCommand($"SELECT * FROM {tableName}", SQLConnection);
            SQLDataReader = SQLCommand.ExecuteReader();

            while (SQLDataReader.Read())
            {
                list.Add(new Product
                {
                    Id    = Convert.ToInt32(SQLDataReader["id"]),
                    Name  = SQLDataReader["name"].ToString(),
                    Price = Convert.ToDecimal(SQLDataReader["price"])
                });
            }

            CloseDataBaseConnection();
            return(list);
        }