Workflow Tips n Tricks Thread
I thought I'd start up a thread where everyone can post their tips and tricks related to workflow. Feel free to add your own and post feedback on other peoples tips n tricks.
Running activities in parallel
Parallel activities are an extremely powerful tool if used correctly. The main benefit of using them is being able to run a branch of activities and then when an async activity is hit, the parallel continues onto the next branch until the next async activity is hit, and so on. This can help reduce the time in which your workflow runs since it is not stopping and waiting for that expensive query to finish.
There are a few key concepts to using parallel activities correctly:
Async Activities: There is no real benefit in using parallel activities other than being cosmetic if you do not have async code, client activities or a combiniation of both running in them. In the upcoming Geocortex Essentials 3.15 release, you will be able to see which activities are async from the workflow designer's help module.
Client and Server Side Activities: There is nothing preventing you from putting client, server side, async and sync activities in a parallel. There may actually be cases where it makes sense for you, but when starting out, it's best to keep them separate. You see that place in your workflow where you select some features, zoom to a location and add some markup geometry? Well, it could probably be in parallel, it could save you a second.
Checking if a feature set has features (the quick way)
Before you try any fancy processing on a featureset, you can handle a whole bunch of potential issues if you check for FeatureSet.Features.Any() upfront. Alternatively, you can use Count().
Storing credentials on the server and retrieving them in workflow
You can add keyed values to your web.config file and retrieve them in workflow activities such as get token. To setup these key value pairs, you can open up your REST web.config file located in C:\Program Files (x86)\Latitude Geographics\Geocortex Essentials\Default\REST Elements\REST . At the top of this config file will be an <appsettings> node which contains <add> nodes. Here are some sample key values:
<add key="SecureUser" value="user" />
<add key="SecurePassword" value="password123" />
This is where you can store things such as passwords, credentials and secret server names. It is more secure than putting these things in workflow properties for example.
To retrieve these in workflow call:
System.Configuration.ConfigurationManager.AppSettings("SecureUser") and
System.Configuration.ConfigurationManager.AppSettings("SecurePassword")
You can use these calls inside an activity, or assign them to a string first, it's your call.
-
Useful tips.
0 -
How to use SQL 'IN'-clause in WHERE-clause in the SQL QUERY Task
When you have one parameter which passes the comma delimietered variable with which you think you want to put in IN-clause, say 'WHERE aFieldName IN ([Your Parameter Name])' in the command text, it won't work when the variable contains more than one thing to filter since "You can't use a single parameter for a list of values ".
This is what you can do to achieve with the MS SQL DB and in the Oracle DB.
(1) MS SQL DB : create a table-valued function to split your string parameter
- Create a Function to split a long string (comma-delimitered input variable). For example, you call that function as 'F_Split'
- Configure the Command Text as 'SELECT * FROM [Table Name] WHERE [Column Name] IN (SELECT CAST(Value AS INT) FROM F_Split(@parameterName, ','))'.
- Refer how to implement 'F_Split' function on http://stackoverflow.com/questions/5401641/passing-a-sql-parameter-to-an-in-clause-using-typed-datasets-in-net
(2) Oracle: utilize the oracle ' (http://download-uk.oracle.com/docs/cd/B12037_01/server.101/b10759/functions116.htm) regexp_substr function'
- Use the regexp_substr function in your comman text. For example,
- SELECT *
FROM [Table Name]
WHERE [Column Name] IN (
SELECT regexp_substr([:parametername],'[^,]+', 1, level) from dual
connect by regexp_substr([:parametername], '[^,]+', 1, level) is not null )' - Refer the detailed information about regexp_substr on https://blogs.oracle.com/aramamoo/entry/how_to_split_comma_separated_string_and_pass_to_in_clause_of_select_statement
Let's share all cool/meagre tips n tricks we found to make the place you enter in the better little more (it sounds like a slogan from boy-scout ^_*)!
0 -
Token for a Secured Map Service for Query Task activity
Just an FYI that, as of Essentials 3.15, the Get Token activity is not needed for getting ArcGIS tokens for secured services that are part of a site; the Token out argument of GetMapServiceInfo will work just fine now.
0 -
Sending FeatureSet both to ActiveCollection (Named Collection) and DefaultCollection
Sometimes you want to send the FeatureSet (from QueryTask or BufferedTask etc) to display on the Result as the ActiveCollection or Default Collection using SelectFeatures activity.
Rather than executing two consecutive SelectFeatures activities (with/without Collection Name), call SelectFeatures with Collection name (so sending as Active Collection), and then Run ExternalCommand with 'AppendToDefaultCollectionById' whose parameter is the Collection Name you used on SelectFeature.
To Check the FeatureSet Content
Find Log Activity (under Debugging group) on WF designer, and put Message as 'featureSet.ToJason', and then check your REST System Logging file to check. It depends on the Log Level you set on Rest manager though (Default is Info). So set Log activity as Info level unless you want to see lots of Debug logging.
0 -
Hi Kevin,
I looked the workflow designer 4.1's help module but couldn't find where it can tells me if an activity is async or not. Any suggestions? Thanks.
regards,
Jack
0 -
You can see if an activity is Async by looking at it's Inheritance Hierarchy in the help section for the activity.
/customer/servlet/servlet.FileDownload?file=00P6000000e88Z6EAI
0 -
I see. Thanks Kevin.
0 -
Hello,
So here's one tip saying - Storing credentials on the server and retrieving them in workflow
I have query here on something similar. I have ArcGIS online account from where all my feature layers are loaded. But all my queries on feature layer should be performed based on identity server authentiication. Now if I login thru identity server credentials, none of my feature layers load saying access denied. (which is obvious).
So can i store my arcgis online credentials on the server (config file) as they are never going to change and then make user to login thru identity server and open site with all layers loaded?
Thanks.
0 -
Hi Kevin, I'm re-reading your thread, and really hope more tips added on to it. Just a question about Parallel. You said "There is no real benefit in using parallel activities other than being cosmetic if you do not have async code, client activities or a combiniation of both running in them." Does that mean only activities that inherited from System.Activities.AsyncCodeActivity or under the Common Client section are benifited by running in Parallel? Or how can I be sure on which activities are Client activities? thanks 0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
9 Kommentare