private long CreateBookVersionResource(Resource resource, int version, string versionExternalId, User user, DateTime now)
        {
            var newDbBookVersion = new BookVersionResource
            {
                Resource      = resource,
                ExternalId    = versionExternalId,
                VersionNumber = version,
                Comment       = string.Empty,
                CreateTime    = now,
                CreatedByUser = user,
            };

            resource.LatestVersion = newDbBookVersion;
            var resultId = m_resourceRepository.Create(newDbBookVersion);

            return((long)resultId);
        }
Exemple #2
0
        public virtual ProjectIdentificationResult GetProjectIdentification(long projectId)
        {
            ProjectIdentificationResult resultAlias      = null;
            Snapshot            snapshotAlias            = null;
            BookVersionResource bookVersionResourceAlias = null;

            var dbResult = GetSession().QueryOver <Project>()
                           .JoinAlias(x => x.LatestPublishedSnapshot, () => snapshotAlias)
                           .JoinAlias(() => snapshotAlias.BookVersion, () => bookVersionResourceAlias, JoinType.LeftOuterJoin)
                           .SelectList(list => list
                                       .Select(x => x.Id).WithAlias(() => resultAlias.ProjectId)
                                       .Select(x => x.ExternalId).WithAlias(() => resultAlias.ProjectExternalId)
                                       .Select(() => snapshotAlias.Id).WithAlias(() => resultAlias.SnapshotId)
                                       .Select(() => bookVersionResourceAlias.ExternalId).WithAlias(() => resultAlias.BookVersionExternalId)
                                       .Select(x => x.ProjectType).WithAlias(() => resultAlias.ProjectType)
                                       )
                           .Where(x => x.Id == projectId && x.IsRemoved == false)
                           .TransformUsing(Transformers.AliasToBean <ProjectIdentificationResult>())
                           .SingleOrDefault <ProjectIdentificationResult>();

            return(dbResult);
        }
Exemple #3
0
        private void CreateHeadwordResource(int version, Resource resource, List <BookHeadwordData> headwordDataList, User user, DateTime now, BookVersionResource bookVersion, Dictionary <string, PageResource> dbPagesByImage)
        {
            var firstHeadwordData = headwordDataList.First();

            var newDbHeadword = new HeadwordResource
            {
                Resource        = resource,
                BookVersion     = bookVersion,
                Comment         = null,
                CreateTime      = now,
                CreatedByUser   = user,
                VersionNumber   = version,
                HeadwordItems   = null, // Headword Items are created in following for-each
                ExternalId      = firstHeadwordData.XmlEntryId,
                DefaultHeadword = firstHeadwordData.DefaultHeadword,
                Sorting         = firstHeadwordData.SortOrder,
            };

            resource.LatestVersion = newDbHeadword;

            m_resourceRepository.Create(newDbHeadword);
            m_importedResourceVersionIds.Add(newDbHeadword.Id);

            foreach (var bookHeadwordData in headwordDataList)
            {
                var dbPage            = GetPageResourceByImage(dbPagesByImage, bookHeadwordData.Image);
                var newDbHeadwordItem = new HeadwordItem
                {
                    HeadwordResource = newDbHeadword,
                    Headword         = bookHeadwordData.Headword,
                    HeadwordOriginal = bookHeadwordData.HeadwordOriginal,
                    ResourcePage     = dbPage?.Resource
                };
                m_resourceRepository.Create(newDbHeadwordItem);
            }
        }
        private long CreateEditionNoteResource(Resource resource, int version, User user, DateTime now, BookVersionResource bookVersion)
        {
            var newDbEditionNote = new EditionNoteResource
            {
                Resource      = resource,
                BookVersion   = bookVersion,
                VersionNumber = version,
                Comment       = string.Empty,
                CreateTime    = now,
                CreatedByUser = user,
            };

            resource.LatestVersion = newDbEditionNote;
            var resultId = m_resourceRepository.Create(newDbEditionNote);

            return((long)resultId);
        }