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() 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