Example #1
0
        private ImportDecision <LocalEdition> GetDecision(LocalEdition localEdition, DownloadClientItem downloadClientItem)
        {
            ImportDecision <LocalEdition> decision = null;

            if (localEdition.Edition == null)
            {
                decision = new ImportDecision <LocalEdition>(localEdition, new Rejection($"Couldn't find similar book for {localEdition}"));
            }
            else
            {
                var reasons = _bookSpecifications.Select(c => EvaluateSpec(c, localEdition, downloadClientItem))
                              .Where(c => c != null);

                decision = new ImportDecision <LocalEdition>(localEdition, reasons.ToArray());
            }

            if (decision == null)
            {
                _logger.Error("Unable to make a decision on {0}", localEdition);
            }
            else if (decision.Rejections.Any())
            {
                _logger.Debug("Book rejected for the following reasons: {0}", string.Join(", ", decision.Rejections));
            }
            else
            {
                _logger.Debug("Book accepted");
            }

            return(decision);
        }
Example #2
0
        private ImportDecision <LocalBook> GetDecision(LocalBook localBook, DownloadClientItem downloadClientItem)
        {
            ImportDecision <LocalBook> decision = null;

            if (localBook.Book == null)
            {
                decision = new ImportDecision <LocalBook>(localBook, new Rejection($"Couldn't parse book from: {localBook.FileTrackInfo}"));
            }
            else
            {
                var reasons = _trackSpecifications.Select(c => EvaluateSpec(c, localBook, downloadClientItem))
                              .Where(c => c != null);

                decision = new ImportDecision <LocalBook>(localBook, reasons.ToArray());
            }

            if (decision == null)
            {
                _logger.Error("Unable to make a decision on {0}", localBook.Path);
            }
            else if (decision.Rejections.Any())
            {
                _logger.Debug("File rejected for the following reasons: {0}", string.Join(", ", decision.Rejections));
            }
            else
            {
                _logger.Debug("File accepted");
            }

            return(decision);
        }
Example #3
0
        public ImportResult(ImportDecision <LocalBook> importDecision, params string[] errors)
        {
            Ensure.That(importDecision, () => importDecision).IsNotNull();

            ImportDecision = importDecision;
            Errors         = errors.ToList();
        }