本文介绍了Export-SPWeb错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

早上好

在特定子站点上,我在导出过程中一直遇到问题,我很好奇以前是否有人遇到过类似问题.

On a particular sub-site I keep encountering issues during the export process and I was curious if anyone else had encountered a similar issue previously.

在导出过程中,每次收到不同文件时,我都会收到以下致命消息.如果我使用浏览器浏览到有问题的文档,它将毫无问题地加载.

During the export process, on a differing document each time I will receive a fatal as below.  If I navigate to the document in question with a browser it will load with no issues.

FatalError:无法启用此约束,因为并非所有值都有相应的父值.
[5/24/2017 5:40:45 PM]调试:   在System.Data.ConstraintCollection.AddForeignKeyConstraint(ForeignKeyConstraint约束)中
  在System.Data.ConstraintCollection.Add(约束约束,布尔值addUniqueWhenAddingForeign)
  在System.Data.DataRelationCollection.DataSetRelationCollection.AddCore(DataRelation关系)处
  在System.Data.DataRelationCollection.Add(与DataRelation关系)
  在System.Data.DataRelationCollection.Add(字符串名称,DataColumn父列,DataColumn子列)
  在Microsoft.SharePoint.Deployment.FileObjectHelper.GetNextBatch()
  在Microsoft.SharePoint.Deployment.ObjectHelper.RetrieveDataFromDatabase(ExportObject exportObject)
  在Microsoft.SharePoint.Deployment.FileObjectHelper.RetrieveData(ExportObject exportObject)
  在Microsoft.SharePoint.Deployment.ExportObjectManager.GetObjectData(ExportObject exportObject)
  在Microsoft.SharePoint.Deployment.ExportObjectManager.MoveNext()
  在Microsoft.SharePoint.Deployment.SPExport.SerializeObjects()
  在Microsoft.SharePoint.Deployment.SPExport.Run()

FatalError: This constraint cannot be enabled as not all values have corresponding parent values.
[5/24/2017 5:40:45 PM] Debug:    at System.Data.ConstraintCollection.AddForeignKeyConstraint(ForeignKeyConstraint constraint)
   at System.Data.ConstraintCollection.Add(Constraint constraint, Boolean addUniqueWhenAddingForeign)
   at System.Data.DataRelationCollection.DataSetRelationCollection.AddCore(DataRelation relation)
   at System.Data.DataRelationCollection.Add(DataRelation relation)
   at System.Data.DataRelationCollection.Add(String name, DataColumn parentColumn, DataColumn childColumn)
   at Microsoft.SharePoint.Deployment.FileObjectHelper.GetNextBatch()
   at Microsoft.SharePoint.Deployment.ObjectHelper.RetrieveDataFromDatabase(ExportObject exportObject)
   at Microsoft.SharePoint.Deployment.FileObjectHelper.RetrieveData(ExportObject exportObject)
   at Microsoft.SharePoint.Deployment.ExportObjectManager.GetObjectData(ExportObject exportObject)
   at Microsoft.SharePoint.Deployment.ExportObjectManager.MoveNext()
   at Microsoft.SharePoint.Deployment.SPExport.SerializeObjects()
   at Microsoft.SharePoint.Deployment.SPExport.Run()

推荐答案

你好亚历克斯,

失败的原因是因为Allwebparts表中的Webpart条目指向的页面或其版本在AllDocs和AllDocVersions中不存在.

The reason for failure was because Allwebparts table had entries for Webparts pointing to pages or their versions that did not exist in AllDocs and AllDocVersions.

我们可以使用SQL检测查询来查看要删除的行:

we can use SQL detection query to look at the rows we were going to delete:

USE WSS_Content; 
GO
 
SELECT TOP 1000 * FROM 
(SELECT tp_ID, 
tp_PageUrlID, 
tp_SiteId, 
tp_IsCurrentVersion, 
tp_PageVersion, 
tp_Level 
FROM TVF_Sites_ALL() AS S 
CROSS APPLY 
TVF_AllWebParts_Site(S.Id) AS AWP 
OUTER APPLY 
TVF_AllDocs_Id_Level(S.Id,AWP.tp_PageUrlID, AWP.tp_Level) AS AD 
WHERE AD.Id IS NULL AND AWP.tp_IsCurrentVersion = 1 
UNION 
SELECT tp_ID, 
tp_PageUrlID, 
tp_SiteId, 
tp_IsCurrentVersion, 
tp_PageVersion, 
tp_Level 
FROM TVF_Sites_ALL() AS S1 
CROSS APPLY 
TVF_AllWebParts_Site(S1.Id) AS AWPV 
OUTER APPLY 
TVF_AllDocVersions_SiteDocIdUIVersion(S1.Id, AWPV.tp_PageUrlID, AWPV.tp_PageVersion) AS ADV
WHERE ADV.Id IS NULL AND AWPV.tp_IsCurrentVersion = 0 
) AS OrphanedWebParts 
GO 

然后使用下面的SQL脚本清理孤立的条目:

Then use the below SQL script to clean up the orphan entries:

USE WSS_Content; 

GO 

DECLARE @chunkSize INT; 

SET @chunkSize = 1000; 

-- Entries in the Personalization table are automatically cleaned up by _OnDeleteWebParts
-- All we need to do is find any WebParts that exist that are not mapped to a DocVersion

WHILE 1=1 

BEGIN 
DELETE TOP(@chunkSize) AWP FROM TVF_Sites_ALL() AS S 
CROSS APPLY 
TVF_AllWebParts_Site(S.Id) AS AWP 
OUTER APPLY 
TVF_AllDocs_Id_Level(S.Id,AWP.tp_PageUrlID, AWP.tp_Level) AS AD 
WHERE AD.Id IS NULL AND AWP.tp_IsCurrentVersion = 1; 
IF (@@ROWCOUNT = 0) 
BREAK 
END 

WHILE 1=1 
BEGIN 
DELETE TOP(@chunkSize) AWPV FROM TVF_Sites_ALL() AS S1 
CROSS APPLY 
TVF_AllWebParts_Site(S1.Id) AS AWPV 
OUTER APPLY 
TVF_AllDocVersions_SiteDocIdUIVersion(S1.Id, AWPV.tp_PageUrlID, AWPV.tp_PageVersion) AS ADV
WHERE ADV.Id IS NULL AND AWPV.tp_IsCurrentVersion = 0; 
IF (@@ROWCOUNT = 0) 
BREAK 
END 

WHILE 1=1 
BEGIN 
-- Remove any WebParts in WebPartLists cache that may have been deleted 
DELETE TOP(@chunkSize) WPL FROM TVF_Sites_ALL() AS S1 
CROSS APPLY 
TVF_WebPartLists_Site(S1.Id) AS WPL 
OUTER APPLY
TVF_AllWebParts_SitePartId(S1.Id, WPL.tp_WebPartID) AS AWP 
WHERE AWP.tp_ID IS NULL; 
IF (@@ROWCOUNT = 0) 
BREAK 
END 

GO 

注意:您需要将WSS_Content更改为承载该站点的Web应用程序的内容数据库.并且在运行上面的内容之前,请备份您的内容数据库.

Note: you need to change WSS_Content to your content database of your web application which hosts the site. And Before you run the above, please back up your content database.

谢谢

温迪


这篇关于Export-SPWeb错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 11:51