After attending Citrix Synergy last week, I wanted to come back and complete this 5 part series that I started before the conference began. In the last article (Part 3), I discussed the anatomy of a Workflow Studio project. The information in that article should help you get started in coding your activities. Next on the list is to discuss how to test your activity project within Workflow Studio once you’ve completed a bulk of the code in Visual Studio.
If you want to follow along with me, you should create the AdvancedDelay activity project as outlined within the Workflow Studio Developers Guide. The AdvancedDelay activity inserts a delay into your workflows for a specified amount of time. As discussed in the Developers Guide, the code that you add is pretty straightforward. You are just adding a property to specify the delay time and a sleep command in the execution section to perform the actual delay.
To make the testing process simple, I’ll break it up into the following sections. Each section is discussed in more detail below.
• Before you begin
• Build your solution in Visual Studio
• Copy the activity DLL to the Workflow Studio activities folder
• Launch Workflow Studio and create a new workflow project
• Add the activity to the workflow project and run/test the workflow
Before you begin
Before you compile your project, you should check out a few settings that are placed at the top of your activity file. If you are following the AdvancedDelay example, open the AdvancedDelay.cs file and check out the activity settings at the top.
• - this is the name of the activity as it will appear in the Workflow Studio Designer.
• - this is the location that the activity will be placed in within the Workflow Studio Designer activity pane. In the example below, I’m placing this activity within the General/Custom Activities folder. You can place this activity anywhere in the activity pane.
Build your solution in Visual Studio
You build the solution like any other Visual Studio project. Just navigate to Build–>Build Solution in the file menu. Verify that the build succeeds within the Output window at the bottom of Visual Studio.
Copy the activity DLL to the Workflow Studio activities folder
After you compile the project, a DLL is produced that contains your activity project code. This DLL is typically found in a sub-directory where your Visual Studio project resides on the system. In my environment, this DLL was found in my user profile since my Visual Studio projects are all written to my user profile (“C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\ProjectsAdvancedDelay\AdvancedDelay\bin\Debug”).
Copy the activity DLL (AdvancedDelay.dll in this example) and paste into “C:\Program Files\Citrix\Workflow Studio”. Your DLL will need to be here in order for Workflow Studio to use it.
: If your project happens to reference other 3rd party DLLs that you added manually to the project (for example, mfcom.dll for tying into XenApp), you’ll need to add these extra DLLs to the above folder as well. This allows the Workflow Studio Designer and Runtime to pick up these references to allow you to run the activity. In our example here, our AdvancedDelay activity project is pretty simple and we didn’t add a reference to another 3rd party DLL so we can bypass this action.
Launch Workflow Studio and create a new workflow project
With your activity DLL now in the right location, launch Workflow Studio and create a new workflow project. I typically like to create new workflow projects for testing activities, but you can also edit existing workflow projects if you desire.
Add the activity to the workflow project and run/test the workflow
The Workflow Studio Designer should now be displayed. If this is your first time testing the activity, the activity will not yet be displayed within the activity pane. To add the activity as an available activity within the pane, navigate to Tools–>Choose Activities. Browse to the activity, verify it is selected, and close the Choose Activities dialog. Notice the “Toolbox Location” field on this dialog. This is the location we specified in our code where this activity will be placed within the activity pane.
Verify the activity is now listed within the activity pane. Drag the activity to the designer surface and configure the properties as needed. Start the activity and verify that it runs as expected.
In the example below, I configured the AdvancedDelay activity to run for 5000 milliseconds (5 seconds). I then placed a message box beneath the delay. When running the activity, it should take about 5 seconds for the message box to pop up. If it does, I know this activity is running as expected.
One final note:
If you find that you need to make code changes to your activity, just open up Visual Studio, update your code, and recompile your project. You’ll then need to place the updated DLL back in the C:\Program Files\Citrix\Workflow Studio folder in order for Workflow Studio to pick it up. If you get an “Access Denied” type message, this typically means that you’ll need to close Workflow Studio (Console and Designer) in order to successfully overwrite the existing DLL that is in that location. The Workflow Studio executables will have a lock on that DLL if you just used a previous version of that DLL in a workflow.
Once you can copy the updated DLL to that location, re-open Workflow Studio, and edit your workflow project. When you edit your project, your workflow will automatically be referencing the new DLL. You don’t have to re-browse for the activity and add it to the activity pane. Make the appropriate property changes and workflow changes and re-execute your workflow.
In the next blog, I’ll explain how you can step through your code in real-time in case you wanted to perform more robust troubleshooting at this stage. Stay tuned!
Blogs in this series:
• Getting Started
• Setting up your Visual Studio development environment
• Anatomy of a Workflow Studio activity project
• Testing your Workflow Studio activity project (this one)
• Stepping through your Visual Studio code