Merged PR 15380: Added logging for when a network error is encountered

Added logging for when a network error is encountered
This commit is contained in:
Ouellette Jonathan (CSC FI SPS MESLEO) 2025-04-21 21:10:54 +02:00
parent 8a44de0075
commit e0b3557068

View File

@ -34,6 +34,15 @@ Declare subroutine Shipment_Services, OBJ_Notes
Equ CRLF$ to \0D0A\ Equ CRLF$ to \0D0A\
LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\COC_Availability'
LogDate = Oconv(Date(), 'D4/')
LogTime = Oconv(Time(), 'MTS')
LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : '_NETWORK.log'
Headers = 'Logging DTM' : @FM : 'Message'
ColumnWidths = 30 : @FM : 300
objLogNetwork = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, ' ', Headers, ColumnWidths, False$, False$)
LoggingDTM = LogDate : ' ' : LogTime ; // Logging DTM
GoToService GoToService
Return Response or "" Return Response or ""
@ -165,7 +174,11 @@ Service CheckFileAvailability(StartDate, EndDate)
end end
// Code to run COC SELECT and change MONA Status // Code to run COC SELECT and change MONA Status
If NetworkError EQ False$ then If NetworkError EQ False$ then
//Log that there were no network errors detected.
NetworkLogMessage = 'No network errors detected.'
GoSub LogNetworkStatus
Shipment_Services('ClearMONACritical', 'FTP_SERVER_REACHABLE') Shipment_Services('ClearMONACritical', 'FTP_SERVER_REACHABLE')
EarliestDate = Shipment_Services('GetEarliestDate') EarliestDate = Shipment_Services('GetEarliestDate')
EarliestDate = OConv(EarliestDate, 'D4-') EarliestDate = OConv(EarliestDate, 'D4-')
SelectQuery = 'SELECT COC BY ENTRY_DATE WITH ENTRY_DATE GE ' : Quote(EarliestDate) : ' AND WITH FTP_SHOULD_EXIST EQ 1 AND WITH FTP_EXISTS EQ 0' SelectQuery = 'SELECT COC BY ENTRY_DATE WITH ENTRY_DATE GE ' : Quote(EarliestDate) : ' AND WITH FTP_SHOULD_EXIST EQ 1 AND WITH FTP_EXISTS EQ 0'
@ -185,6 +198,12 @@ Service CheckFileAvailability(StartDate, EndDate)
Shipment_Services('ClearMONACritical', 'FILE_AVAILABILITY') Shipment_Services('ClearMONACritical', 'FILE_AVAILABILITY')
end end
end else end else
//Log that there were network errors detected.
If Assigned(ErrTest) then
NetworkLogMessage = ErrTest
swap CRLF$ with ' , ' in NetworkLogMessage
GoSub LogNetworkStatus
end
Shipment_Services('SetMONAWarning', 'FTP_SERVER_REACHABLE') Shipment_Services('SetMONAWarning', 'FTP_SERVER_REACHABLE')
Error_Services('Add', Service : 'service failed. ''An issue connecting to the FTP server has occured.') Error_Services('Add', Service : 'service failed. ''An issue connecting to the FTP server has occured.')
end end
@ -339,6 +358,33 @@ InitCocLog:
return return
InitNetworkLog:
LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\COC_Availability'
LogDate = Oconv(Date(), 'D4/')
LogTime = Oconv(Time(), 'MTS')
LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : '_NETWORK.log'
Headers = 'Logging DTM' : @FM : 'Message'
ColumnWidths = 30 : @FM : 300
objLogNetwork = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, ' ', Headers, ColumnWidths, False$, False$)
LoggingDTM = LogDate : ' ' : LogTime ; // Logging DTM
return
LogNetworkStatus:
If Assigned(NetworkLogMessage) then
ErrorLogMessage = NetworkLogMessage
end else
ErrorLogMessage = 'Unspecified network error'
end
GoSub InitNetworkLog
LogData = ''
LogData<1> = LoggingDTM
LogData<2> = ErrorLogMessage
Logging_Services('AppendLog', objLogNetwork, LogData, @RM, @FM)
return
LogMissingFile: LogMissingFile:
@ -400,3 +446,4 @@ CompanyExceptionCheck:
return return