Skip to content

2.2 Actions

Mike van Mourik edited this page Jul 24, 2024 · 3 revisions

Introduction

Within the Wiser Task Scheduler actions are defined to execute specific tasks. Each specific action is based on the information described on this page.

For developers: The actions are loaded into the specific action classes, e.g. QueryModel. Each of these classes inherits from ActionModel and is used within the ConfigurationsService to be executed.

Properties

Property name Mandatory Default value Explanation
TimeId yes 0 The ID of the run scheme within is action is to be performed.
Order yes 0 A number that determines the order in which the actions are executed.
Currently this vlaue needs to be unique within a runscheme.
ResultSetName no null The name the results of this action can be used within other actions in the same run scheme.
See 2.3 Result sets for more information.
UseResultSet no null The name of the result set of a previous action in the same run scheme to use.
See 2.3 Result sets for more information.
HashAlgorithm no SHA256 The hashing algorithm that needs to be used if a replacement needs to be hashed.
See 2.6 Hashing for more information.
HashRepresentation no Base64 The format in which the hashed value will be written.
See 2.6 Hashing for more information.
OnlyWithStatusCode no null Only execute the action if given result set has the expected StatusCode. Format: ResultSetName,StatusCode, e.g. MyApiCall,200. (Only works with the HttpApi result set)
OnlyWithSuccessState no null Only execute the action if the given result set had the expected success state. Format: ResultSetName,Status, e.g. MyImport,True. (Only works with the ImportFile and GenerateFile result sets.)
OnlyWithValue no null Only execute the action if the given result set had the expected value. Format: ResultSetName.key?0,1, e.g. SupportResult.Results[0].IsLastDay?0,1.
LogSettings no LogSettings from the run scheme The settings to use for logging. When no are provided these will be copied from the run scheme this action is within.
See 2.5 Log settings for more information.

Examples

Single action

Action performed within the run scheme with time ID 1.

<Query>
  <TimeId>1</TimeId>
  <Order>1</Order>
  <Query><![CDATA[SELECT 1 AS ValueOne]]></Query>
</Query>

Multiple actions within the same run scheme

Two actions of the same type executed sequentially within the run scheme with time ID 1.

<Query>
  <TimeId>1</TimeId>
  <Order>1</Order>
  <Query><![CDATA[SELECT 1 AS ValueOne]]></Query>
</Query>

<Query>
  <TimeId>1</TimeId>
  <Order>2</Order>
  <Query><![CDATA[SELECT 2 AS ValueTwo]]></Query>
</Query>

Multiple actions within different run schemes

Two actions of the same type executed in different run schemes.

<Query>
  <TimeId>1</TimeId>
  <Order>1</Order>
  <Query><![CDATA[SELECT 1 AS ValueOne]]></Query>
</Query>

<Query>
  <TimeId>2</TimeId>
  <Order>1</Order>
  <Query><![CDATA[SELECT 2 AS ValueTwo]]></Query>
</Query>

Multiple actions with result set

Two actions of different types executed sequentially within the run scheme with time ID 1. Action 1 stored the results in a result set. Action 2 uses the result set of action 1.

<Query>
  <TimeId>1</TimeId>
  <Order>1</Order>
  <ResultSetName>MyResult</ResultSetName>
  <Query><![CDATA[SELECT 1 AS ValueOne]]></Query>
</Query>

<HttpApi>
  <TimeId>1</TimeId>
  <Order>2</Order>
  <UseResultSet>MyResult</UseResultSet>
  <Url>https://test.test/api/number/[{Results[i].ValueOne}]</Url>
  <Method>Get</Method>
  <SingleRequest>false</SingleRequest>
</HttpApi>

Multiple actions with conditional HTTP StatusCode

Three actions of different types executed sequentially within the run scheme with time ID 1. Action 1 stores the results in a result set. Action 2 uses the results of action 1 and stored its own results in a new result set. Action 3 is executed only if on the request of action 2 return a status code 200.

<Query>
  <TimeId>1</TimeId>
  <Order>1</Order>
  <ResultSetName>MyResult</ResultSetName>
  <Query><![CDATA[SELECT 1 AS ValueOne]]></Query>
</Query>

<HttpApi>
  <TimeId>1</TimeId>
  <Order>2</Order>
  <ResultSetName>MyApiCall</ResultSetName>
  <UseResultSet>MyResult</UseResultSet>
  <Url>https://test.test/api/number/[{Results[0].ValueOne}]</Url>
  <Method>Get</Method>
</HttpApi>

<Query>
  <TimeId>1</TimeId>
  <Order>3</Order>
  <OnlyWithStatusCode>MyApiCall,200</OnlyWithStatusCode>
  <Query><![CDATA[INSERT INTO _wts_tests (information) VALUES('Success')]]></Query>
</Query>

Multiple actions with conditional success status

Thee actions executed sequentially where action 2 and 3 depend on the success status of action 1.

Action 1 imports a file. Action 2 writes the information to the database if the import was successful. Action 3 writes a notifcation to the database if the import failed.

<ImportFile>
  <TimeId>1</TimeId>
  <Order>1</Order>
  <ResultSetName>ImportWithFields</ResultSetName>
  <FilePath>C:\Temp\Import\file1.csv</FilePath>
</ImportFile>

<Query>
  <TimeId>1</TimeId>
  <Order>2</Order>
  <UseResultSet>ImportWithFields.Results</UseResultSet>
  <OnlyWithSuccessState>ImportWithFields,True</OnlyWithSuccessState>
  <Query>
    <![CDATA[
       INSERT INTO _wts_tests (information)
       VALUES (CONCAT([{Id}], ', ', [{Name}], ', ', [{Role}]))
      ]]>
  </Query>
</Query>

<Query>
  <TimeId>1</TimeId>
  <Order>3</Order>
  <OnlyWithSuccessState>ImportWithFields,False</OnlyWithSuccessState>
  <Query>
    <![CDATA[
       INSERT INTO _wts_tests (information)
       VALUES ('Can't add infomation to database because import failed.')
      ]]>
  </Query>
</Query>

Custom logging

The actions has its own log settings that is used instead of the log settings of the run scheme with time ID 1.

<Query>
  <TimeId>1</TimeId>
  <Order>1</Order>

  <LogSettings>
  </LogSettings>

  <Query><![CDATA[SELECT 1 AS ValueOne]]></Query>
</Query>