本文整理汇总了C#中Web.GetPublishingPage方法的典型用法代码示例。如果您正苦于以下问题:C# Web.GetPublishingPage方法的具体用法?C# Web.GetPublishingPage怎么用?C# Web.GetPublishingPage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Web
的用法示例。
在下文中一共展示了Web.GetPublishingPage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddPublishingPage
public static void AddPublishingPage(PublishingPage page, ClientContext ctx, Web web)
{
SPPublishing.PublishingPage publishingPage = web.GetPublishingPage(page.FileName + ".aspx");
RemovePublishingPage(publishingPage, page, ctx, web);
web.AddPublishingPage(page.FileName, page.Layout, page.Title, false); //DO NOT Publish here or it will fail if library doesn't enable Minor versions (PnP bug)
publishingPage = web.GetPublishingPage(page.FileName + ".aspx");
Microsoft.SharePoint.Client.File pageFile = publishingPage.ListItem.File;
pageFile.CheckOut();
if (page.Properties != null && page.Properties.Count > 0)
{
ctx.Load(pageFile, p => p.Name, p => p.CheckOutType); //need these values in SetFileProperties
ctx.ExecuteQuery();
pageFile.SetFileProperties(page.Properties, false);
}
if (page.WebParts != null && page.WebParts.Count > 0)
{
Microsoft.SharePoint.Client.WebParts.LimitedWebPartManager mgr = pageFile.GetLimitedWebPartManager(Microsoft.SharePoint.Client.WebParts.PersonalizationScope.Shared);
ctx.Load(mgr);
ctx.ExecuteQuery();
AddWebpartsToPublishingPage(page, ctx, mgr);
}
List pagesLibrary = publishingPage.ListItem.ParentList;
ctx.Load(pagesLibrary);
ctx.ExecuteQueryRetry();
ListItem pageItem = publishingPage.ListItem;
web.Context.Load(pageItem, p => p.File.CheckOutType);
web.Context.ExecuteQueryRetry();
if (pageItem.File.CheckOutType != CheckOutType.None)
{
pageItem.File.CheckIn(String.Empty, CheckinType.MajorCheckIn);
}
if (page.Publish && pagesLibrary.EnableMinorVersions)
{
pageItem.File.Publish(String.Empty);
if (pagesLibrary.EnableModeration)
{
pageItem.File.Approve(String.Empty);
}
}
if (page.WelcomePage)
{
SetWelcomePage(web, pageFile);
}
ctx.ExecuteQuery();
}
示例2: ProvisionObjects
public override TokenParser ProvisionObjects(Web web, ProvisioningTemplate template, TokenParser parser,
ProvisioningTemplateApplyingInformation applyingInformation)
{
using (var scope = new PnPMonitoredScope(this.Name))
{
var context = web.Context as ClientContext;
web.EnsureProperties(w => w.ServerRelativeUrl, w => w.Url);
foreach (PublishingPage page in template.Publishing.PublishingPages)
{
string parsedFileName = parser.ParseString(page.FileName);
string parsedFullFileName = parser.ParseString(page.FullFileName);
Microsoft.SharePoint.Client.Publishing.PublishingPage existingPage =
web.GetPublishingPage(parsedFileName + ".aspx");
if (!web.IsPropertyAvailable("RootFolder"))
{
web.Context.Load(web.RootFolder);
web.Context.ExecuteQueryRetry();
}
if (existingPage != null && existingPage.ServerObjectIsNull.Value == false)
{
if (!page.Overwrite)
{
scope.LogDebug(
CoreResources.Provisioning_ObjectHandlers_PublishingPages_Skipping_As_Overwrite_false,
parsedFileName);
continue;
}
if (page.WelcomePage && web.RootFolder.WelcomePage.Contains(parsedFullFileName))
{
//set the welcome page to a Temp page to allow page deletion
web.RootFolder.WelcomePage = "home.aspx";
web.RootFolder.Update();
web.Update();
context.ExecuteQueryRetry();
}
existingPage.ListItem.DeleteObject();
context.ExecuteQuery();
}
web.AddPublishingPage(
parsedFileName,
page.Layout,
parser.ParseString(page.Title)
);
Microsoft.SharePoint.Client.Publishing.PublishingPage publishingPage =
web.GetPublishingPage(parsedFullFileName);
Microsoft.SharePoint.Client.File pageFile = publishingPage.ListItem.File;
pageFile.CheckOut();
if (page.Properties != null && page.Properties.Count > 0)
{
context.Load(pageFile, p => p.Name, p => p.CheckOutType);
context.ExecuteQueryRetry();
var parsedProperties = page.Properties.ToDictionary(p => p.Key, p => parser.ParseString(p.Value));
pageFile.SetFileProperties(parsedProperties, false);
}
if (page.WebParts != null && page.WebParts.Count > 0)
{
Microsoft.SharePoint.Client.WebParts.LimitedWebPartManager mgr =
pageFile.GetLimitedWebPartManager(
Microsoft.SharePoint.Client.WebParts.PersonalizationScope.Shared);
context.Load(mgr);
context.ExecuteQueryRetry();
AddWebPartsToPublishingPage(page, context, mgr, parser);
}
List pagesLibrary = publishingPage.ListItem.ParentList;
context.Load(pagesLibrary);
context.ExecuteQueryRetry();
ListItem pageItem = publishingPage.ListItem;
web.Context.Load(pageItem, p => p.File.CheckOutType);
web.Context.ExecuteQueryRetry();
if (pageItem.File.CheckOutType != CheckOutType.None)
{
pageItem.File.CheckIn(String.Empty, CheckinType.MajorCheckIn);
}
if (page.Publish && pagesLibrary.EnableMinorVersions)
{
pageItem.File.Publish(String.Empty);
if (pagesLibrary.EnableModeration)
{
pageItem.File.Approve(String.Empty);
}
}
if (page.WelcomePage)
{
SetWelcomePage(web, pageFile);
}
//.........这里部分代码省略.........