本文整理汇总了C#中Rock.Model.PageService.Get方法的典型用法代码示例。如果您正苦于以下问题:C# PageService.Get方法的具体用法?C# PageService.Get怎么用?C# PageService.Get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.PageService
的用法示例。
在下文中一共展示了PageService.Get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyPage
/// <summary>
/// Copies the page.
/// </summary>
/// <param name="pageId">The page identifier.</param>
/// <param name="currentPersonAliasId">The current person alias identifier.</param>
public Guid? CopyPage( int pageId, int? currentPersonAliasId = null )
{
var rockContext = new RockContext();
var pageService = new PageService( rockContext );
Guid? newPageGuid = null;
var page = pageService.Get( pageId );
if ( page != null )
{
Dictionary<Guid, Guid> pageGuidDictionary = new Dictionary<Guid, Guid>();
Dictionary<Guid, Guid> blockGuidDictionary = new Dictionary<Guid, Guid>();
var newPage = GeneratePageCopy( page, pageGuidDictionary, blockGuidDictionary, currentPersonAliasId );
pageService.Add( newPage );
rockContext.SaveChanges();
if ( newPage.ParentPageId.HasValue )
{
PageCache.Flush( newPage.ParentPageId.Value );
}
newPageGuid= newPage.Guid;
GenerateBlockAttributeValues( pageGuidDictionary, blockGuidDictionary, rockContext, currentPersonAliasId );
GeneratePageBlockAuths( pageGuidDictionary, blockGuidDictionary, rockContext, currentPersonAliasId );
CloneHtmlContent( blockGuidDictionary, rockContext, currentPersonAliasId );
}
return newPageGuid;
}
示例2: FormatValue
/// <summary>
/// Returns the field's current value(s)
/// </summary>
/// <param name="parentControl">The parent control.</param>
/// <param name="value">Information about the value</param>
/// <param name="configurationValues">The configuration values.</param>
/// <param name="condensed">Flag indicating if the value should be condensed (i.e. for use in a grid column)</param>
/// <returns></returns>
public override string FormatValue( System.Web.UI.Control parentControl, string value, Dictionary<string, ConfigurationValue> configurationValues, bool condensed )
{
string formattedValue = string.Empty;
if ( !string.IsNullOrWhiteSpace( value ) )
{
var service = new PageService();
var page = service.Get( new Guid( value ) );
if ( page != null )
{
formattedValue = page.InternalName;
}
}
return base.FormatValue( parentControl, formattedValue, null, condensed );
}
示例3: masterPage_OnSave
/// <summary>
/// Handles the OnSave event of the masterPage 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 masterPage_OnSave( object sender, EventArgs e )
{
Page.Validate( BlockValidationGroup );
if ( Page.IsValid && _pageId.HasValue )
{
var rockContext = new RockContext();
var pageService = new PageService( rockContext );
var routeService = new PageRouteService( rockContext );
var contextService = new PageContextService( rockContext );
var page = pageService.Get( _pageId.Value );
// validate/check for removed routes
var editorRoutes = tbPageRoute.Text.SplitDelimitedValues().Distinct();
var databasePageRoutes = page.PageRoutes.ToList();
var deletedRouteIds = new List<int>();
var addedRoutes = new List<string>();
if ( editorRoutes.Any() )
{
// validate for any duplicate routes
var duplicateRoutes = routeService.Queryable()
.Where( r => editorRoutes.Contains( r.Route ) && r.PageId != _pageId )
.Select( r => r.Route )
.Distinct()
.ToList();
if ( duplicateRoutes.Any() )
{
// Duplicate routes
nbPageRouteWarning.Title = "Duplicate Route(s)";
nbPageRouteWarning.Text = string.Format( "<p>The page route <strong>{0}</strong>, already exists for another page. Please choose a different route name.</p>", duplicateRoutes.AsDelimited( "</strong> and <strong>" ) );
nbPageRouteWarning.Dismissable = true;
nbPageRouteWarning.Visible = true;
CurrentTab = "Advanced Settings";
rptProperties.DataSource = _tabs;
rptProperties.DataBind();
ShowSelectedPane();
return;
}
}
// validate if removed routes can be deleted
foreach ( var pageRoute in databasePageRoutes )
{
if ( !editorRoutes.Contains( pageRoute.Route ) )
{
// make sure the route can be deleted
string errorMessage;
if ( !routeService.CanDelete( pageRoute, out errorMessage ) )
{
nbPageRouteWarning.Text = string.Format( "The page route <strong>{0}</strong>, cannot be removed. {1}", pageRoute.Route, errorMessage );
nbPageRouteWarning.NotificationBoxType = NotificationBoxType.Warning;
nbPageRouteWarning.Dismissable = true;
nbPageRouteWarning.Visible = true;
CurrentTab = "Advanced Settings";
rptProperties.DataSource = _tabs;
rptProperties.DataBind();
ShowSelectedPane();
return;
}
}
}
// take care of deleted routes
foreach ( var pageRoute in databasePageRoutes )
{
if ( !editorRoutes.Contains( pageRoute.Route ) )
{
// if they removed the Route, remove it from the database
page.PageRoutes.Remove( pageRoute );
routeService.Delete( pageRoute );
deletedRouteIds.Add( pageRoute.Id );
}
}
// take care of added routes
foreach ( string route in editorRoutes )
{
// if they added the Route, add it to the database
if ( !databasePageRoutes.Any( a => a.Route == route ) )
{
var pageRoute = new PageRoute();
pageRoute.Route = route.TrimStart( new char[] { '/' } );
pageRoute.Guid = Guid.NewGuid();
page.PageRoutes.Add( pageRoute );
addedRoutes.Add( route );
}
}
int parentPageId = ppParentPage.SelectedValueAsInt() ?? 0;
if ( page.ParentPageId != parentPageId )
//.........这里部分代码省略.........
示例4: lbExport_Click
/// <summary>
/// Handles the Click event of the lbExport 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 lbExport_Click( object sender, EventArgs e )
{
if ( _pageId.HasValue )
{
var pageService = new PageService( new RockContext() );
var page = pageService.Get( _pageId.Value );
var packageService = new PackageService();
var pageName = page.InternalName.Replace( " ", "_" ) + ( cbExportChildren.Checked ? "_wChildPages" : string.Empty );
using ( var stream = packageService.ExportPage( page, cbExportChildren.Checked ) )
{
EnableViewState = false;
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AddHeader( "content-disposition", "attachment; filename=" + pageName + ".nupkg" );
Response.Charset = string.Empty;
Response.BinaryWrite( stream.ToArray() );
Response.Flush();
Response.End();
}
}
}
示例5: gPages_Delete
/// <summary>
/// Handles the Delete event of the gPages control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="RowEventArgs" /> instance containing the event data.</param>
protected void gPages_Delete( object sender, RowEventArgs e )
{
var rockContext = new RockContext();
PageService pageService = new PageService( rockContext );
var pageViewService = new PageViewService(rockContext);
var siteService = new SiteService(rockContext);
Rock.Model.Page page = pageService.Get( new Guid( e.RowKeyValue.ToString() ) );
if ( page != null )
{
string errorMessage;
if ( !pageService.CanDelete( page, out errorMessage, includeSecondLvl: true ) )
{
mdGridWarning.Show( errorMessage, ModalAlertType.Alert );
return;
}
foreach (var site in siteService.Queryable())
{
if (site.DefaultPageId == page.Id)
{
site.DefaultPageId = null;
site.DefaultPageRouteId = null;
}
if (site.LoginPageId == page.Id)
{
site.LoginPageId = null;
site.LoginPageRouteId = null;
}
if (site.RegistrationPageId == page.Id)
{
site.RegistrationPageId = null;
site.RegistrationPageRouteId = null;
}
}
foreach (var pageView in pageViewService.GetByPageId(page.Id))
{
pageView.Page = null;
pageView.PageId = null;
}
pageService.Delete( page );
rockContext.SaveChanges();
PageCache.Flush( page.Id );
}
BindPagesGrid();
}
示例6: lbSave_Click
protected void lbSave_Click( object sender, EventArgs e )
{
if ( updatePage )
{
var pageCache = PageCache.Read( RockPage.PageId );
if ( pageCache != null &&
( pageCache.PageTitle != tbName.Text || pageCache.Description != tbDesc.Text ) )
{
var rockContext = new RockContext();
var service = new PageService( rockContext );
var page = service.Get( pageCache.Id );
page.InternalName = tbName.Text;
page.PageTitle = tbName.Text;
page.BrowserTitle = tbName.Text;
page.Description = tbDesc.Text;
rockContext.SaveChanges();
Rock.Web.Cache.PageCache.Flush( page.Id );
pageCache = PageCache.Read( RockPage.PageId );
var breadCrumb = RockPage.BreadCrumbs.Where( c => c.Url == RockPage.PageReference.BuildUrl() ).FirstOrDefault();
if ( breadCrumb != null )
{
breadCrumb.Name = pageCache.BreadCrumbText;
}
}
}
SetAttributeValue( "Query", ceQuery.Text );
SetAttributeValue( "QueryParams", tbParams.Text );
SetAttributeValue( "UrlMask", tbUrlMask.Text );
SetAttributeValue( "Columns", tbColumns.Text );
SetAttributeValue( "ShowColumns", ddlHideShow.SelectedValue );
SetAttributeValue( "FormattedOutput", ceFormattedOutput.Text );
SetAttributeValue( "PersonReport", cbPersonReport.Checked.ToString() );
SetAttributeValue( "MergeFields", tbMergeFields.Text );
SaveAttributeValues();
ShowView();
}
示例7: rGrid_Delete
protected void rGrid_Delete( object sender, RowEventArgs e )
{
var rockContext = new RockContext();
var pageService = new PageService( rockContext );
var pageViewService = new PageViewService( rockContext );
var siteService = new SiteService( rockContext );
var page = pageService.Get( (int)rGrid.DataKeys[e.RowIndex]["id"] );
if ( page != null )
{
string errorMessage = string.Empty;
if ( !pageService.CanDelete( page, out errorMessage ) )
{
//errorMessage = "The page is the parent page of another page.";
mdDeleteWarning.Show( errorMessage, ModalAlertType.Alert );
return;
}
foreach ( var site in siteService.Queryable() )
{
if ( site.DefaultPageId == page.Id )
{
site.DefaultPageId = null;
site.DefaultPageRouteId = null;
}
if ( site.LoginPageId == page.Id )
{
site.LoginPageId = null;
site.LoginPageRouteId = null;
}
if ( site.RegistrationPageId == page.Id )
{
site.RegistrationPageId = null;
site.RegistrationPageRouteId = null;
}
}
// TODO: Could be thousands of page views. Can we set this up as cascade?
foreach( var pageView in pageViewService.GetByPageId(page.Id))
{
pageViewService.Delete( pageView );
}
pageService.Delete( page );
rockContext.SaveChanges();
Rock.Web.Cache.PageCache.Flush( page.Id );
if ( _page != null )
{
_page.FlushChildPages();
}
}
BindGrid();
}
示例8: BindExceptionListFilter
/// <summary>
/// Binds the exception list filter.
/// </summary>
private void BindExceptionListFilter()
{
BindSitesFilter();
int siteId;
var rockContext = new RockContext();
if ( int.TryParse( fExceptionList.GetUserPreference( "Site" ), out siteId )
&& ddlSite.Items.FindByValue( siteId.ToString() ) != null )
{
ddlSite.SelectedValue = siteId.ToString();
}
int pageId;
if ( int.TryParse( fExceptionList.GetUserPreference( "Page" ), out pageId ) )
{
PageService pageService = new PageService( rockContext );
ppPage.SetValue( pageService.Get( pageId ) );
}
else
{
ppPage.SetValue( None.Id );
}
int userPersonId;
if ( int.TryParse( fExceptionList.GetUserPreference( "User" ), out userPersonId ) )
{
PersonService personService = new PersonService( rockContext );
ppUser.SetValue( personService.Get( userPersonId ) );
}
if ( !String.IsNullOrEmpty( fExceptionList.GetUserPreference( "Status Code" ) ) )
{
txtStatusCode.Text = fExceptionList.GetUserPreference( "Status Code" );
}
DateTime startDate;
if ( DateTime.TryParse( fExceptionList.GetUserPreference( "Start Date" ), out startDate ) )
{
dpStartDate.Text = startDate.ToShortDateString();
}
DateTime endDate;
if ( DateTime.TryParse( fExceptionList.GetUserPreference( "End Date" ), out endDate ) )
{
dpEndDate.Text = endDate.ToShortDateString();
}
}
示例9: rGrid_Delete
/// <summary>
/// Handles the Delete event of the rGrid control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="RowEventArgs"/> instance containing the event data.</param>
protected void rGrid_Delete( object sender, RowEventArgs e )
{
var rockContext = new RockContext();
var pageService = new PageService( rockContext );
var pageViewService = new PageViewService( rockContext );
var siteService = new SiteService( rockContext );
var page = pageService.Get( e.RowKeyId );
if ( page != null )
{
string errorMessage = string.Empty;
if ( !pageService.CanDelete( page, out errorMessage ) )
{
mdDeleteWarning.Show( errorMessage, ModalAlertType.Alert );
return;
}
foreach ( var site in siteService.Queryable() )
{
if ( site.DefaultPageId == page.Id )
{
site.DefaultPageId = null;
site.DefaultPageRouteId = null;
}
if ( site.LoginPageId == page.Id )
{
site.LoginPageId = null;
site.LoginPageRouteId = null;
}
if ( site.RegistrationPageId == page.Id )
{
site.RegistrationPageId = null;
site.RegistrationPageRouteId = null;
}
}
foreach ( var pageView in pageViewService.GetByPageId( page.Id ) )
{
pageView.Page = null;
pageView.PageId = null;
}
pageService.Delete( page );
rockContext.SaveChanges();
Rock.Web.Cache.PageCache.Flush( page.Id );
if ( _page != null )
{
_page.FlushChildPages();
}
}
BindGrid();
}
示例10: 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();
}
示例11: gPages_Delete
/// <summary>
/// Handles the Delete event of the gPages control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="RowEventArgs" /> instance containing the event data.</param>
protected void gPages_Delete( object sender, RowEventArgs e )
{
bool canDelete = false;
var rockContext = new RockContext();
PageService pageService = new PageService( rockContext );
Rock.Model.Page page = pageService.Get( new Guid( e.RowKeyValue.ToString() ) );
if ( page != null )
{
string errorMessage;
canDelete = pageService.CanDelete( page, out errorMessage, includeSecondLvl: true );
if ( !canDelete )
{
mdGridWarning.Show( errorMessage, ModalAlertType.Alert );
return;
}
pageService.Delete( page );
rockContext.SaveChanges();
PageCache.Flush( page.Id );
}
BindPagesGrid();
}
示例12: BindGrid
/// <summary>
/// Binds the grid.
/// </summary>
private void BindGrid()
{
var rockContext = new RockContext();
var htmlContentService = new HtmlContentService( rockContext );
var htmlContent = htmlContentService.Queryable();
string pageName = "";
string siteName = "";
var htmlList = new List<HtmlApproval>();
foreach ( var content in htmlContent )
{
content.Block.LoadAttributes();
var blah = content.Block.GetAttributeValue( "RequireApproval" );
if ( !string.IsNullOrEmpty( blah ) && blah.ToLower() == "true" )
{
var pageService = new PageService( rockContext );
if ( content.Block.PageId != null )
{
var page = pageService.Get( (int)content.Block.PageId );
if ( page != null )
{
pageName = page.InternalName;
while ( page.ParentPageId != null )
{
page = pageService.Get( (int)page.ParentPageId );
}
var siteService = new SiteService( rockContext );
siteName = siteService.GetByDefaultPageId( page.Id ).Select( s => s.Name ).FirstOrDefault();
}
}
var htmlApprovalClass = new HtmlApproval();
htmlApprovalClass.SiteName = siteName;
htmlApprovalClass.PageName = pageName;
htmlApprovalClass.Block = content.Block;
htmlApprovalClass.BlockId = content.BlockId;
htmlApprovalClass.Content = content.Content;
htmlApprovalClass.Id = content.Id;
htmlApprovalClass.IsApproved = content.IsApproved;
htmlApprovalClass.ApprovedByPerson = content.ApprovedByPerson;
htmlApprovalClass.ApprovedByPersonId = content.ApprovedByPersonId;
htmlApprovalClass.ApprovedDateTime = content.ApprovedDateTime;
htmlList.Add( htmlApprovalClass );
}
}
// Filter by Site
if ( ddlSiteFilter.SelectedIndex > 0 )
{
if ( ddlSiteFilter.SelectedValue.ToLower() != "all" )
{
htmlList = htmlList.Where( h => h.SiteName == ddlSiteFilter.SelectedValue ).ToList();
}
}
// Filter by approved/unapproved
if ( ddlApprovedFilter.SelectedIndex > -1 )
{
if ( ddlApprovedFilter.SelectedValue.ToLower() == "unapproved" )
{
htmlList = htmlList.Where( a => a.IsApproved == false ).ToList();
}
else if ( ddlApprovedFilter.SelectedValue.ToLower() == "approved" )
{
htmlList = htmlList.Where( a => a.IsApproved == true ).ToList();
}
}
// Filter by the person that approved the content
if ( _canApprove )
{
int personId = 0;
if ( int.TryParse( gContentListFilter.GetUserPreference( "Approved By" ), out personId ) && personId != 0 )
{
htmlList = htmlList.Where( a => a.ApprovedByPersonId.HasValue && a.ApprovedByPersonId.Value == personId ).ToList();
}
}
SortProperty sortProperty = gContentList.SortProperty;
if ( sortProperty != null )
{
gContentList.DataSource = htmlList.AsQueryable().Sort( sortProperty ).ToList();
}
else
{
gContentList.DataSource = htmlList.OrderBy( h => h.Id ).ToList();
}
gContentList.DataBind();
}
示例13: fExceptionList_DisplayFilterValue
/// <summary>
/// Build filter values/summary with user friendly data from filters
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The e.</param>
protected void fExceptionList_DisplayFilterValue( object sender, GridFilter.DisplayFilterValueArgs e )
{
switch ( e.Key )
{
case "Site":
int siteId;
if ( int.TryParse( e.Value, out siteId ) )
{
SiteService siteService = new SiteService();
var site = siteService.Get( siteId );
if ( site != null )
{
e.Value = site.Name;
}
}
break;
case "Page":
int pageId;
if ( int.TryParse( e.Value, out pageId ) )
{
PageService pageService = new PageService();
var page = pageService.Get( pageId );
if ( page != null )
{
e.Value = page.InternalName;
}
}
break;
case "User":
int userPersonId;
if ( int.TryParse( e.Value, out userPersonId ) )
{
PersonService personService = new PersonService();
var user = personService.Get( userPersonId );
if ( user != null )
{
e.Value = user.FullName;
}
}
break;
}
}
示例14: rGrid_Delete
protected void rGrid_Delete( object sender, RowEventArgs e )
{
using ( new UnitOfWorkScope() )
{
var pageService = new PageService();
var siteService = new SiteService();
var page = pageService.Get( (int)rGrid.DataKeys[e.RowIndex]["id"] );
if ( page != null )
{
RockTransactionScope.WrapTransaction( () =>
{
foreach ( var site in siteService.Queryable() )
{
bool updateSite = false;
if (site.DefaultPageId == page.Id)
{
site.DefaultPageId = null;
site.DefaultPageRouteId = null;
updateSite = true;
}
if (site.LoginPageId == page.Id)
{
site.LoginPageId = null;
site.LoginPageRouteId = null;
updateSite = true;
}
if (site.RegistrationPageId == page.Id)
{
site.RegistrationPageId = null;
site.RegistrationPageRouteId = null;
updateSite = true;
}
if (updateSite)
{
siteService.Save( site, CurrentPersonId );
}
}
pageService.Delete( page, CurrentPersonId );
pageService.Save( page, CurrentPersonId );
Rock.Web.Cache.PageCache.Flush( page.Id );
if ( _page != null )
_page.FlushChildPages();
} );
}
}
BindGrid();
}
示例15: 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 );
}