Пример #1
0
        /// <summary>
        ///		Carga una sentencia de borrado
        /// </summary>
        private BaseSentence LoadDeleteSentence(MLNode rootML)
        {
            DeleteSentence sentence = new DeleteSentence();

            // Carga los datos de la sentencia
            AssignSentence(sentence, rootML);
            sentence.Path = rootML.Attributes[TagPath].Value.TrimIgnoreNull();
            sentence.Mask = rootML.Attributes[TagMask].Value.TrimIgnoreNull();
            // Devuelve la sentencia
            return(sentence);
        }
Пример #2
0
        /// <summary>
        ///		Procesa un borrado de archivos
        /// </summary>
        private async Task ProcessDeleteAsync(BlockLogModel parent, DeleteSentence sentence)
        {
            // Evita el warning
            await Task.Delay(1);

            // Borra los archivos / directorios
            using (BlockLogModel block = parent.CreateBlock(LogModel.LogType.Info, $"Start delete '{sentence.Path}'"))
            {
                string path = Step.Project.GetFullFileName(sentence.Path);

                try
                {
                    if (Directory.Exists(path))
                    {
                        if (!string.IsNullOrWhiteSpace(sentence.Mask))
                        {
                            LibHelper.Files.HelperFiles.KillFiles(path, sentence.Mask);
                        }
                        else
                        {
                            LibHelper.Files.HelperFiles.KillPath(path);
                        }
                    }
                    else if (File.Exists(path))
                    {
                        LibHelper.Files.HelperFiles.KillFile(path);
                    }
                    else
                    {
                        block.Info($"Cant find file or path '{path}' for delete");
                    }
                }
                catch (Exception exception)
                {
                    AddError(block, $"Error when delete '{path}'. {exception.Message}");
                }
            }
        }