Exemple #1
0
        public async Task <bool> ExecuteAsync()
        {
            await LogMessageActionAsync(LogLevel.Info, string.Concat("Executing Task with id: ", this.Id.ToString()));
            await LogMessageActionAsync(LogLevel.Debug, string.Concat("Executing Task on ", this.Path.ToString(), " with ", this.Pattern.Pattern, " as patern"));

            FileInfo[] matchingFiles = FilesManager.GetMatchingFiles(Path, Pattern);

            if (matchingFiles == null || matchingFiles.Length == 0)
            {
                await LogMessageActionAsync(LogLevel.Debug, "No matching files found");

                return(matchingFiles == null && matchingFiles.Length == 0);
            }

            await LogMessageActionAsync(LogLevel.Info, string.Format("Found {0} files", matchingFiles.Length));

            bool succeded = true;

            foreach (FileInfo fi in matchingFiles)
            {
                CurrentFile = fi;
                try
                {
                    await executionManager.ExecuteJob(fi, this.JobStepsGroups);
                }
                catch (Exception e)
                {
                    LogMessageActionAsync(LogLevel.Error, string.Format("Error: {0} - Stack {1}", e.Message, e.StackTrace)).RunSynchronously();
                }
            }

            await LogMessageActionAsync(LogLevel.Debug, "All files have been processed");

            return(succeded);
        }