private string DumpResult(FileSortingExecution entry)
        {
            const string format = "{0,-80} | {1}";
            const string formatSubInformations = "{0,80} | {1}";

            var sb = new StringBuilder();

            if (entry.FileWasProcessed)
            {
                sb.AppendFormat(format, entry.SourceFile.FullPath, entry.DestinationPath != null ? entry.DestinationPath.FullPath : string.Empty);
                sb.AppendLine();
                if (entry.MatchingFileFilterName != null)
                {
                    sb.AppendFormat(formatSubInformations, "Matching FileFilter", entry.MatchingFileInformationFilterName);
                    sb.AppendLine();
                }
                if (entry.FileInformation != null)
                {
                    foreach (var info in entry.FileInformation)
                    {
                        sb.AppendFormat(formatSubInformations, info.Key, info.Value);
                        sb.AppendLine();
                    }
                }
                if (entry.MatchingFileInformationFilterName != null)
                {
                    sb.AppendFormat(formatSubInformations, "Matching FileInformationFilter", entry.MatchingFileInformationFilterName);
                    sb.AppendLine();
                }
                if (entry.Error != null)
                {
                    sb.AppendFormat(formatSubInformations, "Error", entry.Error.ToString());
                    sb.AppendLine();
                }
                sb.AppendLine();
            }

            return(sb.ToString());
        }
        private void Execute(FileSortingExecution execution, FileSorting sorting)
        {
            _logger.Debug("Executing file filter");
            var fileFilterWasMatching = true;

            foreach (var filter in sorting.FileFilter)
            {
                if (filter.MatchFile(execution.SourceFile))
                {
                    execution.MatchingFileFilterName = filter.Name ?? string.Empty;
                    fileFilterWasMatching            = true;
                    break;
                }
                fileFilterWasMatching = false;
            }

            if (!fileFilterWasMatching)
            {
                _logger.Debug("No Filter matching for file {0}", execution.SourceFile.FullPath);
                execution.FileWasProcessed = false;
                return;
            }

            execution.FileWasProcessed = true;

            _logger.Debug("Extracting informations from file {0}", execution.SourceFile.FullPath);
            var fileInformations = sorting.FileInformationExtractor.Select(x => x.ExtractInformation(execution.SourceFile));

            execution.FileInformation = MergeFileInformation(fileInformations);

            _logger.Debug("Mapping informations from file {0}", execution.SourceFile.FullPath);
            foreach (var mapper in sorting.FileInformationMapper)
            {
                execution.FileInformation = mapper.MapInformation(execution.FileInformation);
            }

            _logger.Debug("Executing fileInformation filter");
            var fileInformationFilterWasMatching = true;

            foreach (var filter in sorting.FileInformationFilter)
            {
                if (filter.MatchFile(execution.SourceFile, execution.FileInformation))
                {
                    execution.MatchingFileInformationFilterName = filter.Name ?? string.Empty;
                    fileInformationFilterWasMatching            = true;
                    break;
                }
                fileInformationFilterWasMatching = false;
            }

            if (!fileInformationFilterWasMatching)
            {
                _logger.Debug("No fileInformation Filter matching for file {0}", execution.SourceFile.FullPath);
                return;
            }

            _logger.Debug("Creating new file path for file {0}", execution.SourceFile.FullPath);
            execution.DestinationPath = sorting.FilePathCreator.CreateDestinationPath(execution.FileInformation, execution.SourceFile);

            if (sorting.BackupFilePathCreator != null)
            {
                _logger.Debug("Creating backup file path for file {0}", execution.SourceFile.FullPath);
                execution.BackupPath = sorting.BackupFilePathCreator.CreateDestinationPath(execution.FileInformation, execution.SourceFile);

                _logger.Debug("Backuping file {0}", execution.SourceFile.FullPath);
                sorting.FileMover.ProcessFileBackup(execution.SourceFile, execution.BackupPath);
            }

            _logger.Debug("Moving file {0}", execution.SourceFile.FullPath);
            sorting.FileMover.ProcessFileSort(execution.SourceFile, execution.DestinationPath);

            _logger.Debug("Change content of file {0}", execution.DestinationPath.FullPath);
            foreach (var contentChanger in sorting.FileContentChanger)
            {
                contentChanger.ChangeContent(execution.DestinationPath);
            }

            _logger.Debug("Indexing file {0}", execution.DestinationPath.FullPath);
            foreach (var indexer in sorting.FileIndexer)
            {
                indexer.IndexFile(execution.DestinationPath);
            }
        }