示例#1
0
        public bool RecordsExist(AbstractConnection connection, Entity entity)
        {
            var checker = new LuceneConnectionChecker(entity.ProcessName, connection.Logger);

            if (!checker.Check(connection))
            {
                return(false);
            }

            var directoryInfo = new DirectoryInfo(LuceneDirectoryFactory.Path(connection, entity));

            if (!directoryInfo.Exists)
            {
                return(false);
            }

            if (directoryInfo.GetFiles().Length == 0)
            {
                return(false);
            }

            using (var indexDirectory = LuceneDirectoryFactory.Create(connection, entity)) {
                using (var reader = IndexReader.Open(indexDirectory, true)) {
                    var count = reader.NumDocs();
                    return(count > 0);
                }
            }
        }
示例#2
0
 public void Drop(AbstractConnection connection, Entity entity)
 {
     if (!EntityExists.Exists(connection, entity))
     {
         return;
     }
     new DirectoryInfo(LuceneDirectoryFactory.Path(connection, entity)).Delete(true);
 }
示例#3
0
 public bool Exists(AbstractConnection connection, Entity entity)
 {
     if (!new DirectoryInfo(LuceneDirectoryFactory.Path(connection, entity)).Exists)
     {
         return(false);
     }
     using (var dir = LuceneDirectoryFactory.Create(connection, entity)) {
         return(dir.ListAll().Length > 0);
     }
 }