Esempio n. 1
0
        private bool LoadMediaFromDatabaseLocked(bool onStartup)
        {
            // locks & notes: see content
            var mediaTypes = _serviceContext.MediaTypeService.GetAll()
                             .Select(x => _publishedContentTypeFactory.CreateContentType(x));

            _mediaStore.SetAllContentTypesLocked(mediaTypes);

            using (_profilingLogger.TraceDuration <PublishedSnapshotService>("Loading media from database"))
            {
                // beware! at that point the cache is inconsistent,
                // assuming we are going to SetAll content items!
                _localMediaDb?.Clear();

                _logger.LogDebug("Loading media from database...");
                // IMPORTANT GetAllMediaSources sorts kits by level + parentId + sortOrder
                var kits = _publishedContentService.GetAllMediaSources();
                return(onStartup ? _mediaStore.SetAllFastSortedLocked(kits, true) : _mediaStore.SetAllLocked(kits));
            }
        }
Esempio n. 2
0
        private bool LoadContentFromDatabaseLocked(bool onStartup)
        {
            // locks:
            // contentStore is wlocked (1 thread)
            // content (and types) are read-locked

            var contentTypes = _serviceContext.ContentTypeService.GetAll().ToList();

            _contentStore.SetAllContentTypesLocked(contentTypes.Select(x => _publishedContentTypeFactory.CreateContentType(x)));

            using (_profilingLogger.TraceDuration <PublishedSnapshotService>("Loading content from database"))
            {
                // beware! at that point the cache is inconsistent,
                // assuming we are going to SetAll content items!

                _localContentDb?.Clear();

                // IMPORTANT GetAllContentSources sorts kits by level + parentId + sortOrder
                var kits = _publishedContentService.GetAllContentSources();
                return(onStartup ? _contentStore.SetAllFastSortedLocked(kits, true) : _contentStore.SetAllLocked(kits));
            }
        }