Beispiel #1
0
        public void should_return_json_string_when_saving_boolean_to_db()
        {
            var command = new RefreshAuthorCommand();

            Subject.SetValue(_param, command);
            _param.Value.Should().BeOfType <string>();
        }
Beispiel #2
0
        public void Execute(RefreshAuthorCommand message)
        {
            var trigger = message.Trigger;
            var isNew   = message.IsNewAuthor;

            if (message.AuthorId.HasValue)
            {
                RefreshSelectedAuthors(new List <int> {
                    message.AuthorId.Value
                }, isNew, trigger);
            }
            else
            {
                var updated   = false;
                var authors   = _authorService.GetAllAuthors().OrderBy(c => c.Name).ToList();
                var authorIds = authors.Select(x => x.Id).ToList();

                var updatedGoodreadsAuthors = new HashSet <string>();

                if (message.LastExecutionTime.HasValue && message.LastExecutionTime.Value.AddDays(14) > DateTime.UtcNow)
                {
                    updatedGoodreadsAuthors = _authorInfo.GetChangedAuthors(message.LastStartTime.Value);
                }

                foreach (var author in authors)
                {
                    var manualTrigger = message.Trigger == CommandTrigger.Manual;

                    if ((updatedGoodreadsAuthors == null && _checkIfAuthorShouldBeRefreshed.ShouldRefresh(author)) ||
                        (updatedGoodreadsAuthors != null && updatedGoodreadsAuthors.Contains(author.ForeignAuthorId)) ||
                        manualTrigger)
                    {
                        try
                        {
                            LogProgress(author);
                            var data = GetSkyhookData(author.ForeignAuthorId);
                            updated |= RefreshEntityInfo(author, null, data, manualTrigger, false, message.LastStartTime);
                        }
                        catch (Exception e)
                        {
                            _logger.Error(e, "Couldn't refresh info for {0}", author);
                        }
                    }
                    else
                    {
                        _logger.Info("Skipping refresh of author: {0}", author.Name);
                    }
                }

                Rescan(authorIds, isNew, trigger, updated);
            }
        }
Beispiel #3
0
        private Author GivenArtist(string foreignAuthorId, int metadataProfileId)
        {
            var artist = _addAuthorService.AddAuthor(new Author
            {
                Metadata = new AuthorMetadata
                {
                    ForeignAuthorId = foreignAuthorId
                },
                Path = @"c:\test".AsOsAgnostic(),
                MetadataProfileId = metadataProfileId
            });

            var command = new RefreshAuthorCommand
            {
                AuthorId = artist.Id,
                Trigger  = CommandTrigger.Unspecified
            };

            _refreshArtistService.Execute(command);

            return(_authorService.FindById(foreignAuthorId));
        }