Compile function Override_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        :   Override_Services

    Description :   Handler program getting and setting overrides.

    Notes       :   

    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)
        02/10/22    djs     Original programmer.

***********************************************************************************************************************/
#pragma precomp SRP_PreCompiler

$Insert SERVICE_SETUP
$Insert LOGICAL
$Insert OVERRIDE_EQUATES

Declare function   Datetime, Database_Services, Error_Services
Declare subroutine Database_Services, Error_Services

GoToService

Return Response or ""

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Service Parameter Options
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Options OVERRIDE_TYPES     = 'UNLOAD_DTM'

//-----------------------------------------------------------------------------
// SERVICES
//-----------------------------------------------------------------------------

Service SetOverride(Table, Key, OverrideType=OVERRIDE_TYPES, OverrideUser)
    
    ErrorMsg = ''
    If ( (Table NE '') and (Key NE '') and (OverrideType NE '') and (OverrideUser NE '') ) then
        OverrideRec                          = ''
        OverrideRec<OVERRIDE.OVERRIDE_USER$> = OverrideUser
        OverrideRec<OVERRIDE.OVERRIDE_DTM$>  = Datetime()
        OverrideKey                          = Table:'*':Key:'*':OverrideType
        Database_Services('WriteDataRow', 'OVERRIDE', OverrideKey, OverrideRec)
    end else
        ErrorMsg = 'Error in ':Service:' service. One or more null parameters passed in!'
    end
    
    If ErrorMsg EQ '' then
        Response = True$
    end else
        Response = False$
        Error_Services('Add', ErrorMsg)
    end
    
End Service


Service GetOverride(Table, Key, OverrideType=OVERRIDE_TYPES)

    ErrorMsg = ''
    If ( (Table NE '') and (Key NE '') and (OverrideType NE '') ) then
        OverrideKey                          = Table:'*':Key:'*':OverrideType
        If (RowExists('OVERRIDE', OverrideKey) EQ False$) then
            // Override not set
            ErrorMsg = 'Error in ':Service:' service. Override not found!'
        end
    end else
        ErrorMsg = 'Error in ':Service:' service. One or more null parameters passed in!'
    end
    
    If ErrorMsg EQ '' then
        Response = True$
    end else
        Response = False$
        Error_Services('Add', ErrorMsg)
    end
    
End Service
