diff --git a/LSL2/STPROC/SERVICE_MANAGER_EVENTS.txt b/LSL2/STPROC/SERVICE_MANAGER_EVENTS.txt index da7dcba..9241002 100644 --- a/LSL2/STPROC/SERVICE_MANAGER_EVENTS.txt +++ b/LSL2/STPROC/SERVICE_MANAGER_EVENTS.txt @@ -108,7 +108,8 @@ Event WINDOW.TIMER() Procedures = ServiceDetail Arguments = ServiceDetail For Each Procedure in Procedures using @VM setting procPos - Command = 'RUN ' : Procedure + If Procedure[-9, 9] _EQC '_SERVICES' then Procedure[-9, 9] = '' + Command = 'RUN MCP ' : Quote(Procedure) Arguments = Arguments<0, procPos> If Arguments NE '' then For Each Argument in Arguments using ',' @@ -129,7 +130,7 @@ Event WINDOW.TIMER() If Not(Num(Modifier)) then Modifier = '' Argument = Date() + Modifier end - Command := ' ' : Quote(Argument) + Command := ', ' : Quote(Argument) Next Argument end Next Procedure diff --git a/LSL2/STPROC/SERVICE_SERVICES.txt b/LSL2/STPROC/SERVICE_SERVICES.txt index effcfdd..9187145 100644 --- a/LSL2/STPROC/SERVICE_SERVICES.txt +++ b/LSL2/STPROC/SERVICE_SERVICES.txt @@ -27,19 +27,29 @@ Function Service_Services(@Service, @Params) #pragma precomp SRP_PreCompiler -$insert LOGICAL +$insert APP_INSERTS $insert SERVICE_SETUP $insert SERVICES_EQUATES $insert RLIST_EQUATES $insert SQL_REQUESTS_EQUATES $Insert PROC_QUEUE_EQUATES +Equ Comma$ to ',' + Common /ServiceServices/ Unused1@, Unused2@, Unused3@, Unused4@, Unused5@, Unused6@, Unused7@, Unused8@, Unused9@, Unused10@ Declare function Service_Services, Memory_Services, SRP_List, SRP_FastArray, SRP_Array, Database_Services, Datetime -Declare Function GetTickCount, SRP_Decode, RTI_CREATEGUID +Declare function GetTickCount, SRP_Decode, RTI_CreateGuid, UCase, Environment_services, Logging_Services Declare subroutine Service_Services, Memory_Services, SRP_List, SRP_FastArray, RList, Set_Status, Database_Services -Declare Subroutine Yield, WinYield, Sleepery, Btree.Extract +Declare Subroutine Yield, WinYield, Sleepery, Btree.Extract, Logging_Services, obj_Notes + +LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\ProcQueue' +LogDate = Oconv(Date(), 'D4/') +LogTime = Oconv(Time(), 'MTS') +LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : ' Procedure Queue Log.csv' +Headers = 'Logging DTM' : @FM : 'Machine' : @FM : 'RequestKeyId' : @FM : 'Procedure' : @FM : 'Params' : @FM : 'Result' : @FM : 'Error Message' +objLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, Comma$, Headers, '', False$, False$) +LoggingDTM = LogDate : ' ' : LogTime ; // Logging DTM GoToService else Error_Services('Add', Service : ' is not a valid service request within the ' : ServiceModule : ' services module.') @@ -165,18 +175,21 @@ Service ProcessProcedureQueue() ReadNext RequestKeyID else EOF = True$ Until EOF or Done Lock hProcQueue, RequestKeyID then + Server = Environment_Services('GetServer') Done = True$ Database_Services('GetKeyIDLock', 'PROC_QUEUE', RequestKeyId) RequestRow = Database_Services('ReadDataRow', 'PROC_QUEUE', RequestKeyID) If RequestRow NE '' then Procedure = RequestRow + Procedure = UCase(Procedure) Params = RequestRow If Procedure NE '' then - Dim ProcParams(11) + Dim ProcParams(12) For each Param in Params using @VM setting pPos ProcParams(pPos) = Param Next Param NumArguments = DCount(Params, @VM) + Begin Case Case NumArguments EQ 0 ; Call @Procedure() Case NumArguments EQ 1 ; Call @Procedure(ProcParams(1)) @@ -194,17 +207,40 @@ Service ProcessProcedureQueue() Error_Services('Add', 'Error in ':Service:' service. More than 11 arguments are not currently supported.') End Case end - If Error_Services('NoError') then - Database_Services('DeleteDataRow', 'PROC_QUEUE', RequestKeyId, True$, False$) ; // This call will release the lock + + Swap @VM with ',' in Params + LogData = LoggingDTM + LogData<2> = Server + LogData<3> = RequestKeyId + LogData<4> = Procedure + LogData<5> = Params + ErrCode = '' + If ( Get_Status(ErrCode) or Error_Services('HasError') ) then + ErrorMessage = Error_Services('GetMessage') + Recipients = '' + SentFrom = 'SYSTEM' + Subject = 'Background Procedure Queue Error' + Message = OConv(Datetime(), 'DT2/^H') + Message<2> = 'Error on server ':Server + Message<3> = 'Stored Procedure: ':Procedure + StatCodes = 'Parameters: ':Params + Message<4> = 'Error_Services error message: ':ErrorMessage + Message<5> = 'Get_Status error code: ':ErrCode + Swap @FM with \0D0A\ in Message + AttachWindow = '' + AttachKey = '' + SendToGroup = 'OI_SYSADMIN' + Parms = Recipients:@RM:SentFrom:@RM:Subject:@RM:Message:@RM:AttachWindow:@RM:AttachKey:@RM:SendToGroup + obj_Notes('Create',Parms) + LogData<6> = 'Failed' + LogData<7> = 'Error_Services error message: ':ErrorMessage:' Get_Status error code: ':ErrCode end else - RequestRow = DateTime() - RequestRow = Error_Services('GetMessage') - Database_Services('WriteDataRow', 'PROC_QUEUE', RequestKeyID, RequestRow, True$, False$, False$) ; // This call will release the lock + LogData<6> = 'Success' end - end else - // Empty request, so delete it from the queue - Database_Services('DeleteDataRow', 'PROC_QUEUE', RequestKeyId, True$, False$) ; // This call will release the lock + Logging_Services('AppendLog', objLog, LogData, @RM, @FM) end + Database_Services('DeleteDataRow', 'PROC_QUEUE', RequestKeyId, True$, False$) ; // This call should release the lock + Unlock hProcQueue, RequestKeyID else Null end Repeat end @@ -258,4 +294,3 @@ return /// Internal GoSubs //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -