是否有人知道是否可以在Office 365中使用CSOM导出web部件。我希望启用的方案是将发布页面(嵌入web部件)从一个Office 365租户移动到另一个租户。我最初的研究表明,这在客户端代码中是不可能的-任何帮助都很感谢。
发布于 2017-03-18 00:46:06
下面的代码应该可以做到这一点。
var limitedWebPartManager = file.GetLimitedWebPartManager(PersonalizationScope.Shared);
var webPartDefinitons = limitedWebPartManager.WebParts;
clientContext.LoadAndExecute(webPartDefinitons);
foreach (var webpartDefintion in webPartDefinitons)
{
try
{
var webPartId = webpartDefintion.Id;
var webPartXML = limitedWebPartManager.ExportWebPart(webPartId);
clientContext.ExecuteQuery();
clientContext.Load(webpartDefintion, def => def.ZoneId, def => def.Id);
clientContext.LoadAndExecute(webpartDefintion.WebPart, w => w.Title, w => w.ZoneIndex, w => w.Properties);
}
catch (Exception exception)
{
Console.WriteLine(exception);
}
}发布于 2015-08-28 22:43:36
SharePoint仅通过CSOM导出LimitedWebPartManager。它非常有限(由此得名),并且只能实现有限的操作。(更改WebPart的标题,阅读信息)。
但是,我建议您使用/_vti_bin/webpartpages.asmx服务。(添加服务引用、http://yoursharepoint/_vti_bin/webpartpages.asmx、
var credentials = new NetworkCredential();
credentials.UserName = "username";
credentials.Password = "secret";
credentials.Domain = "domain";
var svc = new WebPartPagesSvc.WebPartPagesWebService();
svc.Credentials = credentials;
var result = svc.GetWebPartPage(filename, WebPartPages2Svc.SPWebServiceBehavior.Version3);
Console.Write(result);希望这能有所帮助。
https://stackoverflow.com/questions/31552510
复制相似问题