本文整理汇总了C#中Rock.Model.PageService.Queryable方法的典型用法代码示例。如果您正苦于以下问题:C# PageService.Queryable方法的具体用法?C# PageService.Queryable怎么用?C# PageService.Queryable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.PageService
的用法示例。
在下文中一共展示了PageService.Queryable方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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>();
PageService pageService = new PageService( new RockContext() );
if ( Page.IsPostBack )
{
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\">" );
var allPages = pageService.Queryable( "Pages, Blocks, Blocks.BlockType" ).ToList();
foreach ( var page in allPages.Where( a => a.ParentPageId == null ).OrderBy( a => a.Order ).ThenBy( a => a.InternalName ) )
{
sb.Append( PageNode( page, expandedPageIds ) );
}
sb.AppendLine( "</ul>" );
lPages.Text = sb.ToString();
}
示例2: OnInit
/// <summary>
/// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
/// </summary>
/// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
protected override void OnInit( EventArgs e )
{
base.OnInit( e );
PageService pageService = new PageService();
var sb = new StringBuilder();
sb.AppendLine( "<ul id=\"treeview\">" );
var allPages = pageService.Queryable( "Pages, Blocks, Blocks.BlockType" ).ToList();
foreach ( var page in allPages.Where( a => a.ParentPageId == null ).OrderBy( a => a.Order ).ThenBy( a => a.InternalName ) )
{
sb.Append( PageNode( page ) );
}
sb.AppendLine( "</ul>" );
lPages.Text = sb.ToString();
}
示例3: BindGrid
private void BindGrid()
{
string type = PageParameter( "SearchType" );
string term = PageParameter( "SearchTerm" );
if ( !string.IsNullOrWhiteSpace( type ) && !string.IsNullOrWhiteSpace( term ) )
{
term = term.Trim();
type = type.Trim().ToLower();
var terms = term.Split( ' ' );
var pageService = new PageService( new RockContext() );
var pages = new List<Page>();
switch ( type )
{
case ( "name" ):
{
pages = pageService.Queryable().ToList().Where( p => Regex.IsMatch( p.PageTitle, String.Join("\\w* ", terms.Select(t => Regex.Escape(t))), RegexOptions.IgnoreCase ) ).ToList();
break;
}
}
if ( pages.Count == 1 )
{
NavigateToPage( pages[0].Guid, null );
Context.ApplicationInstance.CompleteRequest();
}
else
{
gPages.DataKeyNames = new string[] { "Guid" };
gPages.EntityTypeId = EntityTypeCache.GetId<Page>();
gPages.DataSource = pages.Select( p => new
{
p.Guid,
p.PageTitle,
Structure = ParentStructure( p ),
Site = p.Layout.Site.Name
} ).ToList();
gPages.DataBind();
}
}
}
示例4: OnInit
/// <summary>
/// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
/// </summary>
/// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
protected override void OnInit( EventArgs e )
{
base.OnInit( e );
PageService pageService = new PageService( new RockContext() );
List<int> expandedPageIds = new List<int>();
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\">" );
var allPages = pageService.Queryable( "Pages, Blocks, Blocks.BlockType" ).ToList();
foreach ( var page in allPages.Where( a => a.ParentPageId == null ).OrderBy( a => a.Order ).ThenBy( a => a.InternalName ) )
{
sb.Append( PageNode( page, expandedPageIds ) );
}
sb.AppendLine( "</ul>" );
lPages.Text = sb.ToString();
}
示例5: 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 )
{
if ( !Page.IsPostBack && _pageId.HasValue )
{
var rockContext = new RockContext();
LoadSites( rockContext );
PageService pageService = new PageService( rockContext );
Rock.Model.Page page = pageService.Queryable( "Layout,PageRoutes" )
.Where( p => p.Id == _pageId.Value )
.FirstOrDefault();
if ( page.Layout != null )
{
ddlSite.SelectedValue = page.Layout.SiteId.ToString();
LoadLayouts( rockContext, SiteCache.Read( page.Layout.SiteId ) );
ddlLayout.SelectedValue = page.Layout.Id.ToString();
}
rptProperties.DataSource = _tabs;
rptProperties.DataBind();
tbPageName.Text = page.InternalName;
tbPageTitle.Text = page.PageTitle;
tbBrowserTitle.Text = page.BrowserTitle;
ppParentPage.SetValue( pageService.Get( page.ParentPageId ?? 0 ) );
tbIconCssClass.Text = page.IconCssClass;
cbPageTitle.Checked = page.PageDisplayTitle;
cbPageBreadCrumb.Checked = page.PageDisplayBreadCrumb;
cbPageIcon.Checked = page.PageDisplayIcon;
cbPageDescription.Checked = page.PageDisplayDescription;
ddlMenuWhen.SelectedValue = ( (int)page.DisplayInNavWhen ).ToString();
cbMenuDescription.Checked = page.MenuDisplayDescription;
cbMenuIcon.Checked = page.MenuDisplayIcon;
cbMenuChildPages.Checked = page.MenuDisplayChildPages;
cbBreadCrumbIcon.Checked = page.BreadCrumbDisplayIcon;
cbBreadCrumbName.Checked = page.BreadCrumbDisplayName;
cbRequiresEncryption.Checked = page.RequiresEncryption;
cbEnableViewState.Checked = page.EnableViewState;
cbIncludeAdminFooter.Checked = page.IncludeAdminFooter;
tbCacheDuration.Text = page.OutputCacheDuration.ToString();
tbDescription.Text = page.Description;
ceHeaderContent.Text = page.HeaderContent;
tbPageRoute.Text = string.Join( ",", page.PageRoutes.Select( route => route.Route ).ToArray() );
// Add enctype attribute to page's <form> tag to allow file upload control to function
Page.Form.Attributes.Add( "enctype", "multipart/form-data" );
}
base.OnLoad( e );
}
示例6: LoadDropDowns
/// <summary>
/// Loads the drop downs.
/// </summary>
private void LoadDropDowns()
{
PageService pageService = new PageService();
List<Rock.Model.Page> allPages = pageService.Queryable().ToList();
ddlDefaultPage.DataSource = allPages.OrderBy( a => a.PageSortHash );
ddlDefaultPage.DataBind();
ddlTheme.Items.Clear();
DirectoryInfo di = new DirectoryInfo( this.Page.Request.MapPath( this.CurrentTheme ) );
foreach ( var themeDir in di.Parent.EnumerateDirectories().OrderBy( a => a.Name ) )
{
ddlTheme.Items.Add( new ListItem( themeDir.Name, themeDir.Name ) );
}
}
示例7: BindPagesGrid
/// <summary>
/// Binds the pages grid.
/// </summary>
protected void BindPagesGrid()
{
pnlPages.Visible = false;
int siteId = PageParameter( "siteId" ).AsInteger();
if ( siteId == 0 )
{
// quit if the siteId can't be determined
return;
}
hfSiteId.SetValue( siteId );
pnlPages.Visible = true;
// Question: Is this RegisterLayouts necessary here? Since if it's a new layout
// there would not be any pages on them (which is our concern here).
// It seems like it should be the concern of some other part of the puzzle.
LayoutService.RegisterLayouts( Request.MapPath( "~" ), SiteCache.Read( siteId ) );
//var layouts = layoutService.Queryable().Where( a => a.SiteId.Equals( siteId ) ).Select( a => a.Id ).ToList();
// Find all the pages that are related to this site...
// 1) pages used by one of this site's layouts and
// 2) the site's 'special' pages used directly by the site.
var rockContext = new RockContext();
var siteService = new SiteService( rockContext );
var pageService = new PageService( rockContext );
var site = siteService.Get( siteId );
if ( site != null )
{
var sitePages = new List<int> {
site.DefaultPageId ?? -1,
site.LoginPageId ?? -1,
site.RegistrationPageId ?? -1,
site.PageNotFoundPageId ?? -1
};
var qry = pageService.Queryable("Layout")
.Where( t =>
t.Layout.SiteId == siteId ||
sitePages.Contains( t.Id ) );
string layoutFilter = gPagesFilter.GetUserPreference( "Layout" );
if ( !string.IsNullOrWhiteSpace( layoutFilter ) && layoutFilter != Rock.Constants.All.Text )
{
qry = qry.Where( a => a.Layout.ToString() == layoutFilter );
}
SortProperty sortProperty = gPages.SortProperty;
if ( sortProperty != null )
{
qry = qry.Sort( sortProperty );
}
else
{
qry = qry
.OrderBy( t => t.Layout.Name )
.ThenBy( t => t.InternalName );
}
gPages.DataSource = qry.ToList();
gPages.DataBind();
}
}
示例8: GeneratePageBlockAuths
/// <summary>
/// Copies any auths for the original pages and blocks over to the copied pages and blocks.
/// </summary>
/// <param name="pageGuidDictionary">The dictionary containing the original page guids and the corresponding copied page guids.</param>
/// <param name="blockGuidDictionary">The dictionary containing the original block guids and the corresponding copied block guids.</param>
/// <param name="rockContext">The rock context.</param>
/// <param name="currentPersonAliasId">The current person alias identifier.</param>
private void GeneratePageBlockAuths( Dictionary<Guid, Guid> pageGuidDictionary, Dictionary<Guid, Guid> blockGuidDictionary, RockContext rockContext, int? currentPersonAliasId = null )
{
var authService = new AuthService( rockContext );
var pageService = new PageService( rockContext );
var blockService = new BlockService( rockContext );
var pageGuid = Rock.SystemGuid.EntityType.PAGE.AsGuid();
var blockGuid = Rock.SystemGuid.EntityType.BLOCK.AsGuid();
Dictionary<Guid, int> pageIntDictionary = pageService.Queryable()
.Where( p => pageGuidDictionary.Keys.Contains( p.Guid ) || pageGuidDictionary.Values.Contains( p.Guid ) )
.ToDictionary( p => p.Guid, p => p.Id );
Dictionary<Guid, int> blockIntDictionary = blockService.Queryable()
.Where( p => blockGuidDictionary.Keys.Contains( p.Guid ) || blockGuidDictionary.Values.Contains( p.Guid ) )
.ToDictionary( p => p.Guid, p => p.Id );
var pageAuths = authService.Queryable().Where( a =>
a.EntityType.Guid == pageGuid && pageIntDictionary.Values.Contains( a.EntityId.Value ) )
.ToList();
var blockAuths = authService.Queryable().Where( a =>
a.EntityType.Guid == blockGuid && blockIntDictionary.Values.Contains( a.EntityId.Value ) )
.ToList();
foreach ( var pageAuth in pageAuths )
{
var newPageAuth = pageAuth.Clone( false );
newPageAuth.CreatedByPersonAlias = null;
newPageAuth.CreatedByPersonAliasId = currentPersonAliasId;
newPageAuth.CreatedDateTime = RockDateTime.Now;
newPageAuth.ModifiedByPersonAlias = null;
newPageAuth.ModifiedByPersonAliasId = currentPersonAliasId;
newPageAuth.ModifiedDateTime = RockDateTime.Now;
newPageAuth.Id = 0;
newPageAuth.Guid = Guid.NewGuid();
newPageAuth.EntityId = pageIntDictionary[pageGuidDictionary[pageIntDictionary.Where( d => d.Value == pageAuth.EntityId.Value ).FirstOrDefault().Key]];
authService.Add( newPageAuth );
}
foreach ( var blockAuth in blockAuths )
{
var newBlockAuth = blockAuth.Clone( false );
newBlockAuth.CreatedByPersonAlias = null;
newBlockAuth.CreatedByPersonAliasId = currentPersonAliasId;
newBlockAuth.CreatedDateTime = RockDateTime.Now;
newBlockAuth.ModifiedByPersonAlias = null;
newBlockAuth.ModifiedByPersonAliasId = currentPersonAliasId;
newBlockAuth.ModifiedDateTime = RockDateTime.Now;
newBlockAuth.Id = 0;
newBlockAuth.Guid = Guid.NewGuid();
newBlockAuth.EntityId = blockIntDictionary[blockGuidDictionary[blockIntDictionary.Where( d => d.Value == blockAuth.EntityId.Value ).FirstOrDefault().Key]];
authService.Add( newBlockAuth );
}
rockContext.SaveChanges();
}
示例9: btnDeleteConfirm_Click
/// <summary>
/// Handles the Click event of the btnDeleteConfirm 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 btnDeleteConfirm_Click( object sender, EventArgs e )
{
bool canDelete = false;
var rockContext = new RockContext();
SiteService siteService = new SiteService( rockContext );
Site site = siteService.Get( int.Parse( hfSiteId.Value ) );
LayoutService layoutService = new LayoutService( rockContext );
PageService pageService = new PageService( rockContext );
PageViewService pageViewService = new PageViewService( rockContext );
if ( site != null )
{
var sitePages = new List<int> {
site.DefaultPageId ?? -1,
site.LoginPageId ?? -1,
site.RegistrationPageId ?? -1,
site.PageNotFoundPageId ?? -1
};
foreach ( var pageView in pageViewService
.Queryable()
.Where( t =>
t.Page != null &&
t.Page.Layout != null &&
t.Page.Layout.SiteId == site.Id ) )
{
pageView.Page = null;
pageView.PageId = null;
}
var pageQry = pageService.Queryable( "Layout" )
.Where( t =>
t.Layout.SiteId == site.Id ||
sitePages.Contains( t.Id ) );
pageService.DeleteRange( pageQry );
var layoutQry = layoutService.Queryable()
.Where( l =>
l.SiteId == site.Id );
layoutService.DeleteRange( layoutQry );
rockContext.SaveChanges( true );
string errorMessage;
canDelete = siteService.CanDelete( site, out errorMessage, includeSecondLvl: true );
if ( !canDelete )
{
mdDeleteWarning.Show( errorMessage, ModalAlertType.Alert );
return;
}
siteService.Delete( site );
rockContext.SaveChanges();
SiteCache.Flush( site.Id );
}
NavigateToParentPage();
}
示例10: 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 )
{
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 ) );
}
sb.AppendLine( "</ul>" );
lPages.Text = sb.ToString();
}
示例11: Search
/// <summary>
/// Returns a list of matching people
/// </summary>
/// <param name="searchterm"></param>
/// <returns></returns>
public override IQueryable<string> Search( string searchterm )
{
var rootPageGuid = GetAttributeValue( "RootPage" ).AsGuid();
var terms = searchterm.Split( ' ' );
var pageServ = new PageService( new RockContext() );
IEnumerable<Page> pages;
var rootPage = pageServ.Get( rootPageGuid );
if ( rootPage != null )
{
pages = pageServ.GetAllDescendents( rootPage.Id );
}
else
{
pages = pageServ.Queryable();
}
return pages.ToList().Where( p => Regex.IsMatch( p.PageTitle, String.Join( "\\w* ", terms.Select( t => Regex.Escape( t ) ) ), RegexOptions.IgnoreCase ) ).Select( p => p.PageTitle ).AsQueryable();
}
示例12: LoadDropDowns
/// <summary>
/// Loads the drop downs.
/// </summary>
private void LoadDropDowns()
{
PageService pageService = new PageService();
List<Rock.Model.Page> allPages = pageService.Queryable().ToList();
ddlPageName.DataSource = allPages.OrderBy( a => a.PageSortHash );
ddlPageName.DataBind();
}