예제 #1
0
        /// <summary>
        /// Returns Page object from cache.  If page does not already exist in cache, it
        /// will be read and added to cache
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static Page Read(int id)
        {
            string cacheKey = Page.CacheKey(id);

            ObjectCache cache = MemoryCache.Default;
            Page        page  = cache[cacheKey] as Page;

            if (page != null)
            {
                return(page);
            }
            else
            {
                Rock.CMS.PageService pageService = new CMS.PageService();
                Rock.CMS.Page        pageModel   = pageService.Get(id);
                if (pageModel != null)
                {
                    Rock.Attribute.Helper.LoadAttributes(pageModel);

                    page = Page.CopyModel(pageModel);

                    cache.Set(cacheKey, page, new CacheItemPolicy());

                    return(page);
                }
                else
                {
                    return(null);
                }
            }
        }
예제 #2
0
 /// <summary>
 /// Saves the attribute values for the page
 /// </summary>
 /// <param name="personId">The person id.</param>
 public void SaveAttributeValues(int?personId)
 {
     Rock.CMS.PageService pageService = new CMS.PageService();
     Rock.CMS.Page        pageModel   = pageService.Get(this.Id);
     if (pageModel != null)
     {
         Rock.Attribute.Helper.LoadAttributes(pageModel);
         foreach (var category in pageModel.Attributes)
         {
             foreach (var attribute in category.Value)
             {
                 Rock.Attribute.Helper.SaveAttributeValues(pageModel, attribute, this.AttributeValues[attribute.Key].Value, personId);
             }
         }
     }
 }
예제 #3
0
파일: Page.cs 프로젝트: rowlek/Rock-ChMS
 /// <summary>
 /// Saves the attribute values for the page
 /// </summary>
 /// <param name="personId">The person id.</param>
 public void SaveAttributeValues(int? personId)
 {
     Rock.CMS.PageService pageService = new CMS.PageService();
     Rock.CMS.Page pageModel = pageService.Get( this.Id );
     if ( pageModel != null )
     {
         Rock.Attribute.Helper.LoadAttributes( pageModel );
         foreach ( var category in pageModel.Attributes )
             foreach ( var attribute in category.Value )
                 Rock.Attribute.Helper.SaveAttributeValue( pageModel, attribute, this.AttributeValues[attribute.Key].Value, personId );
     }
 }
예제 #4
0
파일: Page.cs 프로젝트: rowlek/Rock-ChMS
        /// <summary>
        /// Returns Page object from cache.  If page does not already exist in cache, it
        /// will be read and added to cache
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static Page Read( int id )
        {
            string cacheKey = Page.CacheKey( id );

            ObjectCache cache = MemoryCache.Default;
            Page page = cache[cacheKey] as Page;

            if ( page != null )
                return page;
            else
            {
                Rock.CMS.PageService pageService = new CMS.PageService();
                Rock.CMS.Page pageModel = pageService.Get( id );
                if ( pageModel != null )
                {
                    Rock.Attribute.Helper.LoadAttributes( pageModel );

                    page = Page.CopyModel( pageModel );

                    cache.Set( cacheKey, page, new CacheItemPolicy() );

                    return page;
                }
                else
                    return null;

            }
        }