/// <summary>
        ///		Copia los archivos
        /// </summary>
        private void CopyFiles(string sourcePath, string targetPath, NormalizedDictionary <object> parameters)
        {
            // Crea el directorio
            //? Sí, está dos veces, no sé porqué si se ejecuta dos veces consecutivas este método, la segunda vez no crea el directorio a menos que
            //? ejecute dos veces la instrucción
            HelperFiles.MakePath(targetPath);
            HelperFiles.MakePath(targetPath);
            // Copia los archivos
            foreach (string file in System.IO.Directory.EnumerateFiles(sourcePath))
            {
                if (MustCopy(file))
                {
                    string targetFile = System.IO.Path.Combine(targetPath, System.IO.Path.GetFileName(file));

                    // Copia los archivos de Python sin cambios, los de SQL los convierte
                    if (file.EndsWith(".py", StringComparison.CurrentCultureIgnoreCase))
                    {
                        SaveFileWithoutBom(targetFile, HelperFiles.LoadTextFile(file));
                    }
                    else if (file.EndsWith(".sql", StringComparison.CurrentCultureIgnoreCase))
                    {
                        SaveFileWithoutBom(targetFile, TransformSql(file, parameters));
                    }
                }
            }
        }
        /// <summary>
        ///		Crea el documento de las páginas
        /// </summary>
        private void CreatePage(string strBookTitle, string pathTemp, DocWriterFactory writerFactory, DocumentModel documentRoot, IndexItem page)
        {
            string fileName = GetFileName(pathTemp, page);

            // Crea la página
            if (File.Exists(fileName))
            {
                string        content = ConvertPageToNhtml(HelperFiles.LoadTextFile(fileName));
                DocumentModel document;

                // Si hay algo que meter en el documento ...
                if (!content.IsEmpty())
                {
                    document = writerFactory.CreatePage(documentRoot,
                                                        $"{page.PageNumber:000}. {page.Name}",
                                                        strBookTitle + " - " + page.Name,
                                                        documentRoot.Description + " - " + page.Name,
                                                        documentRoot.KeyWords, content);
                }
                else
                {
                    document = documentRoot;
                }
                // Crea los documentos de las páginas hija
                if (page.Items != null && page.Items.Count > 0)
                {
                    foreach (IndexItem item in page.Items)
                    {
                        CreatePage(strBookTitle, pathTemp, writerFactory, document, item);
                    }
                }
            }
        }
        /// <summary>
        ///		Obtiene el contenido normalizado de un notebook
        /// </summary>
        private string NormalizeNotebookContent(string fileName)
        {
            string content = HelperFiles.LoadTextFile(fileName);

            // Sustituye los argumentos de tipo $Xxxx por getArgument("xxxx")
            content = ConvertArgumentsToGetArgument(content, "$");
            // Pasa los nombres de archivo a minúsculas
            ConvertFileNameToLower(content);
            // Devuelve la cadena normalizada
            return(content);
        }
Exemple #4
0
        /// <summary>
        ///		Carga las líneas de un archivo
        /// </summary>
        private List <string> LoadLines()
        {
            List <string> objColLines = new List <string>();
            string        strContent  = HelperFiles.LoadTextFile(FileName);

            // Carga el archivo y lo separa en líneas
            if (!strContent.IsEmpty())
            {
                objColLines = strContent.SplitByString("\n");
            }
            // Devuelve las líneas del archivo
            return(objColLines);
        }