Class PageService
- Namespace
- Dynamicweb.Content
- Assembly
- Dynamicweb.dll
Provides methods for querying and persisting pages.
public class PageService : ICacheStorage<int, Page>, ICacheStorage<int>, ICacheStorage
- Inheritance
-
PageService
- Implements
- Inherited Members
Constructors
PageService()
The repository implementation providing access to persistence
public PageService()
Methods
ClearCache()
Resets all keys to the default value for objects stored in the object cache
public void ClearCache()
ClearCache(IEnumerable<int>)
Resets the specified keys to the default value for objects stored in the object cache
public void ClearCache(IEnumerable<int> keys)
Parameters
keysIEnumerable<int>Keys to reset
ClearCache(int)
Resets the specified key to the default value for objects stored in the object cache
public void ClearCache(int key)
Parameters
keyintKey to reset
ClearTrashBin(int)
Deletes the specified page form trashbin
public void ClearTrashBin(int pageId)
Parameters
pageIdintThe id of the page to delete
CopyTo(CopyPageInfo)
Creates a copy of a given Page
public ApplicationResponse<Page> CopyTo(CopyPageInfo copyPageInfo)
Parameters
copyPageInfoCopyPageInfoA CopyPageInfo instance providing information about how to perform the actual copy operation
Returns
- ApplicationResponse<Page>
A response indicating the success or failure of the operation
CreateFromMaster(int, int)
Creates a new language version of the page with the specified id
public int CreateFromMaster(int masterPageId, int languageAreaId)
Parameters
masterPageIdintThe id of the page acting as master
languageAreaIdintThe language version of the website on which to create the new page
Returns
- int
The id of the new page
DeleteAllAreaPages(Area)
public ApplicationResponse DeleteAllAreaPages(Area area)
Parameters
areaArea
Returns
DeletePage(int)
Deletes the specified page
public void DeletePage(int pageId)
Parameters
pageIdintThe id of the page to delete
DeletePageItem(int)
Deletes the page item
public void DeletePageItem(int pageId)
Parameters
pageIdintThe id of the page to delete its item
ForceRefreshIndex(int)
Forces the specific item from the cache to be force-refreshed from the repository.
public bool ForceRefreshIndex(int id)
Parameters
idintId of element to be refreshed
Returns
GetAncestors(int, bool)
Gets all ancestor page collection
public IEnumerable<Page> GetAncestors(int pageId, bool includingSelf)
Parameters
pageIdintThe id of the page to get ancestors
includingSelfboolIndicates if page with given Id will be included in result
Returns
GetAreaAndPageNameByUrl(string, ref string?, ref string?)
Gets the area and page name by URL.
public string GetAreaAndPageNameByUrl(string url, ref string? internalId, ref string? internalAreaId)
Parameters
urlstringThe URL, i.e. Default.aspx?ID=123.
internalIdstringOptional parameter by reference. If passed the ID of the page will be returned.
internalAreaIdstringOptional parameter by reference. If passed the ID of the area will be returned.
Returns
- string
The name of the area and page of the given link in the format "Area name: Page name"
GetAreaNavigationTree(int)
Gets a representation of pages of the website with the specified id
public PageTree? GetAreaNavigationTree(int areaId)
Parameters
areaIdintThe id of the area for which to get its page navigation tree
Returns
GetAreaRootNavigationTree(int)
Gets a representation of a subset of the website with the pages located in the root of the website. Child nodes are added to the root nodes, but not to the tree.
public PageTree? GetAreaRootNavigationTree(int areaId)
Parameters
areaIdintThe id of the area for which to get its page navigation tree
Returns
GetAvailablePageDefinitions(int, int)
Gets the collection of available page definitions for specified area.
public IEnumerable<PageDefinition> GetAvailablePageDefinitions(int areaId, int parentPageId)
Parameters
Returns
- IEnumerable<PageDefinition>
IEnumerable(Of PageDefinition).
GetAvailablePageDefinitions(int, int, string?)
Gets the collection of available page definitions for specified area.
public IEnumerable<PageDefinition> GetAvailablePageDefinitions(int areaId, int parentPageId, string? treeSection)
Parameters
Returns
- IEnumerable<PageDefinition>
IEnumerable(Of PageDefinition).
GetDeletedPages(int)
Gets the collection of deleted pages in specified area
public IEnumerable<Page> GetDeletedPages(int areaId)
Parameters
areaIdintThe area id.
Returns
- IEnumerable<Page>
A collection of pages
GetFirstModulePageForArea(int, string)
Gets the first module page for the area with the specified id.
public Page? GetFirstModulePageForArea(int areaId, string moduleSystemName)
Parameters
areaIdintThe id of the area for which to get the page.
moduleSystemNamestringThe system name of the module.
Returns
- Page
Page.
GetFirstPageForArea(int)
Gets the first root page for the area with the specified id.
public Page? GetFirstPageForArea(int areaId)
Parameters
areaIdintThe id of the area for which to get the page
Returns
- Page
The first page for the specified area
GetLanguagePages(int)
Gets all language versions of the page with the specified id
public PageCollection GetLanguagePages(int pageId)
Parameters
pageIdintThe id of the page for which to get all its language versions
Returns
- PageCollection
A list of pages
GetPage(int)
Gets the page with the specified id
public Page? GetPage(int pageId)
Parameters
pageIdintThe id of the page to get
Returns
- Page
The page with the specified id. If a page with the Id is not found,
nullis returned
GetPageByNavigationTag(int, string)
public Page? GetPageByNavigationTag(int areaId, string navigationTag)
Parameters
Returns
GetPageForItem(string, string)
Gets the page for the item with the specified type and id
public Page? GetPageForItem(string itemType, string itemId)
Parameters
itemTypestringThe itemType for which to find a page
itemIdstringThe itemId for which to find a page
Returns
- Page
A page that has an associated item with the specified item type and id
GetPageIDByMasterID(int, int)
Gets the id of the page in the specified language version that has a master page with the given id
public int GetPageIDByMasterID(int masterId, int languageAreaId)
Parameters
Returns
- int
A page id that has a master page with the specified id in the given language
GetPageNavigationTree(int)
Gets a representation of the website and its pages in a PageTree instance
public PageTree? GetPageNavigationTree(int parentPageId)
Parameters
parentPageIdintThe id of the page for which to get its page navigation tree
Returns
- PageTree
A PageTree instance
Remarks
looks up data from database
GetPageOrLanguage(int, int)
Gets the page with the specified id - if the passed areaid does not match the pageid, the language version will be returned if found
public Page? GetPageOrLanguage(int pageId, int areaId)
Parameters
Returns
- Page
The page with the specified id or its language version for the specified area. If a page with the Id is not found,
nullis returned. If areaid is not more than 0, exception will be thrown
GetPageTemplatesForArea(int)
Gets all page templates for the specified area
public PageCollection GetPageTemplatesForArea(int areaId)
Parameters
areaIdintThe id of the area for which to get it's page templates
Returns
- PageCollection
A collection of page templates
GetPages()
Gets all pages in the system
public PageCollection GetPages()
Returns
- PageCollection
A list of all pages in the system
GetPages(int[])
Gets all the pages matching the ids in the specified array
public PageCollection GetPages(int[] pageIds)
Parameters
pageIdsint[]An array of ids for which to get the page instances
Returns
- PageCollection
A list with the pages matching the specified ids
GetPagesByAreaID(int)
Gets all the pages for the area with the specified id
public PageCollection GetPagesByAreaID(int areaId)
Parameters
areaIdintThe id of the area for which to get all its pages
Returns
- PageCollection
A list of pages
GetPagesByParentID(int)
Gets all pages having the specified parent id
public IEnumerable<Page> GetPagesByParentID(int parentId)
Parameters
parentIdintThe parent id for which to get all children pages
Returns
- IEnumerable<Page>
A list of pages all having a parent page with the specified id
GetPagesByTitle(string)
Gets all the pages that have the specified title
public PageCollection GetPagesByTitle(string title)
Parameters
titlestringThe title fort which to get all pages having that as their title
Returns
- PageCollection
A collection of pages with the specified titel
GetPagesForItems(IEnumerable<string>)
Gets a collection of pages having the specified item types
public PageCollection GetPagesForItems(IEnumerable<string> itemTypes)
Parameters
itemTypesIEnumerable<string>The item types for which to get pages
Returns
- PageCollection
A collection of pages having the specified item types
GetPagesForItems(IEnumerable<string>, int)
Gets a collection of pages for a website (area) having the specified item types
public IEnumerable<Page> GetPagesForItems(IEnumerable<string> itemTypes, int areaId)
Parameters
itemTypesIEnumerable<string>The item types for which to get pages
areaIdintThe area id for which to get the pages
Returns
- IEnumerable<Page>
A collection of pages having the specified item types
GetRootPagesForArea(int)
Gets all root pages for the area with the specified id
public IEnumerable<Page> GetRootPagesForArea(int areaId)
Parameters
areaIdintThe id of the area for which to get all its root pages
Returns
- IEnumerable<Page>
A list of pages all being root to the area with the specified id
GetTemplateParentPage(int)
Get page template folder
public Page? GetTemplateParentPage(int areaId)
Parameters
areaIdintThe area id.
Returns
- Page
The page template folder
GetUpdatedLanguagePages(int)
Gets a list of pages for an area that has not been updated after their masters have been updated. The passed areaId has to be for an Area that is a language (has a master).
public IEnumerable<Page> GetUpdatedLanguagePages(int areaId)
Parameters
areaIdintThe area id for which to get the updated language pages
Returns
Remarks
Uses the database directly
GetWebpageCount(int)
Gets total number of webpages on specified area.
public int GetWebpageCount(int areaId)
Parameters
areaIdintareaId
Returns
- int
webpageCount
Move(int, int, int)
Moves the specified page to the target page and area
public ApplicationResponse<Page> Move(int pageId, int destinationAreaId, int destinationPageId)
Parameters
pageIdintThe id of the page to move
destinationAreaIdintArea to move to.
destinationPageIdintThe id of the page to which the page should be moved
Returns
- ApplicationResponse<Page>
A response indicating the success or failure of the operation
RestorePage(int)
Restore the page with the specified id
public void RestorePage(int pageId)
Parameters
pageIdintThe id of the page to restore
Exceptions
SaveAsTemplate(Page, string, string)
Saves the specified page as a template
public int SaveAsTemplate(Page page, string name, string description)
Parameters
pagePageThe page to save as a template
namestringThe name of the new template
descriptionstringA description of the template
Returns
- int
The newly assigned page id for the template
SaveAsTemplate(Page, string, string, string)
Saves the specified page as a template
public int SaveAsTemplate(Page page, string name, string description, string image)
Parameters
pagePageThe page to save as a template
namestringThe name of the new template
descriptionstringA description of the template
imagestring
Returns
- int
The newly assigned page id for the template
SaveAsTemplate(Page, string, string, string, string)
Saves the specified page as a template
public int SaveAsTemplate(Page page, string name, string description, string image, string category)
Parameters
pagePageThe page to save as a template
namestringThe name of the new template
descriptionstringA description of the template
imagestringThe image of the new template
categorystringA category of the template
Returns
- int
The newly assigned page id for the template
SavePage(Page)
Saves the specified page and handles the creation of language versions if the page is new.
public Page SavePage(Page page)
Parameters
pagePageThe page to be saved.
Returns
- Page
The saved page.
Remarks
If the page is new, it creates language versions for the page using CreatePageLanguageVersions(Page). If the page is not new, it retrieves the existing language versions using GetLanguageVersionsOfPage(Page). The method also synchronizes language pages with the master page if applicable.
SavePage(Page, bool)
Saves the specified page and handles the creation of language versions if the page is new and languages are not skipped.
public Page SavePage(Page page, bool skipLanguages)
Parameters
pagePageThe page to be saved.
skipLanguagesboolIf set to
true, the method will not create or update language versions for the page.
Returns
- Page
The saved page.
Remarks
If the page is new, it creates language versions for the page using CreatePageLanguageVersions(Page). If the page is not new, it retrieves the existing language versions using GetLanguageVersionsOfPage(Page). The method also synchronizes language pages with the master page if applicable.
UpdatePagesOrder(int, int?, IEnumerable<int>)
Updates sorting for given pages
public void UpdatePagesOrder(int areaId, int? pageId, IEnumerable<int> childPageIdsOrder)
Parameters
areaIdintThe id of the area for pages
pageIdint?The parent id for which to update sort indexes
childPageIdsOrderIEnumerable<int>Ordered collection of pages ids
UserHasAccessToAllBackendSubpages(Page, User)
Gets a value indicating if the user has access to all subpages in the specified page in the administration
public bool UserHasAccessToAllBackendSubpages(Page page, User user)
Parameters
pagePageThe page for which to determine if the user can access that and its subpages
userUserThe user for whom to determine access
Returns
- bool
True if the user can access the page and all of its subpages, otherwise false