Exemple #1
0
        protected override long ExecuteWorkImplementation()
        {
            var now = DateTime.UtcNow;

            var latestMetadataResource = m_metadataRepository.GetLatestMetadataResource(m_projectId, false);
            var userEntity             = m_metadataRepository.Load <User>(m_userId);
            var publisherEntity        = m_data.PublisherId != null?m_metadataRepository.Load <Publisher>(m_data.PublisherId) : null;

            Resource resource;
            int      versionNumber;

            if (latestMetadataResource == null)
            {
                var projectEntity = m_metadataRepository.Load <Project>(m_projectId);
                resource = new Resource
                {
                    Name         = "Metadata",
                    Project      = projectEntity,
                    ContentType  = ContentTypeEnum.None,
                    ResourceType = ResourceTypeEnum.ProjectMetadata
                };
                versionNumber = 1;
            }
            else
            {
                resource      = latestMetadataResource.Resource;
                versionNumber = latestMetadataResource.VersionNumber + 1;
            }

            var newResourceVersion = new MetadataResource
            {
                Resource             = resource,
                BiblText             = m_data.BiblText,
                Copyright            = m_data.Copyright,
                CreateTime           = now,
                CreatedByUser        = userEntity,
                ManuscriptCountry    = m_data.ManuscriptCountry,
                ManuscriptExtent     = m_data.ManuscriptExtent,
                ManuscriptSettlement = m_data.ManuscriptSettlement,
                ManuscriptIdno       = m_data.ManuscriptIdno,
                ManuscriptRepository = m_data.ManuscriptRepository,
                NotAfter             = m_data.NotAfter,
                NotBefore            = m_data.NotBefore,
                OriginDate           = m_data.OriginDate,
                PublishDate          = m_data.PublishDate,
                PublishPlace         = m_data.PublishPlace,
                Publisher            = publisherEntity,
                RelicAbbreviation    = m_data.RelicAbbreviation,
                SourceAbbreviation   = m_data.SourceAbbreviation,
                SubTitle             = m_data.SubTitle,
                Title         = m_data.Title,
                VersionNumber = versionNumber
            };

            resource.LatestVersion = newResourceVersion;

            return((long)m_metadataRepository.Create(newResourceVersion));
        }
Exemple #2
0
        protected override int ExecuteWorkImplementation()
        {
            var literaryGenre = new DataEntities.Database.Entities.LiteraryGenre
            {
                Name = m_name
            };

            return((int)m_metadataRepository.Create(literaryGenre));
        }
        protected override int ExecuteWorkImplementation()
        {
            var publisher = new Publisher
            {
                Text  = m_data.Text,
                Email = m_data.Email
            };

            return((int)m_metadataRepository.Create(publisher));
        }
Exemple #4
0
        public bool Logic()
        {
            var logs = new List <Log>();

            try
            {
                logs.Add(new Log(Core.Enums.LogHelpers.LogType.INFO, "Starting Metadata logic", null));

                var showRepo     = new ShowRepository(ConnectionString);
                var metadataRepo = new MetadataRepository(ConnectionString);

                logs.Add(new Log(Core.Enums.LogHelpers.LogType.DEBUG, "Getting shows in database", null));
                var showsInDatabase = showRepo.Select();
                logs.Add(new Log(Core.Enums.LogHelpers.LogType.DEBUG, $"Found {showsInDatabase.Count} shows", null));

                logs.Add(new Log(Core.Enums.LogHelpers.LogType.DEBUG, "Getting metadatas in database", null));
                var metadataInDatabase = metadataRepo.Select();
                logs.Add(new Log(Core.Enums.LogHelpers.LogType.DEBUG, $"Found {metadataInDatabase.Count} shows", null));

                logs.Add(new Log(Core.Enums.LogHelpers.LogType.INFO, $"Getting shows that does not have metadata", null));

                //2433

                var showsWithoutMetadata = (from shows in showsInDatabase
                                            join metadata in metadataInDatabase on shows.Id equals metadata.ShowId into md
                                            from metadata in md.DefaultIfEmpty()
                                            select new { shows }).ToList();

                logs.Add(new Log(Core.Enums.LogHelpers.LogType.INFO, $"Found {showsWithoutMetadata.Count} shows without metadata", null));

                foreach (var show in showsWithoutMetadata)
                {
                    logs.Add(new Log(Core.Enums.LogHelpers.LogType.INFO, $"Looking for {show.shows.Title} metadata", null));
                    var metadata    = GetMetadata(show.shows.Source, show.shows.Url);
                    var newMetadata = new Data.Model.Metadata(show.shows.Id, metadata.ImageUrl, metadata.Plot, metadata.Cast, metadata.Language);
                    metadataRepo.Create(newMetadata);
                    logs.Add(new Log(Core.Enums.LogHelpers.LogType.INFO, $"Metadata added successfully", null));
                }
            }
            catch (Exception e)
            {
                logs.Add(new Log(Core.Enums.LogHelpers.LogType.INFO, e.Message, e.StackTrace));
            }

            logs.Add(new Log(Core.Enums.LogHelpers.LogType.INFO, "Finished Metadata logic", null));

            LogRepository.Create(logs);

            return(true);
        }
Exemple #5
0
        protected override void ExecuteWorkImplementation()
        {
            var dbProjectAuthorList = m_metadataRepository.GetProjectOriginalAuthorList(m_projectId);
            var project             = m_metadataRepository.Load <Project>(m_projectId);

            var itemsToDelete = new List <ProjectOriginalAuthor>();

            foreach (var projectAuthor in dbProjectAuthorList)
            {
                if (!m_authorIdList.Contains(projectAuthor.OriginalAuthor.Id))
                {
                    itemsToDelete.Add(projectAuthor);
                }
            }

            m_metadataRepository.DeleteAll(itemsToDelete);

            var order = 1;

            foreach (var newAuthorId in m_authorIdList)
            {
                var projectAuthor = dbProjectAuthorList.SingleOrDefault(x => x.OriginalAuthor.Id == newAuthorId);
                if (projectAuthor == null)
                {
                    projectAuthor = new ProjectOriginalAuthor
                    {
                        Project        = project,
                        OriginalAuthor = m_metadataRepository.Load <OriginalAuthor>(newAuthorId),
                        Sequence       = order++
                    };
                    m_metadataRepository.Create(projectAuthor);
                }
                else
                {
                    projectAuthor.Sequence = order++;
                    m_metadataRepository.Update(projectAuthor);
                }
            }
        }
        public void UpdateMetadata(long projectId, int userId, BookData bookData)
        {
            var now             = DateTime.UtcNow;
            var lastMetadata    = m_metadataRepository.GetLatestMetadataResource(projectId);
            var firstManuscript = bookData.ManuscriptDescriptions?.FirstOrDefault();

            var authorsString = bookData.Authors != null
                ? string.Join(", ", bookData.Authors.Select(x => x.Name))
                : null;

            var metadata = new MetadataResource
            {
                AuthorsLabel       = authorsString,
                BiblText           = bookData.BiblText,
                Comment            = string.Empty,
                Copyright          = bookData.Copyright,
                CreatedByUser      = m_metadataRepository.Load <User>(userId),
                CreateTime         = now,
                PublisherText      = bookData.Publisher?.Text,
                PublisherEmail     = bookData.Publisher?.Email,
                PublishDate        = bookData.PublishDate,
                PublishPlace       = bookData.PublishPlace,
                SourceAbbreviation = bookData.SourceAbbreviation,
                RelicAbbreviation  = bookData.RelicAbbreviation,
                Title    = bookData.Title,
                SubTitle = bookData.SubTitle
            };

            if (lastMetadata == null)
            {
                var resource = new Resource
                {
                    Project      = m_metadataRepository.Load <Project>(projectId),
                    ContentType  = ContentTypeEnum.None,
                    Name         = "Metadata",
                    ResourceType = ResourceTypeEnum.ProjectMetadata
                };

                metadata.Resource      = resource;
                metadata.VersionNumber = 1;
            }
            else
            {
                metadata.Resource      = lastMetadata.Resource;
                metadata.VersionNumber = lastMetadata.VersionNumber + 1;
            }

            metadata.Resource.LatestVersion = metadata;

            if (firstManuscript != null)
            {
                metadata.ManuscriptSettlement = firstManuscript.Settlement;
                metadata.ManuscriptCountry    = firstManuscript.Country;
                metadata.ManuscriptExtent     = firstManuscript.Extent;
                metadata.ManuscriptIdno       = firstManuscript.Idno;
                metadata.ManuscriptRepository = firstManuscript.Repository;
                metadata.ManuscriptTitle      = firstManuscript.Title;
                metadata.NotBefore            = firstManuscript.NotBefore;
                metadata.NotAfter             = firstManuscript.NotAfter;
                metadata.OriginDate           = firstManuscript.OriginDate;
            }

            m_metadataRepository.Create(metadata);
        }
Exemple #7
0
        private void UpdateMetadata(Project project)
        {
            var now             = DateTime.UtcNow;
            var lastMetadata    = m_metadataRepository.GetLatestMetadataResource(m_projectId);
            var firstManuscript = m_importedRecord.ImportedProject.ProjectMetadata.ManuscriptDescriptionData;

            var authorsString = m_importedRecord.ImportedProject.Authors != null
                ? string.Join(", ", m_importedRecord.ImportedProject.Authors.Select(x => $"{x.LastName} {x.FirstName}"))
                : null;

            var projectMetadata = m_importedRecord.ImportedProject.ProjectMetadata;
            var metadata        = new MetadataResource
            {
                AuthorsLabel       = authorsString,
                BiblText           = projectMetadata.BiblText,
                Copyright          = projectMetadata.Copyright,
                CreatedByUser      = m_metadataRepository.Load <User>(m_userId),
                CreateTime         = now,
                PublisherText      = projectMetadata.PublisherText,
                PublisherEmail     = projectMetadata.PublisherEmail,
                PublishDate        = projectMetadata.PublishDate,
                PublishPlace       = projectMetadata.PublishPlace,
                SourceAbbreviation = projectMetadata.SourceAbbreviation,
                RelicAbbreviation  = projectMetadata.RelicAbbreviation,
                Title    = projectMetadata.Title,
                SubTitle = projectMetadata.SubTitle
            };

            if (lastMetadata == null)
            {
                var resource = new Resource
                {
                    Project      = project,
                    ContentType  = ContentTypeEnum.None,
                    Name         = "Metadata",
                    ResourceType = ResourceTypeEnum.ProjectMetadata
                };

                metadata.Resource      = resource;
                metadata.VersionNumber = 1;
            }
            else
            {
                metadata.Resource      = lastMetadata.Resource;
                metadata.VersionNumber = lastMetadata.VersionNumber + 1;
            }

            metadata.Resource.LatestVersion = metadata;

            if (firstManuscript != null)
            {
                metadata.ManuscriptSettlement = firstManuscript.Settlement;
                metadata.ManuscriptCountry    = firstManuscript.Country;
                metadata.ManuscriptExtent     = firstManuscript.Extent;
                metadata.ManuscriptIdno       = firstManuscript.Idno;
                metadata.ManuscriptRepository = firstManuscript.Repository;
                metadata.ManuscriptTitle      = firstManuscript.Title;
                metadata.NotBefore            = firstManuscript.NotBefore;
                metadata.NotAfter             = firstManuscript.NotAfter;
                metadata.OriginDate           = firstManuscript.OriginDate;
            }

            m_metadataRepository.Create(metadata);
        }