示例:自定义文档 ID 提供程序
上次修改时间: 2011年4月20日
适用范围: SharePoint Server 2010
C:\Program Files\Microsoft SDKs\SharePoint 2010\Samplesfolder 中的 CustomDocIdProvider.zip 文件中的代码示例演示如何创建用于生成文档 ID 的自定义文档 ID 提供程序。
生成并运行示例
在开发或测试网站上测试此项目。
生成示例
此自定义 ID 提供程序生成 ItemName-ItemGuid@Web 形式的 ID。ID 是唯一标识符,它们提供有关项的信息,如项的名称和项所在的 Web。
部署此示例:
在 Microsoft Visual Studio 2010 中打开解决方案。
生成解决方案。
向全局程序集缓存 (GAC) 添加生成的 DLL。
运行 Windows PowerShell 脚本,将 http://MyServer 替换为要将文档 ID 部署到的网站的 URL。
Windows PowerShell 脚本:
$site = Get-SPSite http://MyServer
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.DocumentManagement")
$assembly = [System.Reflection.Assembly]::Load("CustomDocIdProvider")
$type = $assembly.GetType("Microsoft.SDK.MOSS.Samples.CustomDocumentIDProvider");
[Microsoft.Office.DocumentManagement.DocumentId]::SetProvider($site, $type);
运行示例
通过运行示例,可在指定网站上搜索目标文档,以将文档 ID 解析为其相应的 URL。