Compile function OENGINE_HEARTBEAT(@Service, @Params)
#pragma precomp SRP_PreCompiler
declare function GetCommandLine
Declare function Database_Services, SRP_TcpClient, Environment_Services, SRP_Datetime
Declare subroutine SRP_TcpClient, Database_Services


$Insert LOGICAL
$insert SERVICE_SETUP




GoToService else
    null
end

Return Response else ''

Service Run()
    hSysLists = Database_Services('GetTableHandle', 'SYSLISTS')
    Lock hSysLists, ServiceKeyID then
        CommandLine = GetCommandLine()
        Server = Environment_Services('GetServer')
        Env = ''
        Begin Case
            Case Server EQ 'MESTSA01EC' or Server EQ 'MESSA01EC' or Server EQ 'MESTSA09EC' or Server EQ 'MESTSA010EC' or Server EQ 'MESTSA011EC' or Server EQ 'MESTSA012EC'
                Env = 'DB'
            Case Server EQ 'MESSA005' OR Server EQ 'MESSA012'
                Env = 'APP'
        End Case
        //test = Indexc(CommandLine, '/S=EN', 1)
        
        IF Indexc(CommandLine, '/S=EN', 1) then
            EngineTag = Indexc(CommandLine, '/S=EN', 1) + 3
            EngineNo = CommandLine[EngineTag, 999]
            EngineID = Env:'-':EngineNo
            CurrDTM = SRP_Datetime('Now')
            Database_Services('WriteDataRow', 'APP_INFO', EngineID, CurrDTM, True$, False$, True$)
        end
        ClearSelect 0
    end
    Unlock hSysLists, ServiceKeyID else Null
    
end service

