Esempio n. 1
0
        public PageSiteNodeModel GetPageSiteNodeModelByKey(Guid id)
        {
            if (id == Guid.Empty)
            {
                return(null);
            }
            // Construct the cache key
            string cacheKey = CacheUtilities.BuildCacheKey(NavigationSubControl.cacheKey, id.ToString());
            var    model    = (PageSiteNodeModel)CacheUtilities.CacheManagerGlobal[cacheKey];

            if (model == null)
            {
                lock (this.nodeDataLock)
                {
                    model = (PageSiteNodeModel)CacheUtilities.CacheManagerGlobal[cacheKey];
                    if (model == null)
                    {
                        // Get the page node
                        PageManager manager = PageManager.GetManager();
                        var         node    = manager.GetPageNode(id);

                        // Get the models from the node fields
                        var relatedPage = this.GetRelatedPageModel(node, "RelatedPage");

                        var relatedImage = this.GetRelatedImageModel(node, "RelatedImage");

                        string additionalInfo = node.GetValue <Lstring>("AdditionalInfo");

                        // Build the Model
                        model = new PageSiteNodeModel(relatedPage, relatedImage,
                                                      additionalInfo);

                        // Add the model in the cache
                        CacheUtilities.CacheManagerGlobal.Add(
                            cacheKey,
                            model,
                            CacheItemPriority.Normal,
                            null,
                            // Add cache dependency for automatic invalidation
                            new DataItemCacheDependency(typeof(PageNode), id),
                            // Configure sliding time
                            new SlidingTime(TimeSpan.FromMinutes(20)));
                    }
                }
            }

            return(model);
        }
        public ConferenceModel GetConferenceModelById(Guid id, string provider)
        {
            if (id == Guid.Empty)
            {
                return(null);
            }
            // Construct the cache key
            string cacheKey = CacheUtilities.BuildCacheKey(ConferenceSubControl.cacheKey, id.ToString());
            var    model    = (ConferenceModel)CacheUtilities.CacheManagerGlobal[cacheKey];

            if (model == null)
            {
                lock (this.nodeDataLock)
                {
                    model = (ConferenceModel)CacheUtilities.CacheManagerGlobal[cacheKey];
                    if (model == null)
                    {
                        // Get the conference item
                        DynamicModuleManager manager = DynamicModuleManager.GetManager(provider);
                        Type latestHotTopicsType     = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.Conferences.Conference");

                        DynamicContent conference = manager.GetDataItem(latestHotTopicsType, id);
                        // Build the Model
                        model = this.PopulateModel(conference);

                        // Add the model in the cache
                        CacheUtilities.CacheManagerGlobal.Add(
                            cacheKey,
                            model,
                            CacheItemPriority.Normal,
                            null,
                            // Add cache dependency for automatic invalidation
                            new DataItemCacheDependency(typeof(DynamicContent), id),
                            // Configure sliding time
                            new SlidingTime(TimeSpan.FromMinutes(20)));
                    }
                }
            }

            return(model);
        }