王晓宇
摘要:随着Internet、计算机以及网络技术的发展,企业协作系统越来越受到国际大型企业的广泛应用。基于SharePoint技术开发的协作系统,在实践活动中,经常面临文档库元数据更新处理的需要。在之前很长时期内,工程师依赖于微软提供的服务器端对象模型,这对于操作环境和权限有很高的要求。在SharePoint 2010之后,微软提供了更便捷的客户端对象模型,其对文档库元数据处理有十分明显的优势。
关键词:企业协作系统;SharePoint;客户端对象模型;元数据处理
中图分类号:TP311.5 文献标识码:A 文章编号:1009-3044(2016)05-0003-02
Abstract: With the development of Internet, personal computer and network technique, enterprise cooperation system is becoming increasingly popular in the international company. The enterprise cooperation system is developed with SharePoint technology, and always requires document library metadata update. Several years ago, engineer did so depending on the server object model supplied by Microsoft, which ask too much for the operation environment and permission. After SharePoint 2010, Microsoft provided more convenient object model, Client Object model, which has remarkable advantage in this field.
Key words: enterprise cooperation system; SharePoint; client object model; metadata update
1 SharePoint构建协作系统成为流行趋势
1.1 大型企业的协作系统
在全球性的企业中,协作系统是一个很关键的角色,它为多方地域和各种功能提供了有机的连接。该系统拥有海量的数据,并能轻松地通过精巧的搜索功能完成信息获取[1]。基于这个协作系统,公司内部的邮件,问题,评论和想法等形成了具有活力的流,大大提高了交流协作效率。
1.2 SharePoint贡献的功能
SharePoint的桥梁作用能实现的功能,简单地可分为包括:团队协作、门户技术、内容管理、业务流程和表格、企业搜索、商业智能、移动设备访问、业务应用开发等[2]八大方面。
SharePoint是一个协作环境,无论多大规模的组织都能够使用它来提高业务流程的效率。SharePoint提供安全的环境,管理员可对这些环境进行配置,来提供对文档和其他信息的个性化访问。搜索功能可以令用户高效能地找到内容,而无需考虑数据的物理位置。
2 SharePoint Client Object Model的优势
2.1 服务器端对象模型存在制约
在SharePoint 2010之前的版本中,开发者是通过服务器端的一系列代码,也就是SharePoint Server Object Model来获取SharePoint服务器上的内容并对其实施一些操作的。 随着SharePoint的推广,一方面本身在Server端的操作需要较高的权限,另一方面人们发现经常需要从客户端计算机或服务器远程访问SharePoint网站和它的列表数据,这些客户端计算机或服务器上并没有安装SharePoint Foundation,也就是一个非常普通的环境,这样的环境要访问SharePoint这样一个特殊平台上的资源,如果没有一种中间层作支持那是几乎做不到的。
2.2 客户端对象模型的便捷性
从SharePoint 2010版本以后,微软提供了让开发者能和SharePoint Foundation 交互的一种新的方式,这第三种编写代码的方式就叫做SharePoint Client Object Model即客户端对象模型[3][4](也一下简称为Client OM)。Client OM API可以被使用在.NET程序中,Silverlight程序中,以及在浏览器中运行的ECMAScript(JavaScript)中。 虽然Client OM并不如Server OM功能丰富,但是它有自己的特点,比如获取SharePoint内容时并不像Server OM以及SharePoint Web Service一样复杂,更容易获取存储于SharePoint 列表和文档库中的数据[5],并且能够更快捷地编写代码等等。
3 文档库元数据处理
3.1 准备工作
下面,我们集中以文档库的更新来说明我们使用Client OM API完成操作的强大和便捷。在使用Client OM之前,要使调用客户端API的应用程序能正常工作,客户端计算机必须同时具有Microsoft.SharePoint.Client.dll和Microsoft.SharePoint.Client.Runtime.dll[6][7]才能使用.NET托管对象模型远程开发解决方案。
3.2 元数据处理
Microsoft.SharePoint.Client是用于.NET托管对象模型的核心命名空间。SharePoint的客戶端对象模型使用ClientContext对象作为所有操作的"引力中心"[8]。在获取并使用网站和数据的过程中,首先将检索上下文对象。例如,ClientContext clientContext = new ClientContext("http://MyServer/sites/MySiteCollection") 将实例化特定网站集的上下文对象。ClientContext对象将作为用于处理客户端对象模型的主入口点[9],并作为在网站集中安排请求和启动操作所借助的中央对象。
参考文献:
[1] SharePoint 2013 的升级过程概述[EB/OL]. https://technet.microsoft.com/zh-CN/library/cc262483.aspx.
[2] Kadhar L A, Shameem A S, Fathima,et al. A Study on Best Practices for a Successful SharePoint Migration or Up-gradation[J]. IJCSI International Journal of Computer Science Issues, 2014, 11(6): 153-159
[3] Content Migration[EB/OL]. https://msdn.microsoft.com/zh-cn/library/bb249963.aspx.
[4] Sharepoint 2010 client object model with camlQuery - file download but no content/0 byte[EB/OL].
http://stackoverflow.com/questions/10024524/sharepoint-2010-client-object-model-with-camlquery-file-download-but-no-conten.
[5] Sharepoint Client Object Model: Load items from list with included File.ServerRelativeUrl[EB/OL].
http://stackoverflow.com/questions/9059634/sharepoint-client-object-model-load-items-from-list-with-included-file-serverre.
[6] How do I return a document from a Sharepoint Document library to the user? [EB/OL].
http://stackoverflow.com/questions/5709710/how-do-i-return-a-document-from-a-sharepoint-document-library-to-the-user.
[7] SharePoint 2010: Managed .net Client with Client Object Model (OM)[EB/OL]. http://www.codeproject.com/Articles/60294/SharePoint-2010-Managed-net-Client-with-Client-Obj.
[8] Uploading files using Client Object Model in SharePoint 2010[EB/OL]. http://blogs.msdn.com/b/sridhara/archive/2010/03/12/uploading-files-using-client-object-model-in-sharepoint-2010.aspx.
[9] SharePoint 2010系列——2010新特性使用Client Object Model在客户端开发[EB/OL]. http://bbs.winos.cn/thread-86653-1-1.html.