.NET - Workflow, End User Diagrams, Reflection
Are there any tools that can mirror SharePoint Workflow or SharePoint Workflow assemblies and generate .png or some other type of image to present to the user? Dynamically via ASP.NET? Or if there is nothing like this ... how do you provide documentation / documentation to the end user?
I would be interested in free or non-free tools.
source to share
`There are several ways to use the workflow designer depending on your needs / desires.
First of all, you can save an image of the workflow using one of the menus. It's pretty static and needs to be done during development.
More flexible is the ability to override the workflow constructor in your application and generate an image on the fly. Below is the code from a console application, but I did the same inside ASP.NET. The main problem is that the designer was built for use in Visual Studio, which runs everything in the MTA thread, whereas ASP.NET uses STA threads. Just create a new MTA thread, execute the code, and wait for it to complete on the main ASP.NET STA thread, and you're good to go.
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
source to share