183 lines
8.6 KiB
Plaintext
183 lines
8.6 KiB
Plaintext
Compile function React_Mode_NG_Services(@Service, @Params)
|
|
/***********************************************************************************************************************
|
|
|
|
This program is proprietary and is not to be used by or disclosed to others, nor is it to be copied without written
|
|
permission from SRP Computer Solutions, Inc.
|
|
|
|
Name : React_Mode_NG_Services
|
|
|
|
Description : Handler program for all module related services.
|
|
|
|
Notes : The generic parameters should contain all the necessary information to process the services. Often
|
|
this will be information like the data Record and Key ID.
|
|
|
|
Parameters :
|
|
Service [in] -- Name of the service being requested
|
|
Param1-10 [in/out] -- Additional request parameter holders
|
|
Response [out] -- Response to be sent back to the Controller (MCP) or requesting procedure
|
|
|
|
Metadata :
|
|
|
|
History : (Date, Initials, Notes)
|
|
07/19/2022 djs Original programmer.
|
|
|
|
***********************************************************************************************************************/
|
|
|
|
#pragma precomp SRP_PreCompiler
|
|
|
|
$insert APP_INSERTS
|
|
$insert SERVICE_SETUP
|
|
$Insert REACT_MODE_NG_EQUATES
|
|
$insert RLIST_EQUATES
|
|
|
|
Declare function SRP_JSON, Database_Services, Reactor_Modes_Services, Get_Status
|
|
Declare subroutine SRP_JSON, Set_Status, RList, Errmsg
|
|
|
|
GoToService
|
|
|
|
Return Response or ""
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Services
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
Service ConvertRecordToJSON(ReactModeNGKey, ItemURL, CurrUser)
|
|
|
|
ErrorMsg = ''
|
|
JSON = ''
|
|
If ReactModeNGKey then
|
|
@Record = Database_Services('ReadDataRow', 'REACT_MODE_NG', ReactModeNGKey)
|
|
@Dict = Database_Services('GetTableHandle', 'DICT.REACT_MODE_NG')
|
|
@ID = ReactModeNGKey
|
|
If Error_Services('NoError') then
|
|
objJSON = ''
|
|
If SRP_JSON(objJSON, 'New', 'Object') then
|
|
// Create reactor mode object
|
|
objReactMode = ''
|
|
If SRP_JSON(objReactMode, 'New', 'Object') then
|
|
|
|
CurrMode = Xlate('REACT_MODE_NG', ReactModeNGKey, REACT_MODE_NG_MODE$, 'X')
|
|
ServiceDesc = Xlate('REACT_MODE_NG', ReactModeNGKey, REACT_MODE_NG_SERVICE_DESC$, 'X')
|
|
If (CurrUser NE '') then AvailModes = Reactor_Modes_Services('AvailableModes', CurrMode, CurrUser)
|
|
CurrRLKey = Xlate('REACT_MODE_NG', ReactModeNGKey, REACT_MODE_NG_START_RL_ID$ , 'X')
|
|
StartDTM = Field(Xlate('REACT_MODE_NG', ReactModeNGKey, REACT_MODE_NG_START_DTM$, 'X'),'*',2)
|
|
StartUser = Xlate('REACT_MODE_NG', ReactModeNGKey, REACT_MODE_NG_START_USER$, 'X')
|
|
StartNote = Xlate('REACT_MODE_NG', ReactModeNGKey, REACT_MODE_NG_START_NOTE$, 'X')
|
|
E10State = Xlate('REACTOR_MODES', CurrMode, 'E10_STATE', 'X')
|
|
StopDTM = Xlate('REACT_MODE_NG', ReactModeNGKey, REACT_MODE_NG_STOP_DTM$, 'X')
|
|
StopUser = Xlate('REACT_MODE_NG', ReactModeNGKey, REACT_MODE_NG_STOP_USER$, 'X')
|
|
StopNote = Xlate('REACT_MODE_NG', ReactModeNGKey, REACT_MODE_NG_STOP_NOTE$, 'X')
|
|
|
|
SRP_JSON(objReactMode, 'SetValue', 'reactModeKey', ReactModeNGKey, 'String')
|
|
SRP_JSON(objReactMode, 'SetValue', 'currMode', CurrMode, 'String')
|
|
SRP_JSON(objReactMode, 'SetValue', 'e10State', E10State, 'String')
|
|
SRP_JSON(objReactMode, 'SetValue', 'serviceDesc', ServiceDesc, 'String')
|
|
SRP_JSON(objReactMode, 'SetValue', 'reactLogKey', CurrRLKey, 'Number')
|
|
SRP_JSON(objReactMode, 'SetValue', 'startDate', OCONV(StartDTM, 'DT/^S'), 'DateTime')
|
|
SRP_JSON(objReactMode, 'SetValue', 'startUser', StartUser, 'String')
|
|
SRP_JSON(objReactMode, 'SetValue', 'startNote', StartNote, 'String')
|
|
SRP_JSON(objReactMode, 'SetValue', 'stopDTM', OCONV(StopDTM, 'DT/^S'), 'DateTime')
|
|
SRP_JSON(objReactMode, 'SetValue', 'stopUser', StopUser, 'String')
|
|
SRP_JSON(objReactMode, 'SetValue', 'stopNote', StopNote, 'String')
|
|
|
|
objModesArray = ''
|
|
If SRP_JSON(objModesArray, 'New', 'Array') then
|
|
If Assigned(AvailModes) then
|
|
For each AvailMode in AvailModes using @FM setting fPos
|
|
objMode = ''
|
|
If SRP_JSON(objMode, 'New', 'Object') then
|
|
SRP_JSON(objMode, 'SetValue', 'mode', AvailMode, 'String')
|
|
SubCats = Xlate('REACTOR_MODES', AvailMode, 'SERVICE_CATEGORIES', 'X')
|
|
SRP_JSON(objMode, 'SetValueArray', 'subCategories', SubCats, @VM)
|
|
SRP_JSON(objModesArray, 'Add', objMode)
|
|
SRP_JSON(objMode, 'Release')
|
|
end
|
|
Next AvailMode
|
|
// Add modes array object to reactor object
|
|
SRP_JSON(objReactMode, 'Set', 'availableModes', objModesArray)
|
|
SRP_JSON(objModesArray, 'Release')
|
|
end
|
|
end
|
|
|
|
If itemURL NE '' then
|
|
// The itemURL was passed in so add HAL+JSON properties.
|
|
// Create the _links property and then all link objects needed for this resource.
|
|
objLinks = ''
|
|
If SRP_JSON(objLinks, 'New', 'Object') then
|
|
// Create a self link.
|
|
objLink = ''
|
|
If SRP_JSON(objLink, 'New', 'Object') then
|
|
SRP_JSON(objLink, 'SetValue', 'href', ItemURL, 'String')
|
|
SRP_JSON(objLink, 'SetValue', 'title', 'Self', 'String')
|
|
SRP_JSON(objLinks, 'Set', 'self', objLink)
|
|
SRP_JSON(objLink, 'Release')
|
|
end
|
|
SRP_JSON(objReactMode, 'Set', '_links', objLinks)
|
|
SRP_JSON(objLinks, 'Release')
|
|
end
|
|
// Create the _class property for this resource.
|
|
SRP_JSON(objReactMode, 'SetValue', '_class', 'resource')
|
|
end
|
|
SRP_JSON(objJSON, 'Set', 'reactorMode', objReactMode)
|
|
SRP_JSON(objReactMode, 'Release')
|
|
end
|
|
JSON = SRP_JSON(objJSON, 'Stringify', 'Styled')
|
|
SRP_JSON(objJSON, 'Release')
|
|
end else
|
|
ErrorMsg = 'Error in ':Service:' service. Error creating JSON object.'
|
|
end
|
|
end else
|
|
ErrorMsg = Error_Services('GetMessage')
|
|
end
|
|
end else
|
|
ErrorMsg = 'Error in ':Service:' service. Null ReactModeNGKey passed in.'
|
|
end
|
|
If ErrorMsg EQ '' then
|
|
Response = JSON
|
|
end else
|
|
Error_Services('Add', ErrorMsg)
|
|
end
|
|
|
|
End Service
|
|
|
|
|
|
Service GetReactModeHistoryKeys(ReactNo, DaysToReport)
|
|
|
|
StartDt = OCONV(Date() - DaysToReport, 'D4/')
|
|
Response = ''
|
|
SelectSent = 'SELECT REACT_MODE_NG WITH REACT_NO = ':QUOTE(ReactNo):' AND WITH START_DT GE ':QUOTE(StartDt):' BY-DSND START_DTM '
|
|
Set_Status(0)
|
|
RList(SelectSent, TARGET_ACTIVELIST$, "", "", "")
|
|
errCode = ''
|
|
IF Get_Status(errCode) THEN
|
|
ErrMsg(errCode)
|
|
RETURN
|
|
END
|
|
IF @RecCount then
|
|
EoF = 0
|
|
NumKeys = @RecCount
|
|
Cnt = 0
|
|
|
|
Loop
|
|
ReadNext Mode Else EoF = 1
|
|
until EoF
|
|
Response<-1> = Mode
|
|
Repeat
|
|
end
|
|
|
|
end service
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Internal GoSubs
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
ClearCursors:
|
|
|
|
For counter = 0 to 8
|
|
ClearSelect counter
|
|
Next counter
|
|
|
|
return
|
|
|