sharepoint物件模型及相關屬性 轉轉

2021-04-14 20:52:41 字數 2905 閱讀 6267

集合(collection)

很多物件都有集合

spweb–spwebcollection

splist - splistcollection…操作

get:xxcollection[idx], xxcollection.get***by***

add: xxcollection.add

del: xxcollection.delete, xx.delete, xx.recycle

update: xx.update

**的獲取

通過spsite的建構函式獲取**集

使用absolute url

site.allwebs[idx]

site.rootweb

site.openweb()

頂級站點與子站點

spcontext.current

在context環境下使用

最經常用到的容器

列表:web.lists

檔案:web.files

資料夾:web.folders

使用者:web.users

組:web.groups

**站:web.recyclebin

splist

sharepoint中最主要的資料容器

內容list.items

list.views

list.fields

list.folders(*)

splist

幾個屬性

basetype和basetemplate

rootfolder

列表的獲取

web.lists[idx]

web.getlist()

server-relative url

web.getlistfromurl()

web.getlistfromwebpartpageurl()

site-relative url

web.getlistsoftype()

spview

顯示的渠道

檢視包含

query:篩選和排序

viewfields:顯示的字段

schemaxml:基本設定

viewbody等:顯示樣式

url:檢視的位址

spview

獲取list.views[idx]

guid, index, name

list.getview()

guid

web.getviewfromurl()

server-relative url

spfield

spfield (base class)

spfieldtext

spfieldcomputed

spfieldmultichoice

spfieldchoice

spfieldlookup

spfielduser

…spfield

幾個屬性

title(顯示名稱)和internalname(內部名稱)

type:型別

schemaxml:基本設定

獲取fields[idx]

index, display name

fields.getfield()

fields.getfieldbyinternalname()

splistitem

獲取items[idx]

items.getitembyid(), list.getitembyid()

list.getitembyuniqueid()

list.getitems()

新建items.add() -> modify -> item.update()

spfile和spfolder

獲取web.getfile(), web.getfolder()

web.rootfolder, list.rootfolder(*)

folder.files, folder.subfolders

foreach遍歷需要「瀏覽目錄」許可權

特殊的列表spdocumentlibrary

繼承自splist

屬性iscatalog:預設的一些模版庫、web部件庫、母版庫

下面介紹乙個簡單的demo

訪問文件庫遍歷裡面所有的檔案和資料夾

spdocumentlibrary doclib = (spdocumentlibrary)web.lists["共享文件"];

doclib.lists.includerootfolder = true;

gothroughdoclib(doclib, doclib.rootfolder, 0);

static void gothroughdoclib(spdocumentlibrary doclib, spfolder folder, int level)

]", item.name);

gothroughdoclib(doclib, item.folder, level + 1);

}else

console.writeline(item.name);}}

moss類庫說明:

windows sharepoint services類庫說

命名空間:

microsoft.sharepoint

spsite

功能:represents a collection of sites on a virtual server, including a top-level site and all its subsites.

typeasstring:欄位的名稱的字元

sharepoint物件模型及相關屬性

集合 collection 很多物件都有集合 spweb spwebcollection splist splistcollection 操作 get xxcollection idx xxcollection.get by add xxcollection.add del xxcollection...

SharePoint物件模型效能考量(2)

開發過程的一些效能總結 1.取得列表中的item的數量 int count spcontext.current.list.items.count 這句是取得item的數目,不得不取得列表中的所有的item的metadata,這樣我們程式執行的速度就會相對慢一些,如果列表中的資料量不大,那不會有明顯的...

sharepoint物件模型效能比較

sharepoint的物件模型的屬性和方法有多種,可能對於一些初學者不明白他們之間有什麼區別,那種更優越,在何種情況下用那種屬性或方法,通過這篇文章你會有所了解 1,splist 有些人喜歡通過列表的名字去獲得列表,using spsite site new spsite strsite 這個例子中...