public IEnumerable <ResolvedContentType> ResolveContentTypes(
            IEnumerable <ContentReference> contentLinks)
        {
            var contentReferences = contentLinks as ContentReference[] ?? contentLinks.ToArray();

            var result = new List <ResolvedContentType>();

            result.AddRange(contentReferences
                            .Where(l => _referenceConverter.GetContentType(l) == CatalogContentType.Catalog)
                            .Select(l => new ResolvedContentType(l, _catalogContentType)));

            var nodeContentLinks =
                contentReferences.Where(l => _referenceConverter.GetContentType(l) == CatalogContentType.CatalogNode);
            var nodeIds = nodeContentLinks.Select(l => _referenceConverter.GetObjectId(l));

            var entryLinks =
                contentReferences.Where(l => _referenceConverter.GetContentType(l) == CatalogContentType.CatalogEntry);
            var entryIds = entryLinks.Select(l => _referenceConverter.GetObjectId(l));

            var ds = LoadMetaClassNames(entryIds, nodeIds);

            result.AddRange(ResolveContentTypes(ds.Tables[0], CatalogContentType.CatalogEntry));
            result.AddRange(ResolveContentTypes(ds.Tables[1], CatalogContentType.CatalogNode));

            return(result);
        }
Exemplo n.º 2
0
        public IDictionary <ContentReference, ContentType> ResolveContentTypes(
            IEnumerable <ContentReference> contentLinks)
        {
            var result = new Dictionary <ContentReference, ContentType>();
            var catalogContentLinks =
                contentLinks.Where(l => _referenceConverter.GetContentType(l) == CatalogContentType.Catalog);

            foreach (var catalogContentLink in catalogContentLinks)
            {
                result.Add(catalogContentLink, _catalogContentType);
            }

            var notCachedLinks = new List <ContentReference>();

            foreach (var contentLink in contentLinks)
            {
                var cached = _cache.Get(GetCacheKey(contentLink)) as ContentType;
                if (cached != null)
                {
                    result.Add(contentLink, cached);
                }
                else
                {
                    notCachedLinks.Add(contentLink);
                }
            }

            var nodeContentLinks =
                notCachedLinks.Where(l => _referenceConverter.GetContentType(l) == CatalogContentType.CatalogNode);
            var nodeIds = nodeContentLinks.Select(l => _referenceConverter.GetObjectId(l));

            var entryLinks =
                notCachedLinks.Where(l => _referenceConverter.GetContentType(l) == CatalogContentType.CatalogEntry);
            var entryIds = entryLinks.Select(l => _referenceConverter.GetObjectId(l));

            var ds = LoadMetaClassNames(entryIds, nodeIds);

            foreach (var keyPair in ResolveContentTypes(ds.Tables[0], CatalogContentType.CatalogEntry))
            {
                result.Add(keyPair.Key, keyPair.Value);
                _cache.Insert(GetCacheKey(keyPair.Key), keyPair.Value, _cacheEvictionPolicyFunc(keyPair.Key));
            }

            foreach (var keyPair in ResolveContentTypes(ds.Tables[1], CatalogContentType.CatalogNode))
            {
                result.Add(keyPair.Key, keyPair.Value);
                _cache.Insert(GetCacheKey(keyPair.Key), keyPair.Value, _cacheEvictionPolicyFunc(keyPair.Key));
            }

            return(result);
        }
Exemplo n.º 3
0
        public void CheckReferenceConverter()
        {
            // variationController has demo code for "Loading examples"
            ContentReference theRef = _referenceConverter.GetContentLink("Shirts_1");
            int theInt = _referenceConverter.GetObjectId(theRef);

            CatalogContentType theType = _referenceConverter.GetContentType(theRef);

            ContentReference theSameRef = _referenceConverter.GetContentLink
                                              (theInt, CatalogContentType.CatalogNode, 0);

            string theCode = _referenceConverter.GetCode(theSameRef);

            ContentReference catalogRoot = _referenceConverter.GetRootLink();

            List <string> codes = new List <string>
            {
                "Shirts_1",
                "Men_1"
            };

            IDictionary <string, ContentReference> theDict;

            theDict = _referenceConverter.GetContentLinks(codes);
        }
        public void CheckReferenceConverter(ContentReference contentReference, AdminViewModel model)
        {
            RefInfo refInfo = new RefInfo();

            refInfo.Ref         = contentReference;
            refInfo.Code        = _referenceConverter.GetCode(contentReference);
            refInfo.DbId        = _referenceConverter.GetObjectId(contentReference);
            refInfo.CatalogType = _referenceConverter.GetContentType(contentReference).ToString();
            refInfo.RootRef     = _referenceConverter.GetRootLink();

            model.Refs.Add(refInfo);
        }
Exemplo n.º 5
0
        private void OnDeletedContent(object sender, DeleteContentEventArgs e)
        {
            Logger.Debug("OnDeletedContent raised.");

            ContentReference deletedContentLink = e.ContentLink;

            if (ContentReference.IsNullOrEmpty(deletedContentLink) ||
                deletedContentLink.ProviderName != ReferenceConverter.CatalogProviderKey)
            {
                Logger.Debug("Deleted content is not catalog content.");
                return;
            }

            CatalogContentType catalogContentType = _referenceConverter.GetContentType(deletedContentLink);

            if (catalogContentType != CatalogContentType.CatalogNode)
            {
                Logger.Debug("Deleted content is not a catalog node.");
                return;
            }

            // Force a full category structure re-export. This has to be done AFTER the category has been deleted.
            _categoryExportService.StartFullCategoryExport();
        }