Example #1
0
        public void scandir(string ADirectory)
        {
            string[] directorys = Directory.GetDirectories(ADirectory);
            string[] files = Directory.GetFiles(ADirectory);

            // recherche des directorys
            IEnumerator  dirEnumerator = directorys.GetEnumerator();
            while ( !_stoped && dirEnumerator.MoveNext() )
            {
                this.scandir((string)dirEnumerator.Current);
            }

            // Recherche des fichiers dans le repertoire
            IEnumerator fileEnumerator = files.GetEnumerator();
            while ( !_stoped && fileEnumerator.MoveNext() )
            {
                FileInfo fileinfo = new FileInfo((string)fileEnumerator.Current);
                OnFile(fileinfo);

                //bool ignoreindex = Array.IndexOf(_toindex,fileinfo.Extension.ToUpper())==-1;

                int docId = database.addFile(fileinfo);
                Indexer indexer = new Indexer(@" \-_.~",3);
                indexer.ParseText(fileinfo.FullName);

                IDictionaryEnumerator myEnumerator = indexer.keywords.GetEnumerator();
                while ( myEnumerator.MoveNext() )
                {
                    database.addDocumentKeyword(docId,myEnumerator.Key.ToString(),Convert.ToInt32(myEnumerator.Value.ToString()));
                }

            }

            if ( _stoped ) return;

            DirectoryInfo dirinfo = new DirectoryInfo(ADirectory);
            OnDirectory(dirinfo);
            database.addDirectory(dirinfo);
        }
Example #2
0
        private void button2_Click(object sender, System.EventArgs e)
        {
            Document doc = database.GetNextIndex();
            while (!_stop && doc.Id!=-1)
            {
                statusBar1.Text = "Indexe le document" + doc.Nom;
                Application.DoEvents();

                try
                {
                    Indexer indexer = new Indexer(" ,.:'\"",3);
                    indexer.ParseFile(doc.Nom);
                    indexer.Save(doc.Id);

                    doc.Etat="OK";
                    database.updateFileInfo(ref doc);

                }
                catch (Exception E)
                {
                    doc.Etat="Erreur";
                    database.updateFileInfo(ref doc);
                }

                doc = database.GetNextIndex();
            }
        }