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状态筛选条件;
- 设定排序列及排序方式。
![WebPart.jpg](https://i-blog.csdnimg.cn/blog_migrate/43afe9a55f022604c98213f570b4ae28.jpeg)
从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)。
![SPS_Doc.gif](https://i-blog.csdnimg.cn/blog_migrate/8a5b6463d000d865717ecf6f8149c034.gif)
SharePoint 2003 List Event
SharePoint 2003 List Event功能更为强大,因为SharePoint中绝大多数信息都是以列表的方式储存的。使用SharePoint 2003 List Event用户可以创建、更新、删除任何标准的列表库或者用户自定义列表。
![SPS_List.jpg](https://i-blog.csdnimg.cn/blog_migrate/f7a9444c6078193ed196459991dc50cd.jpeg)
SharePoint 2003 Workspace Event
SharePoint 2003 Workspace Event用于在流程执行过程中创建或者删除SharePoint站点或者工作区。用户可以通过代码方式或者流程字段定义SharePoint站点或者工作区的名称、标题以及描述等等。同时用户还可以指定站点或者工作区所使用的模版。可用的模版直接读取自SharePoint站点,包括任何用户自定义的模版。
![SPS_WorkSpace.jpg](https://i-blog.csdnimg.cn/blog_migrate/e92850126f7504f321b9c82a4461eb8e.jpeg)
SharePoint 2003 Multiple Documents Event
SharePoint 2003 Multiple Documents Event与XML附件字段配合使用。XML附件字段可能包含多个文档。执行此向导时,用户需要选择希望执行的动作。所选择的动作对XML附件字段中的每个文档都执行同样的操作。
![SPS_MultiDoc.gif](https://i-blog.csdnimg.cn/blog_migrate/eeeacdce9bbfec29c1622693688980f8.gif)
在用户前台通过拖放式方式进行操作的同时,K2 Server会在后台自动生成相应的代码。如:
Public
Sub Main()
Sub Main(ByRef K2 As ServerEventContext)
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
' Set up variables
Dim Temp as String, ErrorMessage As String = ""
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
Dim Server As String
Server = "http://demo:81/"
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
If Not Server.EndsWith("/") Then Server &= "/"
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
Dim Site As String
Site = ""
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
If Not Site.EndsWith("/") And Site.Trim <> "" Then Site &= "/"
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
Dim Folder As String
Folder = "Shared Documents"
If Not Folder.EndsWith("/") Then Folder &= "/"
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
Dim File As String
File = K2.ProcessInstance.Folio
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
Dim LocalFolder As String
LocalFolder = "D:\"
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
Dim LocalFile As String
LocalFile = "code.txt"
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
Dim SpsList As New K2SPSList()
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
' Set Url for Web Service
SpsList.Url = Server & "_vti_bin/K2SpsList.asmx"
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
' Set Credentials
Dim SpsUtils As New SourceCode.K2SPUtilities.SPSUtilities
SpsList.Credentials = SpsUtils.GetCredentials(Server)
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
' Build The file path
Dim LocalFilePath as String
If Not LocalFolder.EndsWith("\") Then
LocalFilePath = LocalFolder & "\" & LocalFile
Else
LocalFilePath = LocalFolder & LocalFile
End If
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
' Read File Into Byte Array
Dim oByte() as Byte
Dim K2B64 as New K2Base64.K2Base64()
oByte = K2B64.FileToByteArray(LocalFilePath)
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
' 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
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
InitializeXmlField(K2.ProcessInstance.XmlFields("AttachedDocuments"))
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
' 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
![None.gif](/Images/OutliningIndicators/None.gif)
![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
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
待续。