IFS ProCount Workflow Invoker
- 1 Introduction
- 1.1 Configuring the Service
- 1.1.1 Stop the Service
- 1.1.2 Edit the Config File
- 1.1.3 Configure the Queue Tables
- 1.2 Walkthrough
- 1.2.1 Stop the Service
- 1.2.2 Review the Sample Queue Table
- 1.2.3 Review the Sample Trigger
- 1.2.4 Test an Update Made in IFS ProCount
- 1.2.5 Start the Service
- 1.2.6 Monitor the Logs
- 1.1 Configuring the Service
Introduction
A new IFS ProCount service was created for the Ascend demo. This service is called Ascend.ProCount.Workflow.Invoker and monitors a table in the IFS ProCount database. It calls the workflow API end points for each entry in the queue table. To configure the process, configure the inputs through the settings in the application's config file, or modify the trigger and queue table.
Stop the ServiceThe service is listed in the services panel. While getting things set up, it is recommended that you stop the service and run the invoker manually until the process runs as you expect it to. Once working, you can then start the service and have it check the queue table in increments of seconds. | To stop and disable a Service in Windows:
|
Edit the Config FileSettings in this file control the calls to the workflow API along with the connection to the IFS ProCount database. | To edit the configuration file:
<add key="SecondsBetweenPolls" value="30"/> <add key="QueueTables" value="YourWorkflowQueueTb"/> <add key="WorkflowURL" value="http://URL/"/> <add key="AuthenticationPath" value="P2Demo/oauth2/token" /> <add key="CasePath" value="api/1.0/P2Demo/cases/impersonate"/> <add key="RoutePath" value="api/1.0/P2Demo/cases/{appUid}/route-case"/> <add key="ClientID" value="OBIQPBRYIUULZRPETBXIZMZYVXTWZFAO" /> <add key="ClientSecret" value="265187711598a502a8c9801057412853" /> <add key="UserName" value="AdminUser" /> <add key="Password" value="password" /> <add key="ProUID" value="12734012059ee6159991057027054023" /> <add key="UsrUID" value="8174230295988dd40f14f33060600180" /> <add key="TasUID" value="63639893459ee64b4569ed4072281864" /> <connectionStrings> <add name="ProCount" connectionString="Server=MyServer;Database=Procount;User ID=adminuser;Password=password;Provider=SQLOLEDB"/> </connectionStrings> |
Configure the Queue TablesWhen posting the case to the workflow API, the variables section of the post is derived from the columns of the queue table. | A queue table must have the first 3 columns:
The rest of the columns are optional and will be passed as variables to the case. SAMPLE TABLE The following table is a working example being used for the queue: CREATE TABLE [DemoWorkflowQueueTb]( [Id] [int] IDENTITY(1,1) NOT NULL, [UpdateTime] [datetime] NULL, [WorkflowInvoked] [int] NULL, [MerrickID] [int] NULL, [DateOfFirstProduction] [datetime] NULL, CONSTRAINT [PK_DemoWorkflowQueueTb] PRIMARY KEY CLUSTERED ( [Id] ASC )) GO ALTER TABLE [dbo].[DemoWorkflowQueueTb] ADD CONSTRAINT [DF_DemoWorkflowQueueTb_UpdateTime] DEFAULT (getdate()) FOR [UpdateTime] ALTER TABLE [dbo].[DemoWorkflowQueueTb] ADD CONSTRAINT [DF_DemoWorkflowQueueTb_WorkflowInvoked] DEFAULT ((0)) FOR [WorkflowInvoked] GO In the working example, the trigger inserts MerrickID and DateOfFirstProduction into the queue table. The invoker service examines the structure of the table and passes variables for any column other than Id, UpdateTime, and WorflowInvokde. CREATE OR ALTER TRIGGER DemoWorkflowFirstProduction ON CompletionTb AFTER UPDATE, INSERT AS BEGIN … Insert into DemoWorkflowQueueTb (MerrickID, DateOfFirstProduction) Values (@mid, @firstProduction) |
Stop the ServiceTo allow a methodical step-through of this process, it is recommended that the service is not running. To test the steps, you can run this service manually. At the end of this walkthrough the service will be turned back on so that the workflow is invoked automatically. | To stop and disable a Service in Windows:
|
Review the Sample Queue Table | In the preceding configuration steps, a table was created to hold a queue of records which will invoke the workflow API. In this walkthrough we will use an example table name of DemoWorkflowQueueTb. This table can be named anything as long as the invoker has the table name in its config settings file. The config file exists in a directory similar to the following: C:\AscendWorkflowInvoker\ P2.Ascend.Workflow.Demo.Service.exe.config on DDEMOPRO1 The table name must have an entry in this file similar to the following: <add key="QueueTables" value="DemoWorkflowQueueTb"/> |
Review the Sample TriggerIFS ProCount uses the following dates for:
This trigger figures out which of those dates occurs first and passes it to the DemoWorkflowQueueTb table. | The following code is for a trigger that populates the queue table: CREATE OR ALTER TRIGGER DemoWorkflowFirstProduction ON CompletionTb AFTER UPDATE, INSERT AS BEGIN SET NOCOUNT ON; Declare @mid int DECLARE @noDate datetime --instead of using nulls, P2 ProCount defaults to 1900 for no entry... if the date is > 1901 then it must be an actual entry. DECLARE @firstGas datetime DECLARE @firstOil datetime DECLARE @firstProduction datetime --will be set to the earlier of first gas or first oil set @noDate = '19000101' set @firstProduction = @noDate; Select @firstGas = DateOfInitialProductionGas, @firstOil = DateOfInitialProductionOil, @mid = MerrickID from INSERTED
IF EXISTS (SELECT * FROM DELETED) --if deleted exists, then it's an update BEGIN --if the user has updated one of the intitial production fields, figure out which is first, gas or oil and queue a workflow IF UPDATE (DateOfInitialProductionGas) OR UPDATE (DateOfInitialProductionOil) BEGIN set @firstProduction = @firstGas; IF ((@firstOil < @firstGas AND @firstOil > @noDate) OR @firstGas = @noDate) BEGIN set @firstProduction = @firstOil; END END END ELSE BEGIN --if the user has added a new completion with the initial production fields filled in, then insert a record in the queue BEGIN set @firstProduction = @firstGas; IF ((@firstOil < @firstGas AND @firstOil > @noDate) OR @firstGas = @noDate) BEGIN set @firstProduction = @firstOil; END END END IF (@firstProduction > @noDate) --if firstProduction was set above then insert a row in the queue table BEGIN Insert into DemoWorkflowQueueTb (MerrickID, DateOfFirstProduction) Values (@mid, @firstProduction) END END |
Test an Update Made in IFS ProCountTo manually test the Workflow Invoker service, you need to make an update and manually run the service. Then you can review the queue table to verify the updates. | To test an update:
If everything completes successfully, the queue table will be updated and WorkflowInvoked will be set to 1. You can query the queue table again to verify this. For example, in SQLQUery, type select * from DemoWorkflowQueueTb . |
Start the ServiceBefore starting the service again make sure you have tested and found no errors with the following tasks: The trigger is populating the correct table The populated data is correct If you encounter any issues while testing, remember that the settings the config file are what allows the invoker to send the data to the API. To troubleshoot issues, review the configuration file as described in the first section of this page. | The service does exactly what the TestInvoke.exe program does. The only difference is that the TestInvoke application only runs once. Before starting the service, you need to make sure that the configuration file has setting that you want to use in production. This may include adjusting the table name and setting how often the service checks, in seconds, for updates. Checking for updates is in the SecondsBetweenPolls setting. To edit the configuration file:
<add key="SecondsBetweenPolls" value="30"/> <add key="QueueTables" value="YourWorkflowQueueTb"/> <add key="WorkflowURL" value="http://URL/"/> <add key="AuthenticationPath" value="P2Demo/oauth2/token" /> <add key="CasePath" value="api/1.0/P2Demo/cases/impersonate"/> <add key="RoutePath" value="api/1.0/P2Demo/cases/{appUid}/route-case"/> <add key="ClientID" value="OBIQPBRYIUULZRPETBXIZMZYVXTWZFAO" /> <add key="ClientSecret" value="265187711598a502a8c9801057412853" /> <add key="UserName" value="AdminUser" /> <add key="Password" value="password" /> <add key="ProUID" value="12734012059ee6159991057027054023" /> <add key="UsrUID" value="8174230295988dd40f14f33060600180" /> <add key="TasUID" value="63639893459ee64b4569ed4072281864" /> <connectionStrings> <add name="ProCount" connectionString="Server=MyServer;Database=Procount;User ID=adminuser;Password=password;Provider=SQLOLEDB"/> </connectionStrings> To start and enable a Service in Windows:
|
Monitor the LogsUse the WorkflowDemo.log file to observe how the service is working and to watch for potential issues or errors. | To monitor service calls and watch for errors:
|
Copyright© 2024 IFS AB. Copying prohibited. All rights reserved.