日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

SharePoint Add-in Model (App Model) 介绍 – 概念、托管方式、开发语言

發布時間:2024/4/14 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 SharePoint Add-in Model (App Model) 介绍 – 概念、托管方式、开发语言 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

SharePoint Add-in Model 是自 2013 版本以來引入的新的擴展性開發模型, SharePoint 開發者可以利用這種新模型來實現往常利用場解決方案 (Farm Solution)或沙盒解決方案 (Sandbox Solution)進行的站點定制化 (Customizations)。提到站點定制化,常見的用戶場景包括:

  • 實現一個自定義的Web 組件 (WebPart), 使得用戶在編輯網站頁面時可以添加該 Web 組件到頁面上。
  • 實現一個事件接收器 (Event Receiver),使得文檔或列表發生新增、刪除、更新等操作時觸發相應的邏輯。
  • 實現一個計時器任務 (TimerJob), 定期執行某項任務。
  • 通過程序化的方式定義一個列表,并對其進行增刪改
  • 定義網站欄( Site Column)、內容類型(Content Types)
  • 程序化的方式創建網站集 (Site Collection)、網站 (Site),并創建新的文檔庫(Document Libarary),為網站設置主題(Theme),
  • 程序化的方式部署母版頁(Master Page)、網頁布局(Page Layouts)
  • 更多...

這些定制化在 Add-in Model 中絕大多數都是被支持的, 我們會在后續的文章中深入探討。具體如何實現,可以參考 GitHub 上的開源代碼實現: O365 Patterns and Practices (PnP) 項目

什么是 Add-in Model?

它是 SharePoint 提供的用來讓開發者擴展自身功能的一種開發模型, 基于這種模型開發出的定制化解決方案, 通常稱作 SharePoint Add-ins(我們暫且稱它為定制化程序)。

Add-in 模型提供了一種機制, 讓開發者像開發普通 Web 應用程序一樣開發 SharePoint 定制化程序。這使得圍繞 SharePoint 定制化的開發變得更加開放, 開發者可以使用更多的 Web 技術、框架快速構建出自己想要的解決方案。所以,簡單說來: 基于 Add-in Model 的開發, 就是 Web 應用程序的開發。

簡單說來, Add-ins 就是 Web 應用程序。

“如果你了解如何開發常見 Web 應用程序, 那么,你已經了解了如何基于 Add-in 模型去開發 SharePoint 定制化方案了…”

如何托管定制化方案(Add-ins)

既然基于 Add-in 模型的開發,更多的是 Web 應用程序的開發,那么開發出來的 Add-ins 如何部署, 托管在哪呢?

Add-in 模型提供了兩種方式: SharePoint 自托管、Provider-Hosted 方式。

基于 SharePoint自托管( SharePoint-hosted) 方式實現的 Add-ins

特點描述
Add-ins 入口安裝后,網站內容(Site Content)中包含入口瓷塊(tile)
可以包含哪些 UI 組件 add-in 組件(parts) 和 自定義按鈕(Custom Actions. that is, custom ribbon buttons or menu items)。 可以通過 XML 文件的方式在 Add-ins 中包含如下組件:
  • 自定義頁面(Custom Page)
  • 工作流(Workflows)
  • Modules (sets of files)
  • 列表模板(List templates)
  • 列表和庫的實例(List and library instances)
  • 自定義的列表表單和視圖(Custom list forms and views)
  • 自定義內容類型(Custom content types)
  • 網站模板(Web templates)
  • 內置網站列(Built-in columns (not custom columns))
  • 內置 Web 組件(Built-in Web Parts (not custom Web Parts))
  • JavaScript 文件
  • Add-ins 網站內部自定義按鈕和菜單項(Custom buttons and menu items)
  • Add-in 組件(add-in parts)
  • 自定義動作(custom actions),包括自定義的Ribbon按鈕(custom ribbon buttons)或者 菜單項(menu items)
可用的編程語言
  • SharePoint 的客戶端對象模型提供了 JavaScript 版本的庫, 可以用來在 Add-ins 中增刪改查(CRUD) SharePoint 網站上的數據。
  • 自定義的頁面通常是一些 ASP.NET 頁面(ASPX),他們可以引用 ASP.NET 和 SharePoint 內置的控件,但是不能使用 Code Behind。但是如果需要對 SharePoint 控件進行自定義,可以利用 Client-Side rendering 技巧。
  • Add-ins 中的 JavaScript 可以訪問該應用網站外的數據( 包括所其在 SharePoint 網站上的數據和資源, 也可以是互聯網上的任何資源, 可以用如下兩種方式: 1. 利用 JavaScript 跨域庫 2. JavaScript WebProxy 類。

基于 Provider-Hosted 方式實現的 Add-ins

SharePoint 自托管方式支持的組件, 基于 provider-hosted 方式的 Add-ins 中也支持。

Provider-Hosted 方式, 是指將開發出來的 Add-ins 托管在 SharePoint farm 外部的任何服務器上, 這些服務器從硬件的角度上可以是開發者指定的一臺物理機或者 Windows Azure 上的虛擬機。 而從軟件的角度上, 它可以是由 Microsoft IIS 做支撐,也可有由開源的 Apache、Nginx、Tomcat等等。開發者可以利用這些 Web 服務器支持的開發語言如 C#、 JS、HTML、PHP、JAVA 等等來進行開發。

由于 Add-ins 托管在 Farm 外面, 所以如果實現和 SharePoint 網站風格一致,可以利用 SharePoint 提供的 Chrome 控件。代碼如下:

$(document).ready(function () {//Get the URI decoded SharePoint site url from the SPHostUrl parameter.var spHostUrl = decodeURIComponent(getQueryStringParameter('SPHostUrl'));//Get the URI decoded SharePoint app web url from the SPAppWebUrl parameter.var appWebUrl = decodeURIComponent(getQueryStringParameter('SPAppWebUrl'));//Get the isDialog from url parametersvar isDialog = decodeURIComponent(getQueryStringParameter('IsDlg'));//Build absolute path to the layouts root with the spHostUrlvar layoutsRoot = spHostUrl + '/_layouts/15/';//load all appropriate scripts for the page to function$.getScript(layoutsRoot + 'SP.Runtime.js',function () {$.getScript(layoutsRoot + 'SP.js',function () {//Create a Link element for the defaultcss.ashx //resourcevar linkElement = document.createElement('link');linkElement.setAttribute('rel', 'stylesheet');linkElement.setAttribute('href', layoutsRoot + 'defaultcss.ashx');Add the linkElement as a child to the head //section of the htmlvar headElement = document.getElementsByTagName('head');headElement[0].appendChild(linkElement);//Load the SP.UI.Controls.js file to render the App Chrome$.getScript(layoutsRoot + 'SP.UI.Controls.js', renderSPChrome);});});function chromeLoaded() {$('body').show();}//function callback to render chrome after SP.UI.Controls.js loadsfunction renderSPChrome() {//Set the chrome options for launching Help, Account, // and Contact pagesvar options = {'appTitle': document.title,'onCssLoaded': 'chromeLoaded()'};//Load the Chrome Control in the divSPChrome element of the pagevar chromeNavigation = new SP.UI.Controls.Navigation('divSPChrome', options);chromeNavigation.setVisible(true);}

Remote data can be blobs, caches, message queues, content delivery networks (CDN), and databases, among others. And databases can be any type including relational and object-oriented. The remote data can be accessed in a variety of ways. For example, you can use Business Connectivity Services (BCS) to surface the data in a SharePoint list. Another option is to expose data in a grid on a page of a remote web application.

Add-ins 可以利用 APIs 來和 SharePoint 資源進行交互, 主要包括以下幾種:

  • 利用 .NET 開發時, 可使用 SharePoint 客戶端對象模型 (Client-Side Object Model 簡稱 CSOM)
  • REST/OData APIs

SharePoint Add-ins use SharePoint APIs to connect and integrate with SharePoint features—search, workflow, social networking, taxonomy, user profiles, BCS, and more. This lets them read documents, do searches, connect people, and perform CRUD operations.

內容同步發布在 simpeng.net 和 http://www.cnblogs.com/simpeng/p/4900591.html

轉載于:https://www.cnblogs.com/simpeng/p/4900591.html

總結

以上是生活随笔為你收集整理的SharePoint Add-in Model (App Model) 介绍 – 概念、托管方式、开发语言的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。