/// <summary> /// Procesa una copia de archivos /// </summary> private async Task ProcessCopyAsync(BlockLogModel parent, CopySentence sentence) { using (BlockLogModel block = parent.CreateBlock(LogModel.LogType.Info, $"Start copy from '{sentence.Source}' to '{sentence.Target}'")) { string source = Step.Project.GetFullFileName(sentence.Source); string target = Step.Project.GetFullFileName(sentence.Target); try { if (Directory.Exists(source)) { await LibHelper.Files.HelperFiles.CopyPathAsync(source, target, sentence.Mask, sentence.Recursive, sentence.FlattenPaths); } else if (File.Exists(source)) { if (!string.IsNullOrWhiteSpace(Path.GetExtension(target))) { await LibHelper.Files.HelperFiles.CopyFileAsync(source, target); } else { await LibHelper.Files.HelperFiles.CopyFileAsync(source, Path.Combine(target, Path.GetFileName(source))); } } else { AddError(block, $"Cant find source file or path '{source}'"); } } catch (Exception exception) { AddError(block, $"Error when copy '{source}' to '{target}'. {exception.Message}"); } } }
/// <summary> /// Carga la sentencia para descargar un archivo /// </summary> private BaseSentence LoadCopySentence(MLNode rootML) { CopySentence sentence = new CopySentence(); // Carga los datos de la sentencia AssignSentence(sentence, rootML); sentence.Source = rootML.Attributes[TagFrom].Value.TrimIgnoreNull(); sentence.Target = rootML.Attributes[TagTo].Value.TrimIgnoreNull(); sentence.Mask = rootML.Attributes[TagMask].Value.TrimIgnoreNull(); sentence.Recursive = rootML.Attributes[TagRecursive].Value.GetBool(false); sentence.FlattenPaths = rootML.Attributes[TagFlattenPaths].Value.GetBool(false); // Devuelve la sentencia return(sentence); }