使用 Sharepoint 2010 客户端对象模型搜索站点中以特定扩展名结尾的所有文档
我对 Sharepoint 编程完全陌生,因此我需要一些指导来了解如何获取 Sharepoint 站点中存在的所有文档的列表,这些文档的扩展名与传入的值相匹配。
背景:作为合并的一部分,数百万( 7TB)的文档被导入到 Sharepoint 中,而不考虑文件类型,只是为了我们可以从正在关闭的系统中获取存储的数据。
这些文档中包含危险的文件类型,例如 .exe 和 .dll 文件,我们需要保留这些文件,但希望采取适当的措施来确保这些类型的恶意文件无法直接下载。
我们的计划是提取与我们的搜索列表匹配的每个文件,将其压缩,上传 zip 并删除原始文件。为此,我们需要一个一次性应用程序。
实际上涉及多个站点 - 因此理想情况下,我希望运行一个查询来访问所有站点中的所有文档(它们都在一个根目录下,但每个站点都有自己的数据库),但我可以在一组中进行迭代网站。
我的想法是使用 Sharepoint 客户端对象模型对每个站点执行查询,以返回给定类型的所有文件的列表。我想要类似的东西
SharepointSite site = new SharepointSite(siteElement, settings.RootURL);
ClientContext clientContext = site.Context;
ListCollection listCollection = clientContext.Web.Lists;
clientContext.Load(listCollection, l=>l.Name.EndsWith(".exe"));
clientContext.Load(listCollection);
clientContext.ExecuteQuery();
,但那绝对不是。
我应该如何处理这个问题?
I'm absolutely new to Sharepoint programming, so I need a bit of guidance on how to get a list of all documents that exist within a Sharepoint site who's extension matches a value being passed in.
Background: As part of a merger, millions (7TB) of documents were imported into Sharepoint without regard to file type, simply so we could get that data stored from a system that was being shut down.
Included in these documents were dangerous file types like .exe, and .dll files, which we need to preserve but want to take proper steps to ensure malicious files of those types aren't directly down-loadable.
Our plan is to extract each file matching our search list, zip it, upload the zip and delete the original. To do this, we need a one shot application.
There are actually multiple sites involved - so ideally I'd love to run one query to access all documents in all sites (they're all under one root but they each have their own databases) but I'm fine with iterating across a set of sites.
My thinking is to use the Sharepoint Client Object Model to execute a query against each site to give me back a list of all files of a given type. I want something like
SharepointSite site = new SharepointSite(siteElement, settings.RootURL);
ClientContext clientContext = site.Context;
ListCollection listCollection = clientContext.Web.Lists;
clientContext.Load(listCollection, l=>l.Name.EndsWith(".exe"));
clientContext.Load(listCollection);
clientContext.ExecuteQuery();
but that's definitely not it.
How should I approach this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从客户端对象模型中的基本编码开始。您只需要迭代站点、其列表,然后迭代其内容。
http://msdn.microsoft.com/en-us/library/ee857094.aspx
Start with basic coding in Client object model. You just need to iterate over sites, its lists and then its contents.
http://msdn.microsoft.com/en-us/library/ee857094.aspx
最后,我创建了针对数据库的直接查询,以获取所有匹配文档的特定列表,无需迭代数百万个项目,然后能够使用客户端组件来提取我想要的确切文件。
In the end, I created a direct query against the database to get a specific list of all matching documents w/o iterating over millions of items, and then was able to use the client components to pull the exact file I wanted.