Workflow Customization |
Scroll |
The following example shows how to replace the Therfore™ Workflow Form by a custom Workflow Form. In the example we display a custom workflow form for the Workflow Process "My Custom Process" and for every instance that is in "My Custom Task" step.
Requirements and Assumptions:
Visual Basic Imports System.Runtime.InteropServices Imports System.IO Imports System.Windows.Forms Imports Therefore.API
<Guid("02F95848-1E91-4061-AF7D-EC5727A86611), ComVisible(True), ClassInterface(ClassInterfaceType.None)> _ Public Class CustomWorkflowDialog Implements ITheAddIn
Public Sub GetHandledEvents(ByVal clientType As TheClientType, ByVal eventSet As TheEventSet) Implements ITheAddIn.GetHandledEvents eventSet.Add(TheEventType.OpenWorkflowInstance) End Sub
Public Function HandleEvent(ByVal e As TheEvent) As Integer Implements ITheAddIn.HandleEvent public int HandleEvent(TheEvent pEvent)
Dim nInstanceNo As Integer = pEvent.ObjectID
Dim s As New TheServer s.Connect(TheClientType.CustomApplication)
Dim wfInst As New TheWFInstance wfInst.Load(s, nInstanceNo)
If (wfInst.ProcessName == "My Custom Process" && wfInst.CurrTaskName == "My Custom Task") Dim nDocNo As Integer = wfInst.GetLinkedDocAt(0).DocNo
//create and show you customized workflow dialog Dim f As New CustomWorkflowForm(nDocNo) If (f.ShowDialog() == DialogResult.Cancel) Return 2 //return "user canceled request" Else If (f.ShowDialog() == DialogResult.OK) If (f.bApproved) Dim wfTask As TheWFTask = wfInst.GetNextTaskAt(0) wfInst.ClaimInstance(s) wfInst.FinishCurrentTask(s, wfTask.TaskNo, "") Return 1 //return "instance was processed - refresh inbox" Else Dim wfTask As TheWFTask = wfInst.GetNextTaskAt(0) wfInst.ClaimInstance(s) wfInst.FinishCurrentTask(s, wfTask.TaskNo, "") Return 1 //return "instance was processed - refresh inbox" End If End If End If Return 0 //return "display default workflow form" End Function End Class
C# using System; using System.Collections.Generic; using System.Text; using Therefore.API; using System.Windows.Forms; using System.Runtime.InteropServices;
namespace Therefore.Addins { [Guid("02F95848-1E91-4061-AF7D-EC5727A86611"), ComVisible(true)] public class CustomWorkflowDialog : ITheAddIn { #region ITheAddIn Members
public void GetHandledEvents(TheClientType nClient,TheEventSet pEventSet) { pEventSet.Add(TheEventType.OpenWorkflowInstance); }
public int HandleEvent(TheEvent pEvent) { int nInstanceNo = pEvent.ObjectID;
TheServer s = new TheServer(); s.Connect(TheClientType.CustomApplication);
TheWFInstance wfInst = new TheWFInstance(); wfInst.Load(s, nInstanceNo);
if (wfInst.ProcessName == "My Custom Process" && wfInst.CurrTaskName == "My Custom Task") { int nDocNo = wfInst.GetLinkedDocAt(0).DocNo;
//create and show you customized workflow dialog CustomWorkflowForm f = new CustomWorkflowForm(nDocNo); if (f.ShowDialog() == DialogResult.Cancel) return 2; //return "user canceled request" else if (f.ShowDialog() == DialogResult.OK) { if (f.bApproved) { TheWFTask wfTask = wfInst.GetNextTaskAt(0); wfInst.ClaimInstance(s); wfInst.FinishCurrentTask(s, wfTask.TaskNo, ""); return 1; //return "instance was processed - refresh inbox" } else { TheWFTask wfTask = wfInst.GetNextTaskAt(1); wfInst.ClaimInstance(s); wfInst.FinishCurrentTask(s, wfTask.TaskNo, ""); return 1; //return "instance was processed - refresh inbox" } } } return 0; //return "display default workflow form" }
#endregion } } |
|
See Also
|