sharepoint平台客製與開發-2

Post on 03-Dec-2014

4.581 Views

Category:

Technology

2 Downloads

Preview:

Click to see full reader

DESCRIPTION

 

TRANSCRIPT

敦群數位科技股份有限公司游家德

物件架構WSS Sites

WSS Object Model

Web Service

Web PagesWeb Parts

SMART / MOBILEClient

C:\Program Files\Common Files\

Microsoft Shared\web server

extensions\12\ISAPI\

Microsoft.SharePoint.dll

http://moss:1234/_vti_bin/*.asmx

SharePointObject ModelMicrosoft.SharePoint.dll

Microsoft.SharePoint.Search.dll

Microsoft.Office.Server.dll

Microsoft.Office.Server.Search.dll

SPControl

SPSite

SPWebCollection

SPWeb

SPListCollection

SPList

SPListItemCollection

SPListItem

SPFieldCollection

SPField

SPAttachmentCollection

SPFile

SPUserCollection

SPUser

Class / Object

Collections

圖例

WSS3.0 的開發 Step1加入 WSS3.0 參考

於專案中加入 C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\ISAPI\Microsoft.SharePoint.dll

於程式碼中引用相關類別using Microsoft.SharePoint;using Microsoft.SharePoint.WebControls;

取得 SPSite 物件的方式Web Page 中

SPSite oSite = SPControl.GetContextSite(System.Web.HttpContext.Current);

Window Application 中SPSite oSite=new SPSite(“http://moss”);

SPSite 的重要屬性oSite.AllWebs : 取得所有的網站清單oSite.AllWebs[“/Depts/IT”] : 取得特定 url 下的

清單

存取 SPSite 物件

SPWebCollection 與 SPWebSPWebCollection : 網站集合中所有網站組成的清

單SPWeb : 個別網站

SPWebCollection oWebs=oSite.AllWebs;SPWeb oWeb = oWebs[“/Depts/IT”];

SPWeb 的重要屬性oWeb.Lists : 取得所有的清單列表oWeb.AllowUnsafeUpdate() : 允許透過 API 進

行 Post 的修改oWeb.CurrentUser : 取得目前登入使用者oWeb.Users : 取得本網站授權使用者

存取 SPWebCollection / SPWeb 物件

SPListCollection / SPList 物件SPListCollection : 所有清單組成的列表SPList : 個別清單物件

SPListCollection oLists=oWeb.Lists;SPList oList = oLists[“ 最新消息” ];

SPList 的重要屬性SPList.Fields : 取得該欄位的所有欄位名稱SPList.Items : 取得該清單中所有的資料SPList.GetItemByID : 根據傳入的 ID 取得特

定清單項目SPList.GetItems : 根據查詢條件取得符合條件

之清單SPList.DefaultViewUrl

SPListCollection.GetDataTable : 將SPListCollection 轉成 DataTable

存取 SPListCollection/ SPList 物件

SPListItemCollection / SPListItemSPListItemCollection : 清單項目的集合SPListItem : 特定清單項目

SPListItemCollection oListItems = oList.Items;SPListItem oListItem= oListItems[1];

SPListItem 的重要屬性oListItem[“ 欄位名稱” ] : 取得特定欄位值oListItem.Attachments : 取得特定清單項目的附

件集合 (文件庫除外 ) -> SPAttchmentCollectionoListItem.File : 取得文件庫的文件資訊 (針對文件

庫相關清單 ) -> SPFile

存取 SPListItem 物件

關於 Update修改 SPSite / SPWeb / SPList 等基本屬性 , 如名

稱 , 及其他相關可修改之資訊新增 / 修改 / 刪除 清單項目 (SPListItem)

Update 時的注意事項SPWeb 須將 AllowUnSafeUpdate 設為 True

SharePoint 採 Batch Update 的方式 , 須執行Update 動作已確認將更新後送回 SQL Server

修改清單標題SPSite oSite = New SPSite(“http://moss”);SPWeb oWeb = oSite.AllWebs[“/Depts/IT”];oWeb.AllowUnsafeUpdate=True;SPList oList=oWeb.List[“ 最新消息” ];oList.Title=“ 公司快訊” ;oList.Update();

新增清單項目SPSite oSite = New SPSite(“http://moss”);SPWeb oWeb = oSite.AllWebs[“/Depts/IT”];oWeb.AllowUnsafeUpdate=True;SPList oList=oWeb.List[“ 最新消息” ];SPListItem oItem = oList.Items.Add();oItem[“ 標題” ]=“ 這是新的訊息”oItem.Update();

修改清單項目SPSite oSite = New SPSite(“http://moss”);SPWeb oWeb = oSite.AllWebs[“/Depts/IT”];oWeb.AllowUnsafeUpdate=True;SPList oList=oWeb.List[“ 最新消息” ];SPListItem oItem = oList.Items[0];oItem[“ 標題” ]=“ 這是新的訊息”oItem.Update();

刪除清單項目SPSite oSite = New SPSite(“http://moss”);SPWeb oWeb = oSite.AllWebs[“/Depts/IT”];oWeb.AllowUnsafeUpdate=True;SPList oList=oWeb.List[“ 最新消息” ];SPListItem oItem = oList.Items[0]oItem.Delete();oList.Update();

SharePoint 的 Update 機制

SharePoint 結構化查詢CAML: Collaboration Application Mark-up

Language一種以 XML 為基礎的查詢語言<Query><Where><Or><Lt>

<FieldRef Name="Stock"/><Value Type="Number">15</Value>

</Lt><Gt>

<FieldRef Name="Price"/><Value Type="Currency">20.00</Value>

</Gt></Or></Where><OrderBy><FieldRef Name="Title"/></OrderBy></Query>

CAML 的使用應用於

3rd

Party工具

CAML 的使用應用於 SPQuery 以及 SPList.GetItems

SPQuery oQuery = new SPQuery();oQuery.Query=“…..CAML TAGS….”;SPListItemCollection oLis =

oList.GetItems(oQuery);

整合於 ASP.NET 2.0WSS3.0 已經完全整合在 ASP.NET 2.0 上

ASP.NET 1.1

WSS2.0

WSS 3.0

ASP.NET 2.0

Window SharePoint Service 2.0 Window SharePoint Service 3.0

WebPart 的演進歷程

Wss 2.0 網頁組件

ASP.NET 2.0網頁組件

Wss 3.0 網頁組件

WebPart Page 架構由 WebPartManager 類別控管網頁組件具有一個或多個以上的”網頁組件區域”

WSS3.0 中的網頁組件類型ASP.NET WebPart

繼承 asp.net 中的 WebPart 類型以 .webpart 檔案方式匯入新開發的 WebPart 建議以這種方式開發

WSS V2-Style WebPart繼承 WSS2.0 的 WebPart 類型以 .dwp 的方式匯入基本上是為了相容舊的 wss2.0 網頁組件

混合型 WebPart繼承 wss2.0 的 WebPart 類型使用新的 asp.net 的相關類型以 .webpart 方式匯入

WebPart 必要之 NamespaceSystem.Web.UI.WebControls

建立一個類別庫,繼承System.Web.UI.WebControls.WebParts.WebPart

網頁組件主要程式碼

網頁組件的屬性定義

網頁組件的執行安全性定義於 Web.Config 中

OSVR_MinimalWSS_MinimalWSS_MediumFull

網頁組件開發步驟利用 VS.NET2005 開啟 WebPart Project設定強制命名及版本資訊設定 Assembly.cs編譯網頁組件專案將 DLL 檔案複製到 bin 目錄下修改 web.config 將該 dll 宣告為 safeControl在”網頁組件庫”中加入該網頁組件編輯頁面將該網頁組件加入網頁組件區域中

top related