当前位置: 首页>>代码示例>>C#>>正文


C# PageService.CopyPage方法代码示例

本文整理汇总了C#中Rock.Model.PageService.CopyPage方法的典型用法代码示例。如果您正苦于以下问题:C# PageService.CopyPage方法的具体用法?C# PageService.CopyPage怎么用?C# PageService.CopyPage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Rock.Model.PageService的用法示例。


在下文中一共展示了PageService.CopyPage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnLoad

        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad( EventArgs e )
        {
            base.OnLoad( e );

            List<int> expandedPageIds = new List<int>();
            RockContext rockContext = new RockContext();
            PageService pageService = new PageService( rockContext );

            var allPages = pageService.Queryable( "PageContexts, PageRoutes" );

            foreach ( var page in allPages )
            {
                PageCache.Read( page );
            }

            foreach ( var block in new BlockService(rockContext).Queryable() )
            {
                BlockCache.Read( block );
            }

            foreach ( var blockType in new BlockTypeService( rockContext ).Queryable() )
            {
                BlockTypeCache.Read( blockType );
            }

            if ( Page.IsPostBack )
            {
                if ( Request.Form["__EVENTTARGET"] == "CopyPage" )
                {
                    // Fire event
                    int? intPageId = Request.Form["__EVENTARGUMENT"].AsIntegerOrNull();
                    if ( intPageId.HasValue )
                    {
                        Guid? pageGuid = pageService.CopyPage( intPageId.Value, CurrentPersonAliasId );
                        if ( pageGuid.HasValue )
                        {
                            NavigateToPage( pageGuid.Value, null );
                        }
                        else
                        {
                            NavigateToCurrentPage();
                        }
                    }
                }

                foreach ( string expandedId in hfExpandedIds.Value.Split( new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries ) )
                {
                    int id = 0;
                    if ( expandedId.StartsWith( "p" ) && expandedId.Length > 1 )
                    {
                        if ( int.TryParse( expandedId.Substring( 1 ), out id ) )
                        {
                            expandedPageIds.Add( id );
                        }
                    }
                }
            }
            else
            {
                string pageSearch = this.PageParameter( "pageSearch" );
                if ( !string.IsNullOrWhiteSpace( pageSearch ) )
                {
                    foreach ( Page page in pageService.Queryable().Where( a => a.InternalName.IndexOf( pageSearch ) >= 0 ) )
                    {
                        Page selectedPage = page;
                        while ( selectedPage != null )
                        {
                            selectedPage = selectedPage.ParentPage;
                            if ( selectedPage != null )
                            {
                                expandedPageIds.Add( selectedPage.Id );
                            }
                        }
                    }
                }
            }

            var sb = new StringBuilder();

            sb.AppendLine( "<ul id=\"treeview\">" );

            string rootPage = GetAttributeValue("RootPage");
            if ( ! string.IsNullOrEmpty( rootPage ) )
            {
                Guid pageGuid = rootPage.AsGuid();
                allPages = allPages.Where( a => a.ParentPage.Guid == pageGuid );
            }
            else
            {
                allPages = allPages.Where( a => a.ParentPageId == null );
            }

            foreach ( var page in allPages.OrderBy( a => a.Order ).ThenBy( a => a.InternalName ).Include(a => a.Blocks).ToList() )
            {
                sb.Append( PageNode( PageCache.Read( page ), expandedPageIds, rockContext ) );
            }
//.........这里部分代码省略.........
开发者ID:NewSpring,项目名称:Rock,代码行数:101,代码来源:PageMap.ascx.cs

示例2: rGrid_Copy

        /// <summary>
        /// Handles the Copy event of the rGrid control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void rGrid_Copy( object sender, RowEventArgs e )
        {
            var pageService = new PageService( new RockContext() );
            pageService.CopyPage( e.RowKeyId, CurrentPersonAliasId );

            BindGrid();
        }
开发者ID:NewSpring,项目名称:Rock,代码行数:12,代码来源:Pages.ascx.cs


注:本文中的Rock.Model.PageService.CopyPage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。