GSD-EventLoop Information
Module GSD-EventLoop is used to queue, mostly more demanding things, so they can be executed by the GSD Verarbeitungs-Server asynchronously.
It works in the way when the operation is being initialized, it creates* a cache object, some sort of container that holds data about that operation. Then data exchange macro (Datenaustauschmakro) looks for the containers with status In use (new operation that hasn't been executed yet) or Error (an error occurred and the operation needs to be repeated). Then it calls event macro (Ereignismakro) that is assigned to that container with all the data that this container holds.
*These objects are not necessarily created. To limit the number of these objects they are not deleted in the process and they are reusable. When new operation is being initialized, it actually looks for free container and uses it, unless there is none, then new container is being created.
There are five possible statuses of these containers:
- 0 - For use - should be set after using it and the operation was successful, it means it's free and can be used again
- 1 - In use - set after initialization, pending to be operated
- 2 - Waiting - excluded from use, needs to be handled manually
- 3 - Error - set when the error occurred and the operation needs to be repeated
- 4 - Error no retry - set when the error occurred but it needs to be handled manually
Usage
In order to use the module for one's purpose, two macros are needed to be implemented. One macro that will initialize the operation and second that will perform it.
Initialization macro
This macro is meant to gather data and initialize the container. It can be done with a usage of macro xEL_CreateEventFromEx.
Executive macro
This macro needs to be an event macro (Ereignismakro) with the specified declaration:
1 2 | INT xEventLoop_EventMacro( STRING input1, STRING input2, STRING input3, DBSTRINGSET &additionalData, STRING &output, INT &endStatus ) RETURN( 0 ) |
With such composition of input parameters of this macro it allows to pass here everything that might be needed. Output string can be used for example for returning potential error messages. While the end status determine what would happen with that container after this macro is complete.
Example
1 2 3 4 5 6 7 8 9 10 | VOID AddIncidentEntry( HDIALOG dialog, Vorgang incident, Vorgangseintrag entry ) IF( incident.LockRefresh() ) incident.Eintraege.Add( entry ); incident.StoreUnlock(); ENDIF xEL_CreateEventFromEx( "xEventLoop_UpdateProject", "", incident.GetOID(), incident.StoreTime.ISOFormatDateTime(), "" ); RETURN() |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | INT xEventLoop_UpdateProject( STRING incidentOid, STRING newTime, STRING input3, DBSTRINGSET &additionalData, STRING &output, INT &endStatus ) BOOL ret; Vorgang incident; Projekt prj; ProjektSet prjSet; ProjektAllSet prjAllSet; IF( incident.FromOID( incidentOid ) ) prjAllSet.Query( "query Dokumentordner.Documents == " + incidentOid.ToQS() + ";", prjSet ); IF( prjSet.GetCount() == 1 ) prj = prjSet[ 1 ]; IF( !prj.IsEmpty() ) IF( prj.LockRefresh() ) prj.SetTime( "LastUpdateDate", newTime.ToTime() ); ret = prj.StoreUnlock(); ELSE prj.GetLockInfosEx( FLAT, TRUE, output ); ENDIF ENDIF ENDIF IF( ret ) endStatus = 0; ELSE endStatus = 3; ENDIF ENDIF RETURN( 0 ) |