private ArrayList GuardarDocumentos(string directory, HtmlPageDecorator decorator, WebIndex indexer) { // Intentar unificar nodos que quedarian vacios, con solo el titulo de la seccion: foreach( NodoArbol nodo in tree.Raiz.Hijos ) UnificarNodos( nodo ); // Recorrer el arbol en busca de nodos con cuerpo ArrayList archivosGenerados = new ArrayList(); foreach (NodoArbol nodo in tree.Raiz.Hijos) GuardarDocumentos(directory, decorator, nodo, archivosGenerados, indexer); return archivosGenerados; }
private void GuardarDocumentos(string directory, HtmlPageDecorator decorator, NodoArbol nodo, ArrayList archivosGenerados, WebIndex indexer) { if( nodo.body != null ) { string texto = ""; if( nodo.body.innerText != null ) texto = nodo.body.innerText.Trim(); if( !texto.Equals("") ) { bool guardar = true; string titulo = ""; IHTMLElement seccion = null; seccion = SearchFirstCutNode( nodo.body ); if( seccion != null && seccion.innerText != null ) { titulo = seccion.innerText.Trim() ; if( titulo.Length == 0 ) guardar = false; } if( guardar ) { // hacer un preproceso de TODOS los nodos del cuerpo: IHTMLElementCollection col = (IHTMLElementCollection)nodo.body.children; foreach( IHTMLElement nodoBody in col ) PreprocessHtmlNode( nodoBody , null); // Save the section, adding header, footers, etc: string filePath = directory + Path.DirectorySeparatorChar + nodo.Archivo; decorator.ProcessAndSavePage(nodo.body, filePath, nodo.Name); if (FirstChapterContent == null) { // This is the first chapter of the document. Store it clean, because // we will need after. FirstChapterContent = nodo.body.innerHTML.Replace("about:blank", "").Replace("about:", ""); } archivosGenerados.Add(filePath); if (indexer != null) // Store the document at the full text search index: //indexer.AddPage(nodo.Archivo, nodo.Title, nodo.body); indexer.AddPage(nodo.Archivo, nodo.Name, nodo.body); } } } foreach( NodoArbol hijo in nodo.Hijos ) GuardarDocumentos( directory , decorator , hijo , archivosGenerados , indexer ); }