Square9Softworks / CallAssemblyExamples

Sample code for GlobalAction's Call Assembly Node
0 stars 5 forks source link

Support for Workflow specific Input IDs #10

Closed VertexGeneral closed 7 years ago

VertexGeneral commented 7 years ago

This version includes the deserialization of the XML to a class. I have also added some error handling.

This updated code can manage multiple workflows for GlobalAction or GlobalCapture within a single mapping file for that feature. It allows a user to pass a workflow ID to the call assembly as a workflow field and will match that ID to a mapping in the PropertyMapping.xml file to get back the specific workflow's Connection String, SQL Statement, and Return Value IDs.

The new XML sample below shows how the schema should be structured:

<?xml version="1.0" encoding="utf-8" ?>
<PropertyMapping>
  <PropertyMap>
    <WorkflowID>SAMPLE</WorkflowID>
    <ConnectionString>1</ConnectionString>
    <SqlStatement>2</SqlStatement>
    <ReturnValue>3</ReturnValue>
  </PropertyMap>
  <PropertyMap>
    <WorkflowID>eF37bs64D</WorkflowID>
    <ConnectionString>4</ConnectionString>
    <SqlStatement>5</SqlStatement>
    <ReturnValue>6</ReturnValue>
  </PropertyMap>
</PropertyMapping>

A user must create a workflow field in GlobalCapture or GlobalAction and set the field value to read WorkflowID=myID, exactly as it reads in the PropertyMapping.xml file. For example:

WorkflowID=SAMPLE

With the above, the SQLSelectQuery.dll will find the WorkflowID in the Input dictionary and then check the PropertyMapping.xml for SAMPLE and find ConnectionString to be 1, SqlStatement to be 2, and ReturnValue to be 3.

NOTE: The ID you provide for the workflow is CASE SENSITIVE and can be any mixture of letters and numbers as seen in the second sample set. If the ID matches an ID in the PropertyMapping.xml file, then we get the property map for that workflow and use it to get our data from the Input dictionary. I have updated this version of the code to pass back an error to the batch when the WorkflowID is not found in the Input dictionary or does not match any values in the PropertyMapping.xml file.

LAST NOTE: This does not support multiple WorkflowIDs in a single Global(Action/Capture) workflow. This will always grab the FIRST WorkflowID that is found in the Input dictionary. If the WorkflowID exists multiple times in the PropertyMapping.xml file it will also always grab the FIRST occurrence of the property map.

VertexGeneral commented 7 years ago

I have updated the comparison between the WorkflowID value in the XML and that which was provided within the Input dictionary from the process field in the workflow. This update removed the case sensitive nature of the WorkflowID. Now WorkflowID=SAMPLE will match the XML even if the XML shows the WorkflowID as:

<WorkflowID>Sample</WorkflowID>

The lookup to get the WorkflowID from the Input dictionary is still case sensitive, so the process field will still need to be set to WorkflowID=xxxx where WorkflowID= is case sensitive and everything after the equals sign is no longer case sensitive.

propagated commented 7 years ago

Merging and bumping version.