【学习sharepoint 2007 一】
Normal 0 false false false EN-US ZH-CN X-NONE1.1 Sharepoint OM-
what is OM?
object model – Sharepoint对象模型;就是一种基于dot net程序集/类库使用其接口来开发,其与WEB没有任何关系,winform或是command程序都可调用。Sharepoint 所有的功能都能通过object model来实现。
1.2
【12】文件夹的位置?
~\Program Files\Common Files\Microsoft Shared\web server extensions\12
Sharepoint 核心内容位置。
Microsoft.SharePoint.dll是最核心的在\12\ISAPI下。
1.3
In-Context or Out-Context
In-Context:是指运行在有sharepoint的环境中。如web
part、workflow
Out-Context:与上相反。如运行在自己的command项目中。
二者区别:
运行在In-C中的代码,是可以得知当前的web
site是谁得到当前sharepoint的一些属性,out-c是没有当前web
site的概念。
注1:in-c
and in-o 的代码入口
In-c:
spContext.Current
spcontext.site;spcontext.spweb
SPSiteCollection sites = this.WebApplication.Sites;
out-C:
using (SPSite currentSite = new
SPSite(@"http://moss"))
using (SPWeb
documentWeb = currentSite.OpenWeb(“Doclib1”))
二者必须点:
只要代码调用sharepoint
om,不论是in-c还是out-c,实现的代码必须运行在sharepoint环境中。
1.4
Don’t forget runtime target!
代码发开时,要注意项目工程在VS中Build-Platform属性选择有x86/x64/Itanium之分为了在不同环境中都可运行选择any
cpu. sharepoint 2010 要求所有环境都是64位
1.5
Dispose Pattern
一定要及时释放spsite
and spweb对象,不然每一次连接都会占用一点内存。
V软有工具会check
dll 检查是否销毁对象。【此工具挺笨的】
1.6
Caching Data?
如:splist->splistItem,
不要caching
sharepoint 对象,可以把它的内部数据取出放入datatable中再caching
DT,因为sharepoint
object 可能引用很多内部object会导致无法释放。
注:做web
part一定要注意caching,避免与后台或DB往返操作。
1.7
Your code is running on multiple servers!
在sharepoint
中多数应用server
farm,用户的一次请求可能不会是由一台web
server来响应,请求时由a
server来处理,再请求时可能由b
server来处理,所以一定不要记录用户的状态保留在server端,会丢失!如session!最坏的办法是使用cookie
1.8
SPXXXCollection
sharepoint 中对象集合多是以sp开头collection结尾。
对collection做遍历时要先取出内容放到变量中,后再对变量遍历,不要直接遍历collection本身。
1.9
Spsite and spweb
spsite 代表网站集,spweb代表网站
1.10
CAML
sharepoint 2010可以用linq去代替caml
CAML 使用字段的内部名称来查询
1.11
Properties
很多对象都有这个属性扩展,可以通过XXX.properties[“X”]
= “…”
可以使用这个办法来记录一些内容。如在网站对象使用属性扩展。