As of release SWAT 19.15.1, we have added official support for custom session properties.
To do this, a custom Consultingwerk.OERA.Context.IContextDatasetFactory service will need to be implemented as below:
Next, a context wrapper class needs to be defined to provide access to the eTestSessionContext table fields.
For the SmartComponent Library session, the properties are available by accessing Consultingwerk.OERA.ContextWrapper.
For the SWAT session, the properties are available by accessing Akioma.Swat.OERA.Context.SwatContextWrapper.
A similar class should be implemented to provide strong-typed access to the custom session properties.
Both the SmartComponent Library and the SWAT context wrappers are separated into 2 different classes, the wrapper and the wrapper implementation (ex. Consultingwerk.OERA.ContextWrapper and Consultingwerk.OERA.ContextWrapperImpl), but this is not a requirement.
To simplify the implementation, we provide a base class for the implementation class: Akioma.Swat.OERA.Context.BaseContextWrapperImpl.
USING Progress.Lang.*. USING Akioma.Swat.OERA.Context.SwatContextWrapper FROM PROPATH. BLOCK-LEVEL ON ERROR UNDO, THROW. CLASS Akioma.Swat.OERA.Context.SwatContextWrapper: ?? DEFINE PUBLIC STATIC PROPERTY TestProperty1 AS CHARACTER NO-UNDO GET: RETURN SwatContextWrapper:GetContextWrapperImpl ():TestProperty1 . END GET . SET (arg AS CHARACTER): SwatContextWrapper:GetContextWrapperImpl ():TestProperty1 = arg . END . DEFINE PROTECTED STATIC VARIABLE oContextWrapperInstance AS Test.ITestContextWrapper NO-UNDO. DEFINE PUBLIC STATIC EVENT BeforeStoringContext SIGNATURE VOID (e AS Consultingwerk.EventArgs). DEFINE PUBLIC STATIC EVENT AfterRestoringContext SIGNATURE VOID (e AS Consultingwerk.EventArgs). CONSTRUCTOR STATIC SwatContextWrapper(): SwatContextWrapper:BeforeStoringContext:Subscribe(AssignFromSessionManager). SwatContextWrapper:AfterRestoringContext:Subscribe(AssignToSessionManager). END CONSTRUCTOR. METHOD PROTECTED STATIC Test.ITestContextWrapper GetContextWrapperImpl (): IF VALID-OBJECT (oContextWrapperInstance) THEN RETURN oContextWrapperInstance. oContextWrapperInstance = {Consultingwerk/get-service.i Test.ITestContextWrapper "NEW Test.TestContextWrapperImpl ()" } . RETURN oContextWrapperInstance . END METHOD. END CLASS.
??