K2.Net提供了從SharePoint到K2.Net和從K2.Net到SharePoint的集成組件,同時支持與SPS和WSS的集成。
從SharePoint到K2.net的集成
這種集成爲SharePoint文檔庫和表單庫提供了企業級的流程功能。典型的應用場景是需要文檔審批的業務流程。我們可以使用SharePoint事件(Event)發起一個新的K2流程實例。這些事件包括:
- 向文檔庫中添加文檔;
- 簽入文檔;
- 簽出文檔;
- 刪除文檔;
- 更新文檔;
- 複製或者移動文檔。
K2.net任務列表Web部件
使用K2.net任務列表部件,用戶可以從SharePoint站點上查看並執行自己的任務。SharePoint系統管理員或者用戶可以將K2.Net任務列表部件放在任何一個頁面上。點擊Web部件中的項目,任務就會在新窗口中打開,用戶可以在新窗口中執行任務。
用戶可以對K2.net的任務列表進行定製:
- 設定顯示的最多任務項數目;
- 刷新頻率;
- 顯示列;
- 設定Process、Activity、Event或Worklist Item狀態篩選條件;
- 設定排序列及排序方式。
從K2.net到SharePoint的集成
K2.net爲用戶操作SharePoint站點中的信息提供了多種集成組件。這些組件稱爲K2.net Server Events,能夠創建和操作SharePoint Workspace、Document和List。這些組件包括:
- SharePoint 2003 Document Event
- SharePoint 2003 List Event
- SharePoint 2003 Workspace Event
- SharePoint 2003 Multiple Documents Event
SharePoint 2003 Document Event
SharePoint 2003 Document Event能夠創建和操作SharePoint文檔庫中的文件。用戶可以上傳文檔、獲取文檔最新版本、刪除文檔、簽入/簽出文檔,或者審批/否決文檔。另外用戶還可以用SharePoint 2003 Document Event獲取或者設定文檔的元數據(Metadata)。
SharePoint 2003 List Event
SharePoint 2003 List Event功能更爲強大,因爲SharePoint中絕大多數信息都是以列表的方式儲存的。使用SharePoint 2003 List Event用戶可以創建、更新、刪除任何標準的列表庫或者用戶自定義列表。
SharePoint 2003 Workspace Event
SharePoint 2003 Workspace Event用於在流程執行過程中創建或者刪除SharePoint站點或者工作區。用戶可以通過代碼方式或者流程字段定義SharePoint站點或者工作區的名稱、標題以及描述等等。同時用戶還可以指定站點或者工作區所使用的模版。可用的模版直接讀取自SharePoint站點,包括任何用戶自定義的模版。
SharePoint 2003 Multiple Documents Event
SharePoint 2003 Multiple Documents Event與XML附件字段配合使用。XML附件字段可能包含多個文檔。執行此嚮導時,用戶需要選擇希望執行的動作。所選擇的動作對XML附件字段中的每個文檔都執行同樣的操作。
在用戶前臺通過拖放式方式進行操作的同時,K2 Server會在後臺自動生成相應的代碼。如:
' Set up variables
Dim Temp as String, ErrorMessage As String = ""
Dim Server As String
Server = "http://demo:81/"
If Not Server.EndsWith("/") Then Server &= "/"
Dim Site As String
Site = ""
If Not Site.EndsWith("/") And Site.Trim <> "" Then Site &= "/"
Dim Folder As String
Folder = "Shared Documents"
If Not Folder.EndsWith("/") Then Folder &= "/"
Dim File As String
File = K2.ProcessInstance.Folio
Dim LocalFolder As String
LocalFolder = "D:/"
Dim LocalFile As String
LocalFile = "code.txt"
Dim SpsList As New K2SPSList()
' Set Url for Web Service
SpsList.Url = Server & "_vti_bin/K2SpsList.asmx"
' Set Credentials
Dim SpsUtils As New SourceCode.K2SPUtilities.SPSUtilities
SpsList.Credentials = SpsUtils.GetCredentials(Server)
' Build The file path
Dim LocalFilePath as String
If Not LocalFolder.EndsWith("/") Then
LocalFilePath = LocalFolder & "/" & LocalFile
Else
LocalFilePath = LocalFolder & LocalFile
End If
' Read File Into Byte Array
Dim oByte() as Byte
Dim K2B64 as New K2Base64.K2Base64()
oByte = K2B64.FileToByteArray(LocalFilePath)
' Call Web Service to Upload Document
If Not SpsList.UploadDocument(Server, Site, Folder, _
File, oByte, False , ErrorMessage) Then
' Error Occurred in UploadDocument - Raise Error
Throw New System.Exception(ErrorMessage)
End If
InitializeXmlField(K2.ProcessInstance.XmlFields("AttachedDocuments"))
' Update the Attahment field
Dim sAtt As String
sAtt = K2.ProcessInstance.XmlFields("AttachedDocuments").Value
sAtt = SpsUtils.AddAttachmentField(sAtt, _
Server, Site, Folder, File)
K2.ProcessInstance.XmlFields("AttachedDocuments").Value = sAtt
End Sub
Private Sub InitializeXmlField(ByRef oXmlField As SourceCode.KO.XmlField)
If oXmlField.Value Is Nothing OrElse oXmlField.Value = "" Then
' Check if Meta Data exist to initialize the field
If oXmlField.MetaData Is Nothing OrElse oXmlField.MetaData = "" Then
Throw New System.Exception("The " & oXmlField.Name & " XML field could not be initialized.")
Else
oXmlField.Value = oXmlField.MetaData
End If
End If
End Sub