Beispiel #1
0
        /// <summary>
        ///		Carga una sentencia de conversión de archivo
        /// </summary>
        private BaseSentence LoadConvertFileSentence(MLNode rootML)
        {
            ConvertFileSentence sentence = new ConvertFileSentence();

            // Carga los datos
            AssignSentence(sentence, rootML);
            sentence.FileNameSource  = rootML.Attributes[TagFrom].Value.TrimIgnoreNull();
            sentence.FileNameTarget  = rootML.Attributes[TagTo].Value.TrimIgnoreNull();
            sentence.ExcelSheetIndex = rootML.Attributes[TagExcelSheetIndex].Value.GetInt(1);
            sentence.ExcelWithHeader = rootML.Attributes[TagExcelWithHeader].Value.GetBool(true);
            // Carga las columnas
            sentence.Columns.AddRange(LoadColumns(rootML));
            // Devuelve la sentencia
            return(sentence);
        }
Beispiel #2
0
        /// <summary>
        ///		Convierte un archivo
        /// </summary>
        private async Task ProcessConvertFileAsync(BlockLogModel parent, ConvertFileSentence sentence, CancellationToken cancellationToken)
        {
            using (BlockLogModel block = parent.CreateBlock(LogModel.LogType.Info, $"Start convert file '{sentence.FileNameSource}' to {sentence.FileNameTarget}"))
            {
                string source = Step.Project.GetFullFileName(sentence.FileNameSource);
                string target = Step.Project.GetFullFileName(sentence.FileNameTarget);

                if (!File.Exists(source))
                {
                    AddError(block, $"Cant find the file '{source}'");
                }
                else
                {
                    await ConvertFileAsync(block, source, target, GetExcelOptions(sentence.ExcelWithHeader, sentence.ExcelSheetIndex), cancellationToken);
                }
            }
        }