-
-
Notifications
You must be signed in to change notification settings - Fork 162
Samples
Workflows can be designed through the Designer, through XML or JSON. However, it is highly recommended to understand Wexflow workflows syntax in order to become familiar with this workflow engine.
Each workflow in Wexflow has a configuration (XML/JSON). Each configuration contains a set of settings and tasks to do depending on a specified schedule and a specified configuration.
In this section, few workflow samples will be presented in order to make the end user familiar with Wexflow workflow syntax:
A sequential workflow executes a set of tasks in order, one by one. Tasks are executed in a sequential manner until the last task finishes. The order of the execution of the tasks can be altered by modifying the execution graph of the workflow.
This workflow uploads invoices to an SFTP server, then waits for 2 days and then notifies the customers.
<Workflow xmlns="urn:wexflow-schema" id="99" name="Workflow_Invoices" description="Workflow_Invoices">
<Settings>
<Setting name="launchType" value="trigger" />
<Setting name="enabled" value="true" />
</Settings>
<Tasks>
<Task id="1" name="FilesLoader" description="Loading invioces" enabled="true">
<Setting name="folder" value="C:\WexflowTesting\Invoices\" />
</Task>
<Task id="2" name="Ftp" description="Uploading invoices" enabled="true">
<Setting name="protocol" value="sftp" /> <!-- ftp|ftps|sftp -->
<Setting name="command" value="upload" /> <!-- list|upload|download|delete -->
<Setting name="server" value="127.0.1" />
<Setting name="port" value="21" />
<Setting name="user" value="user" />
<Setting name="password" value="password" />
<Setting name="path" value="/" />
<Setting name="selectFiles" value="1" />
</Task>
<Task id="3" name="Wait" description="Waiting for 2 days" enabled="true">
<Setting name="duration" value="2.00:00:00" />
</Task>
<Task id="4" name="FilesLoader" description="Loading emails" enabled="true">
<Setting name="file" value="C:\WexflowTesting\Emails\Invoices.xml" />
</Task>
<Task id="5" name="MailsSender" description="Notifying customers" enabled="true">
<Setting name="selectFiles" value="4" />
<Setting name="host" value="127.0.0.1" />
<Setting name="port" value="587" />
<Setting name="enableSsl" value="true" />
<Setting name="user" value="user" />
<Setting name="password" value="password" />
</Task>
<Task id="6" name="FilesMover" description="Moving invoices" enabled="true">
<Setting name="selectFiles" value="1" />
<Setting name="destFolder" value="C:\WexflowTesting\Invoices_sent\" />
</Task>
</Tasks>
</Workflow>
First of all, the FilesLoader task loads all the invoices located in the folder C:\WexflowTesting\Invoices, then the Ftp task uploads them to the SFTP server, then the Wait task waits for 2 days, then the FilesLoader task loads the emails in XML format and then the MailsSender task sends the emails. Finally, the FilesMover task moves the invoices to the folder C:\WexflowTesting\Invoices_sent.
This workflow waits for files to arrive in C:\WexflowTesting\Watchfolder1\ and C:\WexflowTesting\Watchfolder2\ then uploads them to an FTP server then moves them to C:\WexflowTesting\Sent\ folder. This workflow starts every 2 minutes.
<Workflow xmlns="urn:wexflow-schema" id="6" name="Workflow_FilesSender" description="Workflow_FilesSender">
<Settings>
<Setting name="launchType" value="periodic" />
<Setting name="period" value="00.00:02:00.00" />
<Setting name="enabled" value="true" />
</Settings>
<Tasks>
<Task id="1" name="FilesLoader" description="Loading files" enabled="true">
<Setting name="folder" value="C:\WexflowTesting\Watchfolder1\" />
<Setting name="folder" value="C:\WexflowTesting\Watchfolder2\" />
</Task>
<Task id="2" name="Ftp" description="Uploading files" enabled="true">
<Setting name="protocol" value="ftp" /> <!-- ftp|ftps|sftp -->
<Setting name="command" value="upload" /> <!-- list|upload|download|delete -->
<Setting name="server" value="127.0.1" />
<Setting name="port" value="21" />
<Setting name="user" value="user" />
<Setting name="password" value="password" />
<Setting name="path" value="/" />
<Setting name="selectFiles" value="1" />
</Task>
<Task id="3" name="FilesMover" description="Moving files to Sent folder" enabled="true">
<Setting name="selectFiles" value="1" />
<Setting name="destFolder" value="C:\WexflowTesting\Sent\" />
</Task>
</Tasks>
</Workflow>
First of all, the FilesLoader task loads all the files located in the folders C:\WexflowTesting\Watchfolder1\ and C:\WexflowTesting\Watchfolder2\ then the Ftp task loads the files and uploads them to the FTP server. Finally, the FilesMover task moves the files to the folder C:\WexflowTesting\Sent.
If you want to trigger tasks on file events, you should use FileSystemWatcher task to avoid having a lot of logs. Here is a sample workflow.
This workflow transcodes the WAV files located in C:\WexflowTesting\WAV\ to MP3 format through FFMPEG and moves the transcoded files to C:\WexflowTesting\MP3.
<Workflow xmlns="urn:wexflow-schema" id="12" name="Workflow_ffmpeg" description="Workflow_ffmpeg">
<Settings>
<Setting name="launchType" value="trigger" />
<Setting name="enabled" value="true" />
</Settings>
<Tasks>
<Task id="1" name="FilesLoader" description="Loading WAV files" enabled="true">
<Setting name="folder" value="C:\WexflowTesting\WAV\" />
</Task>
<Task id="2" name="ProcessLauncher" description="WAV to MP3" enabled="true">
<Setting name="selectFiles" value="1" />
<!-- You need to install FFMPEG -->
<Setting name="processPath" value="C:\Program Files\ffmpeg\bin\ffmpeg.exe" />
<!-- variables: {$filePath},{$fileName},{$fileNameWithoutExtension}-->
<Setting name="processCmd" value="-i {$filePath} -codec:a libmp3lame -qscale:a 2 {$output:$fileNameWithoutExtension.mp3}" />
<Setting name="hideGui" value="true" />
<Setting name="generatesFiles" value="true" />
</Task>
<Task id="3" name="FilesMover" description="Moving MP3 files from temp folder" enabled="true">
<Setting name="selectFiles" value="2" />
<Setting name="destFolder" value="C:\WexflowTesting\MP3\" />
</Task>
</Tasks>
</Workflow>
First of all, the FilesLoader task loads all the files located in the folder C:\WexflowTesting\WAV\ then the ProcessLauncher task launches FFMPEG process on every file by specifying the right command in order to create the MP3 file. Finally, the FilesMover task moves the MP3 files to the folder C:\WexflowTesting\MP3.
This workflow waits for WAV files to arrive in C:\WexflowTesting\WAV\ then transcodes them to MP3 files through VLC then uploads the MP3 files to an FTP server then moves the WAV files to C:\WexflowTesting\WAV_processed. This workflow starts every 2 minutes.
<Workflow xmlns="urn:wexflow-schema" id="13" name="Workflow_vlc" description="Workflow_vlc">
<Settings>
<Setting name="launchType" value="periodic" />
<Setting name="period" value="00.00:02:00.00" />
<Setting name="enabled" value="true" />
</Settings>
<Tasks>
<Task id="1" name="FilesLoader" description="Loading WAV files" enabled="true">
<Setting name="folder" value="C:\WexflowTesting\WAV\" />
</Task>
<Task id="2" name="ProcessLauncher" description="WAV to MP3" enabled="true">
<Setting name="selectFiles" value="1" />
<!-- You need to install VLC-->
<Setting name="processPath" value="C:\Program Files\VideoLAN\VLC\vlc.exe" />
<!-- variables: {$filePath},{$fileName},{$fileNameWithoutExtension}-->
<Setting name="processCmd" value="-I dummy {$filePath} :sout=#transcode{acodec=mpga}:std{dst={$output:$fileNameWithoutExtension.mp3},access=file} vlc://quit" />
<Setting name="hideGui" value="true" />
<Setting name="generatesFiles" value="true" />
</Task>
<Task id="3" name="Ftp" description="Uploading MP3 files" enabled="true">
<Setting name="protocol" value="ftp" />
<Setting name="command" value="upload" />
<Setting name="server" value="127.0.1" />
<Setting name="port" value="21" />
<Setting name="user" value="user" />
<Setting name="password" value="password" />
<Setting name="path" value="/" />
<Setting name="selectFiles" value="2" />
</Task>
<Task id="4" name="FilesMover" description="Moving WAV files" enabled="true">
<Setting name="selectFiles" value="1" />
<Setting name="destFolder" value="C:\WexflowTesting\WAV_processed\" />
</Task>
</Tasks>
</Workflow>
First of all, the FilesLoader task loads all the files located in the folder C:\WexflowTesting\WAV\ then the ProcessLauncher task launches VLC process on every file by specifying the right command in order to create the MP3 file. Then, the Ftp task loads the MP3 files generated by the ProcessLauncher task and then uploads them to the FTP server. Finally, the FilesMover task moves the processed WAV files to the folder C:\WexflowTesting\WAV_processed.
If you want to trigger tasks on file events, you should use FileSystemWatcher task to avoid having a lot of logs. Here is a sample workflow.
This workflow downloads specific files from an FTP server. This workflow starts by listing all the files located at the root folder of the server, then the specific files that will be downloaded are tagged through an XSLT (LisFiles.xslt), then the files are downloaded by the Ftp task through todo="toDownload" and from="app4" tags, then the downloaded files are moved to the folder C:\WexflowTesting\Ftp_download.
<Workflow xmlns="urn:wexflow-schema" id="40" name="Workflow_Ftp_download_tag" description="Workflow_Ftp_download_tag">
<Settings>
<Setting name="launchType" value="trigger" /> <!-- startup|trigger|periodic -->
<Setting name="enabled" value="true" /> <!-- true|false -->
</Settings>
<Tasks>
<Task id="1" name="Ftp" description="Listing files (FTP)" enabled="true">
<Setting name="command" value="list" />
<Setting name="protocol" value="ftp" /> <!-- ftp|ftps|sftp -->
<Setting name="server" value="127.0.1" />
<Setting name="port" value="21" />
<Setting name="user" value="user" />
<Setting name="password" value="password" />
<Setting name="path" value="/" />
</Task>
<Task id="2" name="ListFiles" description="Listing files" enabled="true">
</Task>
<Task id="3" name="Xslt" description="Renaming and tagging files" enabled="true">
<Setting name="selectFiles" value="2" />
<Setting name="xsltPath" value="C:\Wexflow\Xslt\ListFiles.xslt" />
<Setting name="version" value="2.0" /> <!-- 1.0|2.0 -->
<Setting name="removeWexflowProcessingNodes" value="false" />
</Task>
<Task id="4" name="Ftp" description="Downloading files" enabled="true">
<Setting name="command" value="download" />
<Setting name="protocol" value="ftp" /> <!-- ftp|ftps|sftp -->
<Setting name="server" value="127.0.1" />
<Setting name="port" value="21" />
<Setting name="user" value="user" />
<Setting name="password" value="password" />
<Setting name="path" value="/" />
<Setting name="selectFiles" todo="toDownload" from="app4" />
</Task>
<Task id="5" name="FilesMover" description="Moving files to Ftp_download" enabled="true">
<Setting name="selectFiles" value="4" />
<Setting name="destFolder" value="C:\WexflowTesting\Ftp_download\" />
<Setting name="overwrite" value="true" />
</Task>
</Tasks>
</Workflow>
Roughly speaking, the Ftp task loads the list of files located at the root folder of the FTP server in the running instance of the workflow, then the ListFiles task outputs and XML file that contains all the files loaded then the Xslt task takes as input this XML and generates an XML which contains a system node called WexflowProcessing which contains the list of files to be tagged and/or renamed.
To understand how tagging and renaming files work, refer to the documentation of the ListFiles and Xslt tasks.
Below is the XSLT ListFiles.xslt used for tagging files:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<root>
<WexflowProcessing>
<xsl:for-each select="//wexflowProcessing/Workflow/Files//File">
<xsl:choose>
<xsl:when test="@name = 'file1.txt'">
<File taskId="{@taskId}" name="{@name}" renameTo="file1_renamed.txt"
todo="toRename"
from="app1" />
</xsl:when>
<xsl:when test="@name = 'file2.txt'">
<File taskId="{@taskId}" name="{@name}" renameTo="file2_renamed.txt"
todo="toSend"
from="app2" />
</xsl:when>
<xsl:when test="@name = 'file3.txt'">
<File taskId="{@taskId}" name="{@name}" renameTo="file3_renamed.txt"
todo="toDownload"
from="app3" />
</xsl:when>
<xsl:when test="@name = 'file4.txt'">
<File taskId="{@taskId}" name="{@name}" renameTo="file4_renamed.txt"
todo="toDownload"
from="app4" />
</xsl:when>
</xsl:choose>
</xsl:for-each>
</wexflowProcessing>
</root>
</xsl:template>
</xsl:stylesheet>
This workflow loads the file C:\WexflowTesting\file1.txt then uploads it to an FTP server then moves it to C:\WexflowTesting\Sent\ folder.
<Workflow xmlns="urn:wexflow-schema" id="6" name="Workflow_Ftp_upload" description="Workflow_Ftp_upload">
<Settings>
<Setting name="launchType" value="trigger" />
<Setting name="enabled" value="true" />
</Settings>
<Tasks>
<Task id="1" name="FilesLoader" description="Loading files" enabled="true">
<Setting name="file" value="C:\WexflowTesting\file1.txt" />
</Task>
<Task id="2" name="Ftp" description="Uploading files" enabled="true">
<Setting name="protocol" value="ftp" />
<Setting name="command" value="upload" />
<Setting name="server" value="127.0.1" />
<Setting name="port" value="21" />
<Setting name="user" value="user" />
<Setting name="password" value="password" />
<Setting name="path" value="/" />
<Setting name="selectFiles" value="1" />
</Task>
<Task id="3" name="FilesMover" description="Moving files to Sent folder" enabled="true">
<Setting name="selectFiles" value="1" />
<Setting name="destFolder" value="C:\WexflowTesting\Sent\" />
</Task>
</Tasks>
<ExecutionGraph>
<Task id="1"><Parent id="-1" /></Task>
<Task id="2"><Parent id="1" /></Task>
<Task id="3"><Parent id="2" /></Task>
</ExecutionGraph>
</Workflow>
First of all, the FilesLoader task loads the file C:\WexflowTesting\file1.txt then the Ftp task loads that file and uploads it to the FTP server. Finally, the FilesMover task moves that file to the folder C:\WexflowTesting\Sent.
By convention, the parent task id of the first task to be executed must always be -1.
However, if the execution graph is modified as follows:
<ExecutionGraph>
<Task id="1"><Parent id="-1" /></Task>
<Task id="3"><Parent id="1" /></Task>
<Task id="2"><Parent id="3" /></Task>
</ExecutionGraph>
Task 3 will be executed after task 1.
If the execution graph is modified as follows:
<ExecutionGraph>
<Task id="3"><Parent id="-1" /></Task>
<Task id="2"><Parent id="3" /></Task>
<Task id="1"><Parent id="2" /></Task>
</ExecutionGraph>
Task 3 will be executed first, then task 2 then task 1.
Two things are forbidden in the execution graph:
- Infinite loops.
- Parallel tasks.
Here is an example of infinite loops:
<ExecutionGraph>
<Task id="1"><Parent id="-1" /></Task>
<Task id="2"><Parent id="1" /></Task>
<Task id="1"><Parent id="2" /></Task>
</ExecutionGraph>
Here is an example of parallel tasks:
<ExecutionGraph>
<Task id="1"><Parent id="-1" /></Task>
<Task id="2"><Parent id="1" /></Task>
<Task id="3"><Parent id="1" /></Task>
</ExecutionGraph>
A flowchart workflow is a workflow that contains at least one flowchart node (If/While/Switch) in its execution graph. A flowchart node takes as input a flowchart task and a set of tasks to execute in order, one by one. The order of the execution of the tasks can be altered by modifying the execution graph of the flowchart node.
The following workflow is a flowchart workflow that is triggered by the file file.trigger. If the file file.trigger is found on the file system then this workflow will upload the file file1.txt to an FTP server then it will notify customers that the upload was successful. Otherwise, if the trigger file.trigger is not found on the file system then the workflow will notify customers that the upload failed.
<Workflow xmlns="urn:wexflow-schema" id="7" name="Workflow_If" description="Workflow_If">
<Settings>
<Setting name="launchType" value="trigger" />
<Setting name="enabled" value="true" />
</Settings>
<Tasks>
<Task id="1" name="FilesLoader" description="Loading files" enabled="true">
<Setting name="file" value="C:\WexflowTesting\file1.txt" />
</Task>
<Task id="2" name="Ftp" description="Uploading files" enabled="true">
<Setting name="protocol" value="ftp" />
<Setting name="command" value="upload" />
<Setting name="server" value="127.0.1" />
<Setting name="port" value="21" />
<Setting name="user" value="user" />
<Setting name="password" value="password" />
<Setting name="path" value="/" />
<Setting name="selectFiles" value="1" />
</Task>
<Task id="3" name="FilesLoader" description="Loading emails (OK)" enabled="true">
<Setting name="file" value="C:\WexflowTesting\Emails\Emails.xml" />
</Task>
<Task id="4" name="MailsSender" description="Notifying customers (OK)" enabled="true">
<Setting name="selectFiles" value="3" />
<Setting name="host" value="127.0.0.1" />
<Setting name="port" value="587" />
<Setting name="enableSsl" value="true" />
<Setting name="user" value="user" />
<Setting name="password" value="password" />
</Task>
<Task id="5" name="FilesLoader" description="Loading emails (KO)" enabled="true">
<Setting name="file" value="C:\WexflowTesting\Emails\Emails.xml" />
</Task>
<Task id="6" name="MailsSender" description="Notifying customers (KO)" enabled="true">
<Setting name="selectFiles" value="5" />
<Setting name="host" value="127.0.0.1" />
<Setting name="port" value="587" />
<Setting name="enableSsl" value="true" />
<Setting name="user" value="user" />
<Setting name="password" value="password" />
</Task>
<Task id="99" name="FileExists" description="Checking trigger file" enabled="true">
<Setting name="file" value="C:\WexflowTesting\file.trigger" />
</Task>
</Tasks>
<ExecutionGraph>
<If id="100" parent="-1" if="99">
<Do>
<Task id="1"><Parent id="-1" /></Task>
<Task id="2"><Parent id="1" /></Task>
<Task id="3"><Parent id="2" /></Task>
<Task id="4"><Parent id="3" /></Task>
</Do>
<Else>
<Task id="5"><Parent id="-1" /></Task>
<Task id="6"><Parent id="5" /></Task>
</Else>
</If>
</ExecutionGraph>
</Workflow>
By convention, the parent task id of the first task to execute in and nodes must always be -1.
You can add If flowchart nodes pretty much wherever you want in the execution graph. Also, you can add as mush as you want. You can also add them in the event nodes OnSuccess, OnWarning and OnError.
An If can be inside an If, a While and a Switch.
This workflow is triggered by the file file.trigger. While the file file.trigger exists, this workflow will upload the file file1.txt to an FTP server then it will notify customers then it will wait for 2 days then it will start again.
<Workflow xmlns="urn:wexflow-schema" id="8" name="Workflow_While" description="Workflow_While">
<Settings>
<Setting name="launchType" value="trigger" />
<Setting name="enabled" value="true" />
</Settings>
<Tasks>
<Task id="1" name="FilesLoader" description="Loading files" enabled="true">
<Setting name="file" value="C:\WexflowTesting\file1.txt" />
</Task>
<Task id="2" name="Ftp" description="Uploading files" enabled="true">
<Setting name="protocol" value="ftp" />
<Setting name="command" value="upload" />
<Setting name="server" value="127.0.1" />
<Setting name="port" value="21" />
<Setting name="user" value="user" />
<Setting name="password" value="password" />
<Setting name="path" value="/" />
<Setting name="selectFiles" value="1" />
</Task>
<Task id="3" name="FilesLoader" description="Loading emails" enabled="true">
<Setting name="file" value="C:\WexflowTesting\Emails\Emails.xml" />
</Task>
<Task id="4" name="MailsSender" description="Notifying customers" enabled="true">
<Setting name="selectFiles" value="3" />
<Setting name="host" value="127.0.0.1" />
<Setting name="port" value="587" />
<Setting name="enableSsl" value="true" />
<Setting name="user" value="user" />
<Setting name="password" value="password" />
</Task>
<Task id="5" name="Wait" description="Waiting for 2 days..." enabled="true">
<Setting name="duration" value="02.00:00:00" />
</Task>
<Task id="99" name="FileExists" description="Checking trigger file" enabled="true">
<Setting name="file" value="C:\WexflowTesting\file.trigger" />
</Task>
</Tasks>
<ExecutionGraph>
<While id="100" parent="-1" while="99">
<Task id="1"><Parent id="-1" /></Task>
<Task id="2"><Parent id="1" /></Task>
<Task id="3"><Parent id="2" /></Task>
<Task id="4"><Parent id="3" /></Task>
<Task id="5"><Parent id="4" /></Task>
</While>
</ExecutionGraph>
</Workflow>
By convention, the parent task id of the first task to be executed in the node must always be -1.
You can add While flowchart nodes pretty much wherever you want in the execution graph. Also, you can add as mush as you want. You can also add them in the event nodes OnSuccess, OnWarning and OnError.
A While can be inside a While, an If and a Switch.
This workflow starts every 24 hours. On Monday, it uploads files to an FTP server and on Wednesday it notifies customers.
<Workflow xmlns="urn:wexflow-schema" id="43" name="Workflow_Switch" description="Workflow_Switch">
<Settings>
<Setting name="launchType" value="periodic" />
<Setting name="period" value="1.00:00:00" />
<Setting name="enabled" value="true" />
</Settings>
<Tasks>
<Task id="1" name="Now" description="Getting current day" enabled="true">
<Setting name="culture" value="en-US" />
<Setting name="format" value="dddd" />
</Task>
<Task id="2" name="FilesLoader" description="Loading files" enabled="true">
<Setting name="file" value="C:\WexflowTesting\file1.txt" />
</Task>
<Task id="3" name="Ftp" description="Uploading files" enabled="true">
<Setting name="protocol" value="ftp" />
<Setting name="command" value="upload" />
<Setting name="server" value="127.0.1" />
<Setting name="port" value="21" />
<Setting name="user" value="user" />
<Setting name="password" value="password" />
<Setting name="path" value="/" />
<Setting name="selectFiles" value="1" />
</Task>
<Task id="4" name="FilesLoader" description="Loading emails" enabled="true">
<Setting name="file" value="C:\WexflowTesting\Emails\Emails.xml" />
</Task>
<Task id="5" name="MailsSender" description="Notifying customers" enabled="true">
<Setting name="selectFiles" value="3" />
<Setting name="host" value="127.0.0.1" />
<Setting name="port" value="587" />
<Setting name="enableSsl" value="true" />
<Setting name="user" value="user" />
<Setting name="password" value="password" />
</Task>
</Tasks>
<ExecutionGraph>
<Switch id="100" parent="-1" switch="1">
<Case value="Monday">
<Task id="2"><Parent id="-1" /></Task>
<Task id="3"><Parent id="2" /></Task>
</Case>
<Case value="Wednesday">
<Task id="4"><Parent id="-1" /></Task>
<Task id="5"><Parent id="4" /></Task>
</Case>
<Default />
</Switch>
</ExecutionGraph>
</Workflow>
By convention, the parent task id of the first task to be executed in the Case/Default nodes must always be -1.
You can add Switch flowchart nodes pretty much wherever you want in the execution graph. Also, you can add as mush as you want. You can also add them in the event nodes OnSuccess, OnWarning and OnError.
A Switch can be inside a While, an If and a Switch.
Approval workflows are workflows marked as approval through approval setting option. They can be marked as approval whether from the Designer page in the back end or by XML editing:
<Workflow xmlns="urn:wexflow-schema" id="125" name="Workflow_Approval" description="Workflow_Approval">
<Settings>
<Setting name="launchType" value="trigger" />
<Setting name="enabled" value="true" />
<Setting name="approval" value="true" />
</Settings>
<LocalVariables />
<Tasks />
</Workflow>
Approval workflows must contain at least one Approval task. Approval tasks can be put wherever you want in the workflow and can be multiple. You can create workflows where some tasks get done then the workflow waits for approval then the users are notified for example.
Workflows are being approved whether from Wexflow Manager or from Approval page in the backend.
If the workflow is rejected the OnRejected workflow event is raised and the tasks after Approval task are not executed.
The rejection of workflows can be done by clicking on reject button whether from Approval page in the back end or from Wexflow Manager.
To give you a hint on how approval workflows work, here is a very simple example:
<Workflow xmlns="urn:wexflow-schema" id="131" name="Workflow_Approval" description="Workflow_Approval">
<Settings>
<Setting name="launchType" value="trigger" />
<Setting name="enabled" value="true" />
<Setting name="approval" value="true" />
</Settings>
<LocalVariables />
<Tasks>
<Task id="1" name="Approval" description="Waiting for approval" enabled="true" />
<Task id="2" name="Wait" description="Waiting for 2 seconds" enabled="true">
<Setting name="duration" value="00.00:00:02" />
</Task>
</Tasks>
</Workflow>
This simple workflow is an approval workflow that waits for approval in order to start. Once approved, this workflow waits for 2 seconds. This workflow can be approved or rejected whether from Wexflow Manager or from Approval page in the backend.
Here is another simple approval workflow:
<Workflow xmlns="urn:wexflow-schema" id="132" name="Workflow_Approval_Disapprove" description="Workflow_Approval_Disapprove">
<Settings>
<Setting name="launchType" value="trigger" />
<Setting name="enabled" value="true" />
<Setting name="approval" value="true" />
</Settings>
<LocalVariables />
<Tasks>
<Task id="1" name="Approval" description="Waiting for approval" enabled="true" />
<Task id="2" name="Wait" description="Waiting for 2 seconds" enabled="true">
<Setting name="duration" value="00.00:00:02" />
</Task>
<Task id="3" name="Wait" description="Waiting for 3 seconds" enabled="true">
<Setting name="duration" value="00.00:00:03" />
</Task>
</Tasks>
<ExecutionGraph>
<Task id="1"><Parent id="-1" /></Task>
<Task id="2"><Parent id="1" /></Task>
<OnRejected>
<Task id="3"><Parent id="-1" /></Task>
</OnRejected>
</ExecutionGraph>
</Workflow>
This simple workflow is an approval workflow that waits for approval in order to start. Once approved, this workflow waits for 2 seconds. If this workflow is rejected, the task 2 is not executed and the task 3 is executed. In other words, if this workflow is rejected it waits for 3 seconds. This workflow can be approved or rejected whether from Wexflow Manager or from Approval page in the backend.
Here is a more professional approval workflow:
<Workflow xmlns="urn:wexflow-schema" id="132" name="Workflow_YouTube" description="Workflow_YouTube">
<Settings>
<Setting name="launchType" value="trigger" />
<Setting name="enabled" value="true" />
<Setting name="approval" value="true" />
</Settings>
<LocalVariables />
<Tasks>
<Task id="1" name="FilesLoader" description="Loading YouTube videos" enabled="true">
<Setting name="file" value="C:\WexflowTesting\YouTube\YouTube.xml" />
</Task>
<Task id="2" name="YouTube" description="Uploading YouTube videos" enabled="true">
<Setting name="selectFiles" value="1" />
<Setting name="user" value="username" />
<Setting name="applicationName" value="Wexflow" />
<Setting name="clientSecrets" value="C:\Wexflow-dotnet-core\client_secrets.json" />
</Task>
<Task id="3" name="Approval" description="Waiting for approval" enabled="true" />
<Task id="4" name="FilesLoader" description="Loading notification mails" enabled="true">
<Setting name="file" value="C:\WexflowTesting\Mails\mails.xml" />
</Task>
<Task id="5" name="MailsSender" description="Sending notification mails" enabled="true">
<Setting name="selectFiles" value="4" />
<Setting name="host" value="smtp.gmail.com" />
<Setting name="port" value="587" />
<Setting name="enableSsl" value="true" />
<Setting name="user" value="user" />
<Setting name="password" value="password" />
</Task>
</Tasks>
</Workflow>
This workflow starts by uploading videos to YouTube then it waits for approval in order to check that videos have been effectively uploaded with success to YouTube and edited by the management team. Then, if this workflow is approved from Approval page in the backend or from Wexflow Manager.
When this workflow arrives to Approval task, it suspends its jobs and waits for approval process until it's being approved and then continues its tasks.
Here is another interesting approval workflow:
<Workflow xmlns="urn:wexflow-schema" id="134" name="Workflow_FormSubmission" description="Workflow_FormSubmission">
<Settings>
<Setting name="launchType" value="trigger" />
<Setting name="enabled" value="true" />
<Setting name="approval" value="true" />
</Settings>
<Tasks>
<Task id="1" name="ProcessLauncher" description="Form submission" enabled="true">
<Setting name="processPath" value="C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" />
<Setting name="processCmd" value="https://docs.google.com/forms/d/1sHnPCJ05GLecqvZb0MNeFkFK0eMuVqBUyWAo5uurEQ8/prefill" />
<Setting name="hideGui" value="false" />
<Setting name="generatesFiles" value="false" />
</Task>
<Task id="2" name="Approval" description="Waiting for approval" enabled="true" />
<Task id="3" name="Wait" description="Waiting for 2 seconds" enabled="true">
<Setting name="duration" value="00.00:00:02" />
</Task>
<Task id="4" name="Wait" description="Waiting for 3 seconds" enabled="true">
<Setting name="duration" value="00.00:00:03" />
</Task>
</Tasks>
<ExecutionGraph>
<Task id="1"><Parent id="-1" /></Task>
<Task id="2"><Parent id="1" /></Task>
<!-- You can add other tasks here depending on your need. -->
<Task id="3"><Parent id="2" /></Task>
<OnRejected>
<!-- You can add other tasks here depending on your need. -->
<Task id="4"><Parent id="-1" /></Task>
</OnRejected>
</ExecutionGraph>
</Workflow>
This approval workflow opens a submission form and waits for approval. If the submission is correct, the workflow is approved and waits for 2 seconds (this is just a simple task for testing but you can add email tasks or whatever). Otherwise, if the submission is incorrect, the workflow is rejected and waits for 3 seconds (this is just a simple task for testing but you can add email tasks or whatever). This workflow works on the .NET Core version of Wexflow only because the .NET version of Wexflow does not support opening GUI from ProcessLauncher task since Wexflow server is running in a Windows service in the .NET version.
Approval workflows are very useful when some tasks get done then you have to wait for approval to check that previous tasks have been done with success then users are notified for example. This is just an example, but you can create and imagine other examples as you want and as you need.
Wexflow allows approval workflows on generic assets called records. A record is an entity that refers to a file. Each record has a name, a description, file versions, comments, and approval start and end dates.
A manager can assign a record to a user. If the record is updated with required info, the manajer can approve or reject the workflow.
Here is a simple approval workflow on records:
<?xml version="1.0" encoding="utf-8"?>
<Workflow xmlns="urn:wexflow-schema" id="146" name="Workflow_ApproveDocument" description="Workflow_ApproveDocument">
<Settings>
<Setting name="launchType" value="trigger" />
<Setting name="enabled" value="true" />
<Setting name="approval" value="true" />
<Setting name="enableParallelJobs" value="true" />
</Settings>
<LocalVariables />
<Tasks>
<Task id="1" name="ApproveRecord" description="Approve document" enabled="true">
<Setting name="record" value="1" />
<Setting name="assignedTo" value="wexflow" />
</Task>
</Tasks>
</Workflow>
The manager assigns the record 1 to the user wexflow. The user wexflow will receive a notification in Wexflow and an email if email settings are properly configured to edit the record in question. After the record is updated, the manager will receive a notification and can then check the latest version of the recod. If the record info is good, the manager can approve the workflow. Otherwise, he can reject it.
After a workflow finishes its job, its final result is either success, or warning or error or rejected. If its final result is success, the OnSuccess event is triggered. If its final result is warning, the OnWarning event is triggered. If its final result is error, the OnError event is triggered. If the workflow is rejected, the OnRejected event is triggered. An event contains a set of tasks and/or flowchart nodes to execute in order, one by one. The order of the execution of the tasks and/or flowchart nodes can be altered by modifying the execution graph of the event.
This workflow uploads the file1.txt to an FTP server then notifies customers in case of success.
<Workflow xmlns="urn:wexflow-schema" id="9" name="Workflow_Events" description="Workflow_Events">
<Settings>
<Setting name="launchType" value="trigger" />
<Setting name="enabled" value="true" />
</Settings>
<Tasks>
<Task id="1" name="FilesLoader" description="Loading files" enabled="true">
<Setting name="file" value="C:\WexflowTesting\file1.txt" />
</Task>
<Task id="2" name="Ftp" description="Uploading files" enabled="true">
<Setting name="protocol" value="ftp" />
<Setting name="command" value="upload" />
<Setting name="server" value="127.0.1" />
<Setting name="port" value="21" />
<Setting name="user" value="user" />
<Setting name="password" value="password" />
<Setting name="path" value="/" />
<Setting name="selectFiles" value="1" />
</Task>
<Task id="3" name="FilesLoader" description="Loading emails" enabled="true">
<Setting name="file" value="C:\WexflowTesting\Emails\Emails.xml" />
</Task>
<Task id="4" name="MailsSender" description="Notifying customers" enabled="true">
<Setting name="selectFiles" value="3" />
<Setting name="host" value="127.0.0.1" />
<Setting name="port" value="587" />
<Setting name="enableSsl" value="true" />
<Setting name="user" value="user" />
<Setting name="password" value="password" />
</Task>
</Tasks>
<ExecutionGraph>
<Task id="1"><Parent id="-1" /></Task>
<Task id="2"><Parent id="1" /></Task>
<OnSuccess>
<Task id="3"><Parent id="-1" /></Task>
<Task id="4"><Parent id="3" /></Task>
</OnSuccess>
</ExecutionGraph>
</Workflow>
The flowchart event nodes OnWarning, OnError and OnRejected can be used in the same way. You can put If and While flowchart nodes in event nodes.
For OnRejected workflow event, the workflow must be an approval workflow and must contain at least one Approval task. The OnRejected workflow event is raised once the end user clicks on reject button whether from the Approval page in the backend or from Wexflow Manager.
These are simple and basic workflows to give an idea on how to make your own workflows. However, if you have multiple systems, applications and automations involved in a workflow, the workflow could be very interesting.
Copyright © Akram El Assas. All rights reserved.