Added in additional logic to keep repeated notifications from sending
This commit is contained in:
parent
2b6e5fd2ac
commit
91cb72c509
@ -32,6 +32,13 @@ LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : '
|
|||||||
Headers = 'Logging DTM' : @FM : 'ToolID' : @FM : 'Notes' : @FM : 'Message'
|
Headers = 'Logging DTM' : @FM : 'ToolID' : @FM : 'Notes' : @FM : 'Message'
|
||||||
objLogScrubbers = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, ',', Headers, '', False$, False$)
|
objLogScrubbers = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, ',', Headers, '', False$, False$)
|
||||||
|
|
||||||
|
LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\PM\Notifications'
|
||||||
|
LogDate = Oconv(Date(), 'D4/')
|
||||||
|
LogTime = Oconv(Time(), 'MTS')
|
||||||
|
LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : ' PM_Notifications.csv'
|
||||||
|
Headers = 'Logging DTM' : @FM : 'ToolID' : @FM : 'Message'
|
||||||
|
objLogNotifications = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, ',', Headers, '', False$, False$)
|
||||||
|
|
||||||
LoggingDTM = LogDate : ' ' : LogTime ; // Logging DTM
|
LoggingDTM = LogDate : ' ' : LogTime ; // Logging DTM
|
||||||
|
|
||||||
ChangeModes = Database_Services('ReadDataRow', 'APP_INFO', 'QUAL_CHANGE_MODES')
|
ChangeModes = Database_Services('ReadDataRow', 'APP_INFO', 'QUAL_CHANGE_MODES')
|
||||||
@ -644,18 +651,18 @@ end service
|
|||||||
Service SendPMNotifications()
|
Service SendPMNotifications()
|
||||||
hSysLists = Database_Services('GetTableHandle', 'SYSLISTS')
|
hSysLists = Database_Services('GetTableHandle', 'SYSLISTS')
|
||||||
Lock hSysLists, ServiceKeyID then
|
Lock hSysLists, ServiceKeyID then
|
||||||
PMStatuses = Pm_Services('GetPMStatuses')
|
errMessage = ''
|
||||||
* Recipients = Lsl_Users_Services('GetOnShiftUsersByClass', 'Si Shift Supervisors', 0)
|
PMStatuses = Pm_Services('GetPMStatuses')
|
||||||
* Recipients := @VM : Lsl_Users_Services('GetOnShiftUsersByClass', 'Lead Operator', 0)
|
SentFrom = 'OI_ADMIN'
|
||||||
SentFrom = 'OI_ADMIN'
|
AttachWindow = ''
|
||||||
AttachWindow = ''
|
AttachKey = ''
|
||||||
AttachKey = ''
|
SendToGroup = ''
|
||||||
SendToGroup = ''
|
|
||||||
for each PMStatusLine in PMStatuses using @FM
|
for each PMStatusLine in PMStatuses using @FM
|
||||||
Status = PMStatusLine<1,COL$STATUS>
|
Status = PMStatusLine<1,COL$STATUS>
|
||||||
LastNotification = PMStatusLine<1,COL$NOTIFICAITON>
|
LastNotification = PMStatusLine<1,COL$NOTIFICAITON>
|
||||||
PMDesc = XLATE('PM_SPEC', PMStatusLine<1,COL$PMSKEY>, PM_SPEC_DESC$, 'X')
|
PMDesc = XLATE('PM_SPEC', PMStatusLine<1,COL$PMSKEY>, PM_SPEC_DESC$, 'X')
|
||||||
PMKey = PMStatusLine<1,COL$CURRPMKEY>
|
PMKey = PMStatusLine<1,COL$CURRPMKEY>
|
||||||
|
|
||||||
PMRec = Database_Services('ReadDataRow', 'PM', PMKey)
|
PMRec = Database_Services('ReadDataRow', 'PM', PMKey)
|
||||||
PMSpecKey = PMStatusLine<1, COL$PMSKEY>
|
PMSpecKey = PMStatusLine<1, COL$PMSKEY>
|
||||||
PMSRec = Database_Services('ReadDataRow', 'PM_SPEC', PMSpecKey)
|
PMSRec = Database_Services('ReadDataRow', 'PM_SPEC', PMSpecKey)
|
||||||
@ -667,33 +674,120 @@ Service SendPMNotifications()
|
|||||||
Begin Case
|
Begin Case
|
||||||
Case Status EQ 'EARLY'
|
Case Status EQ 'EARLY'
|
||||||
IF SendEarlyNotification then
|
IF SendEarlyNotification then
|
||||||
Recipients = PM_Services('GetPMNotificationRecipients', PMSpecKey)
|
If PMRec<PM_EARLY_NOTIF_SENT$> EQ '' then
|
||||||
Subject = 'PM Task Coming Due'
|
PMRec<PM_EARLY_NOTIF_SENT$> = Datetime()
|
||||||
Message = 'Tool: ': Tool : ' - ' :PMDesc:" is coming due. Scheduled due by " : OCONV(PMStatusLine<1,COL$DUEBY>, 'DT')
|
Database_Services('WriteDataRow', 'PM', PMKey, PMRec, 1, 0, 1)
|
||||||
Parms = Recipients:@RM:SentFrom:@RM:Subject:@RM:Message:@RM:AttachWindow:@RM:AttachKey:@RM:SendToGroup
|
if Error_Services('NoError') then
|
||||||
obj_Notes('Create',Parms)
|
Recipients = PM_Services('GetPMNotificationRecipients', PMSpecKey)
|
||||||
PMRec<PM_EARLY_NOTIF_SENT$> = Datetime()
|
if Error_Services('NoError') then
|
||||||
Database_Services('WriteDataRow', 'PM', PMKey, PMRec, 1, 0, 1)
|
Subject = 'PM Task Coming Due'
|
||||||
|
Message = 'Tool: ': Tool : ' - ' :PMDesc:" is coming due. Scheduled due by " : OCONV(PMStatusLine<1,COL$DUEBY>, 'DT')
|
||||||
|
Parms = Recipients:@RM:SentFrom:@RM:Subject:@RM:Message:@RM:AttachWindow:@RM:AttachKey:@RM:SendToGroup
|
||||||
|
obj_Notes('Create',Parms)
|
||||||
|
end else
|
||||||
|
errMessage = Error_Services('GetMessage')
|
||||||
|
LogData = ''
|
||||||
|
LogData<1> = LoggingDTM;//Defined at entry of subroutine
|
||||||
|
LogData<2> = Tool
|
||||||
|
LogData<3> = PMDesc
|
||||||
|
LogData<4> = 'EARLY notification failed - ' : errMessage
|
||||||
|
Logging_Services('AppendLog', objLogNotifications, LogData, @RM, @FM, False$)
|
||||||
|
end
|
||||||
|
end else
|
||||||
|
errMessage = Error_Services('GetMessage')
|
||||||
|
LogData = ''
|
||||||
|
LogData<1> = LoggingDTM;//Defined at entry of subroutine
|
||||||
|
LogData<2> = Tool
|
||||||
|
LogData<3> = PMDesc
|
||||||
|
LogData<4> = 'EARLY notification failed - ' : errMessage
|
||||||
|
Logging_Services('AppendLog', objLogNotifications, LogData, @RM, @FM, False$)
|
||||||
|
end
|
||||||
|
end else
|
||||||
|
LogData = ''
|
||||||
|
LogData<1> = LoggingDTM;//Defined at entry of subroutine
|
||||||
|
LogData<2> = Tool
|
||||||
|
LogData<3> = PMDesc
|
||||||
|
LogData<4> = 'EARLY notification did not send because it has been marked as being already sent.'
|
||||||
|
Logging_Services('AppendLog', objLogNotifications, LogData, @RM, @FM, False$)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
Case Status EQ 'DUE'
|
Case Status EQ 'DUE'
|
||||||
If SendDueNotification then
|
If SendDueNotification then
|
||||||
Recipients = PM_Services('GetPMNotificationRecipients', PMSpecKey)
|
If PMRec<PM_DUE_NOTIF_SENT$> EQ '' then
|
||||||
Subject = 'PM Task Due'
|
PMRec<PM_DUE_NOTIF_SENT$> = Datetime()
|
||||||
Message = 'Tool: ': Tool : ' - ' :PMDesc:" is due. Scheduled due by " : OCONV(PMStatusLine<1,COL$DUEBY>, 'DT')
|
Database_Services('WriteDataRow', 'PM', PMKey, PMRec, 1, 0, 1)
|
||||||
Parms = Recipients:@RM:SentFrom:@RM:Subject:@RM:Message:@RM:AttachWindow:@RM:AttachKey:@RM:SendToGroup
|
if Error_Services('NoError') then
|
||||||
obj_Notes('Create',Parms)
|
Recipients = PM_Services('GetPMNotificationRecipients', PMSpecKey)
|
||||||
PMRec<PM_DUE_NOTIF_SENT$> = Datetime()
|
if Error_Services('NoError') then
|
||||||
Database_Services('WriteDataRow', 'PM', PMKey, PMRec, 1, 0, 1)
|
Subject = 'PM Task Due'
|
||||||
|
Message = 'Tool: ': Tool : ' - ' :PMDesc:" is due. Scheduled due by " : OCONV(PMStatusLine<1,COL$DUEBY>, 'DT')
|
||||||
|
Parms = Recipients:@RM:SentFrom:@RM:Subject:@RM:Message:@RM:AttachWindow:@RM:AttachKey:@RM:SendToGroup
|
||||||
|
obj_Notes('Create',Parms)
|
||||||
|
end else
|
||||||
|
errMessage = Error_Services('GetMessage')
|
||||||
|
LogData = ''
|
||||||
|
LogData<1> = LoggingDTM;//Defined at entry of subroutine
|
||||||
|
LogData<2> = Tool
|
||||||
|
LogData<3> = PMDesc
|
||||||
|
LogData<4> = 'DUE notification failed - ' : errMessage
|
||||||
|
Logging_Services('AppendLog', objLogNotifications, LogData, @RM, @FM, False$)
|
||||||
|
end
|
||||||
|
end else
|
||||||
|
errMessage = Error_Services('GetMessage')
|
||||||
|
LogData = ''
|
||||||
|
LogData<1> = LoggingDTM;//Defined at entry of subroutine
|
||||||
|
LogData<2> = Tool
|
||||||
|
LogData<3> = PMDesc
|
||||||
|
LogData<4> = 'DUE notification failed - ' : errMessage
|
||||||
|
Logging_Services('AppendLog', objLogNotifications, LogData, @RM, @FM, False$)
|
||||||
|
end
|
||||||
|
end else
|
||||||
|
LogData = ''
|
||||||
|
LogData<1> = LoggingDTM;//Defined at entry of subroutine
|
||||||
|
LogData<2> = Tool
|
||||||
|
LogData<3> = PMDesc
|
||||||
|
LogData<4> = 'DUE notification did not send because it has been marked as being already sent.'
|
||||||
|
Logging_Services('AppendLog', objLogNotifications, LogData, @RM, @FM, False$)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
Case Status EQ 'LATE'
|
Case Status EQ 'LATE'
|
||||||
if SendLateNotification then
|
if SendLateNotification then
|
||||||
Recipients = PM_Services('GetPMNotificationRecipients', PMSpecKey)
|
If PMRec<PM_LATE_NOTIF_SENT$> EQ '' then
|
||||||
Subject = 'PM overdue'
|
PMRec<PM_LATE_NOTIF_SENT$> = Datetime()
|
||||||
Message = 'Tool: ': Tool : ' - ' :PMDesc:" is overdue. Scheduled due by " : OCONV(PMStatusLine<1,COL$DUEBY>, 'DT')
|
Database_Services('WriteDataRow', 'PM', PMKey, PMRec, 1, 0, 1)
|
||||||
Parms = Recipients:@RM:SentFrom:@RM:Subject:@RM:Message:@RM:AttachWindow:@RM:AttachKey:@RM:SendToGroup
|
if Error_Services('NoError') then
|
||||||
obj_Notes('Create',Parms)
|
Recipients = PM_Services('GetPMNotificationRecipients', PMSpecKey)
|
||||||
PMRec<PM_LATE_NOTIF_SENT$> = Datetime()
|
if Error_Services('NoError') then
|
||||||
Database_Services('WriteDataRow', 'PM', PMKey, PMRec, 1, 0, 1)
|
Subject = 'PM overdue'
|
||||||
|
Message = 'Tool: ': Tool : ' - ' :PMDesc:" is overdue. Scheduled due by " : OCONV(PMStatusLine<1,COL$DUEBY>, 'DT')
|
||||||
|
Parms = Recipients:@RM:SentFrom:@RM:Subject:@RM:Message:@RM:AttachWindow:@RM:AttachKey:@RM:SendToGroup
|
||||||
|
obj_Notes('Create',Parms)
|
||||||
|
end else
|
||||||
|
errMessage = Error_Services('GetMessage')
|
||||||
|
LogData = ''
|
||||||
|
LogData<1> = LoggingDTM;//Defined at entry of subroutine
|
||||||
|
LogData<2> = Tool
|
||||||
|
LogData<3> = PMDesc
|
||||||
|
LogData<4> = 'LATE notification failed - ' : errMessage
|
||||||
|
Logging_Services('AppendLog', objLogNotifications, LogData, @RM, @FM, False$)
|
||||||
|
end
|
||||||
|
end else
|
||||||
|
errMessage = Error_Services('GetMessage')
|
||||||
|
LogData = ''
|
||||||
|
LogData<1> = LoggingDTM;//Defined at entry of subroutine
|
||||||
|
LogData<2> = Tool
|
||||||
|
LogData<3> = PMDesc
|
||||||
|
LogData<4> = 'LATE notification failed - ' : errMessage
|
||||||
|
Logging_Services('AppendLog', objLogNotifications, LogData, @RM, @FM, False$)
|
||||||
|
end
|
||||||
|
end else
|
||||||
|
LogData = ''
|
||||||
|
LogData<1> = LoggingDTM;//Defined at entry of subroutine
|
||||||
|
LogData<2> = Tool
|
||||||
|
LogData<3> = PMDesc
|
||||||
|
LogData<4> = 'LATE notification did not send because it has been marked as being already sent.'
|
||||||
|
Logging_Services('AppendLog', objLogNotifications, LogData, @RM, @FM, False$)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
End Case
|
End Case
|
||||||
end
|
end
|
||||||
@ -703,68 +797,6 @@ Service SendPMNotifications()
|
|||||||
|
|
||||||
end service
|
end service
|
||||||
|
|
||||||
* Service SendPMNotifications()
|
|
||||||
*
|
|
||||||
* hSysLists = Database_Services('GetTableHandle', 'SYSLISTS')
|
|
||||||
* Lock hSysLists, ServiceKeyID then
|
|
||||||
*
|
|
||||||
* PMStatuses = Pm_Services('GetPMStatuses')
|
|
||||||
* Recipients = Lsl_Users_Services('GetOnShiftUsersByClass', 'Si Shift Supervisors', 0)
|
|
||||||
* Recipients := @VM : Lsl_Users_Services('GetOnShiftUsersByClass', 'Lead Operator', 0)
|
|
||||||
* SentFrom = 'OI_ADMIN'
|
|
||||||
* AttachWindow = ''
|
|
||||||
* AttachKey = ''
|
|
||||||
* SendToGroup = ''
|
|
||||||
* for each PMStatusLine in PMStatuses using @FM
|
|
||||||
* Status = PMStatusLine<1,COL$STATUS>
|
|
||||||
* LastNotification = PMStatusLine<1,COL$NOTIFICAITON>
|
|
||||||
* PMDesc = XLATE('PM_SPEC', PMStatusLine<1,COL$PMSKEY>, PM_SPEC_DESC$, 'X')
|
|
||||||
* PMKey = PMStatusLine<1,COL$CURRPMKEY>
|
|
||||||
* PMRec = Database_Services('ReadDataRow', 'PM', PMKey)
|
|
||||||
* PMSpecKey = PMStatusLine<1, COL$PMSKEY>
|
|
||||||
* PMSRec = Database_Services('ReadDataRow', 'PM_SPEC', PMSpecKey)
|
|
||||||
* //SendNotification = PMSRec<PM_SPEC_SEND_NOTIFICATION$>
|
|
||||||
* SendEarlyNotification = PMSRec<PM_SPEC_SEND_EARLY_NOTIFICATION$>
|
|
||||||
* SendDueNotification = PMSRec<PM_SPEC_SEND_DUE_NOTIFICATION$>
|
|
||||||
* SendLateNotification = PMSRec<PM_SPEC_SEND_LATE_NOTIFICATION$>
|
|
||||||
* If LastNotification EQ '' then
|
|
||||||
* Begin Case
|
|
||||||
* Case Status EQ 'EARLY'
|
|
||||||
* IF SendEarlyNotification then
|
|
||||||
* Subject = 'PM Task Coming Due'
|
|
||||||
* Message = PMDesc:" is coming due. Scheduled due by " : OCONV(PMStatusLine<1,COL$DUEBY>, 'DT')
|
|
||||||
* Parms = Recipients:@RM:SentFrom:@RM:Subject:@RM:Message:@RM:AttachWindow:@RM:AttachKey:@RM:SendToGroup
|
|
||||||
* obj_Notes('Create',Parms)
|
|
||||||
* PMRec<PM_EARLY_NOTIF_SENT$> = Datetime()
|
|
||||||
* Database_Services('WriteDataRow', 'PM', PMKey, PMRec, 1, 0, 1)
|
|
||||||
* end
|
|
||||||
* Case Status EQ 'DUE'
|
|
||||||
* If SendDueNotification then
|
|
||||||
* Subject = 'PM Task Due'
|
|
||||||
* Message = PMDesc:" is due. Scheduled due by " : OCONV(PMStatusLine<1,COL$DUEBY>, 'DT')
|
|
||||||
* Parms = Recipients:@RM:SentFrom:@RM:Subject:@RM:Message:@RM:AttachWindow:@RM:AttachKey:@RM:SendToGroup
|
|
||||||
* obj_Notes('Create',Parms)
|
|
||||||
* PMRec<PM_DUE_NOTIF_SENT$> = Datetime()
|
|
||||||
* Database_Services('WriteDataRow', 'PM', PMKey, PMRec, 1, 0, 1)
|
|
||||||
* end
|
|
||||||
* Case Status EQ 'LATE'
|
|
||||||
* if SendLateNotification then
|
|
||||||
* Subject = 'PM overdue'
|
|
||||||
* Message = PMDesc:" is overdue. Scheduled due by " : OCONV(PMStatusLine<1,COL$DUEBY>, 'DT')
|
|
||||||
* Parms = Recipients:@RM:SentFrom:@RM:Subject:@RM:Message:@RM:AttachWindow:@RM:AttachKey:@RM:SendToGroup
|
|
||||||
* obj_Notes('Create',Parms)
|
|
||||||
* PMRec<PM_LATE_NOTIF_SENT$> = Datetime()
|
|
||||||
* Database_Services('WriteDataRow', 'PM', PMKey, PMRec, 1, 0, 1)
|
|
||||||
* end
|
|
||||||
* End Case
|
|
||||||
* end
|
|
||||||
* Next PMStatus
|
|
||||||
* Unlock hSysLists, ServiceKeyID else Null
|
|
||||||
* end
|
|
||||||
*
|
|
||||||
* end service
|
|
||||||
|
|
||||||
|
|
||||||
Service GetPMStatuses()
|
Service GetPMStatuses()
|
||||||
|
|
||||||
SendEarlyCnt = 0
|
SendEarlyCnt = 0
|
||||||
@ -934,3 +966,4 @@ Service CompleteScrubberPM(ScrubberID)
|
|||||||
end
|
end
|
||||||
|
|
||||||
end service
|
end service
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user