.NET - 工作流程,最终用户图表,反射

时间:2009-09-01 13:43:05

标签: .net sharepoint workflow workflow-foundation

是否有任何工具可以反映在Windows Workflow或SharePoint Workflow程序集上,并生成.png或其他图像类型以呈现给用户?通过ASP.NET动态地?或者如果没有这样的东西......你如何提供文档/最终用户文档?

我会对免费或非免费工具感兴趣。

1 个答案:

答案 0 :(得分:0)

`根据您的需求/愿望,有几种方法可以使用工作流程设计师。

首先,您可以使用其中一个菜单保存工作流程的图像。这是相当静态的,你需要在设计时做些事情。

更灵活的是在应用中重新托管工作流设计器并动态生成图像的选项。下面的代码来自一个控制台应用程序,但我在ASP.NET中做了同样的事情。主要问题是设计器是为在Visual Studio中使用而创建的,它在MTA线程中的所有内容中运行,而ASP.NET使用STA线程。只需创建一个新的MTA线程,执行代码并等待它在主ASP.NET STA线程中完成,你就可以了。

Imports System.ComponentModel.Design
Imports System.ComponentModel.Design.
Imports System.Drawing.Imaging
Imports System.Workflow.Activities
Imports System.Workflow.ComponentModel
Imports System.Workflow.ComponentModel.Design

Module Module1
Sub Main()
    Dim workflow AsNew SequentialWorkflowActivity
    workflow.Activities.Add(New DelayActivity())

    Dim loader AsNew WorkflowLoader(workflow)
    Dim surface AsNew DesignSurface
    surface.BeginLoad(loader)
    Dim view AsNew WorkflowView(CType(surface, IServiceProvider))
    view.SaveWorkflowImage("workflow.png", ImageFormat.Png)

    Process.Start("workflow.png")
End Sub
End Module


Public Class WorkflowLoader
Inherits WorkflowDesignerLoader

Private _workflowDefinition As Activity

SubNew(ByVal workflowDefinition As Activity)
    _workflowDefinition = workflowDefinition
EndSub

ProtectedOverridesSub PerformLoad(ByVal serializationManager As IDesignerSerializationManager)
    MyBase.PerformLoad(serializationManager)

    Dim designerHost As IDesignerHost = Me.GetService(GetType(IDesignerHost))
    Dim allActivities As List(Of Activity) = WorkflowUtils.GetAllActivities(_workflowDefinition)

    ForEach item As Activity In allActivities
        designerHost.Container.Add(item, item.QualifiedName)
    Next
EndSub

Public Overrides ReadOnly Property FileName() As String
    Get
        Return""
    EndGet
End Property

PublicOverridesFunction GetFileReader(ByVal filePath AsString) As System.IO.TextReader
    ThrowNew NotSupportedException()
End Function

Public Overrides Function GetFileWriter(ByVal filePath AsString) As System.IO.TextWriter
    Throw New NotSupportedException()
End Function
End Class