Modified PM Specs to use AD Groups to send notifications
This commit is contained in:
@ -7,10 +7,16 @@ $Insert PM_EQUATES
|
||||
$Insert PM_SPEC_EQUATES
|
||||
$Insert TOOL_EQUATES
|
||||
|
||||
EQU COL$PMSKEY TO 1
|
||||
EQU COL$STATUS TO 2
|
||||
EQU COL$NOTIFICAITON TO 3
|
||||
EQU COL$DUEBY To 4
|
||||
EQU COL$CURRPMKEY To 5
|
||||
|
||||
Declare subroutine Database_Services, Error_Services, Set_Status, obj_PM_Spec, Tool_Services, Btree.Extract
|
||||
Declare subroutine Logging_Services, Pm_Services, RList, Obj_Notes, PM_Spec_Services
|
||||
Declare function Datetime, Database_Services, Error_Services, obj_PM_Spec, obj_Tool, Environment_Services
|
||||
Declare function Logging_Services, Pm_Services, NextKey, SRP_Datetime, Lsl_Users_Services
|
||||
Declare function Datetime, Database_Services, Error_Services, obj_PM_Spec, obj_Tool, Environment_Services, LCASE
|
||||
Declare function Logging_Services, Pm_Services, NextKey, SRP_Datetime, Lsl_Users_Services, Active_Directory_Services
|
||||
|
||||
LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\Tool'
|
||||
LogDate = Oconv(Date(), 'D4/')
|
||||
@ -584,8 +590,8 @@ Service ScheduleNextPM(PMSID, PMNo, StartQty)
|
||||
end
|
||||
|
||||
Case Units = 'M'
|
||||
//Month based PM
|
||||
SchedDt = SRP_Datetime('AddMonths', CurrDt, Interval)
|
||||
//Month based PM
|
||||
SchedDt = SRP_Datetime('AddMonths', CurrDt, Interval)
|
||||
CASE 1
|
||||
* Missing Units
|
||||
RETURN
|
||||
@ -605,19 +611,42 @@ Service ScheduleNextPM(PMSID, PMNo, StartQty)
|
||||
|
||||
end service
|
||||
|
||||
Service GetPMNotificationRecipients(PMSID)
|
||||
Recipients = ''
|
||||
If PMSID NE '' then
|
||||
If RowExists('PM_SPEC', PMSID) then
|
||||
Recipients := Lsl_Users_Services('GetOnShiftUsersByClass', 'Si Shift Supervisors', 0)
|
||||
Recipients := @VM : Lsl_Users_Services('GetOnShiftUsersByClass', 'Lead Operator', 0)
|
||||
ADNotificationGroups = XLATE('PM_SPEC', PMSID, PM_SPEC_AD_NOTIFICATION_GROUPS$, 'X')
|
||||
IF ADNotificationGroups NE '' then
|
||||
for each ADGroup in ADNotificationGroups using @VM
|
||||
GroupMemberList = Active_Directory_Services('GetADGroupMembers', ADGroup, 'INFINEON')
|
||||
for each GroupMember in GroupMemberList using @FM
|
||||
ADUsername = LCASE(GroupMember<1,1>)
|
||||
ADToLSLUserMap = Database_Services('ReadDataRow', 'APP_INFO', 'AD_TO_LSL_USER_MAP')
|
||||
ADToLSLUserMap<1> = LCASE(ADToLSLUserMap<1>)
|
||||
Locate ADUsername in ADToLSLUserMap<1> using @VM setting userPos then
|
||||
LSLUserID = ADToLSLUserMap<2, userPos>
|
||||
Recipients<1, -1> = LSLUserID
|
||||
end
|
||||
Next GroupMember
|
||||
Next ADGroup
|
||||
end
|
||||
end else
|
||||
Error_Services('Add', 'Error in GetPMNotificationRecipients: PM Spec record with key id ' : PMSID : 'does not exist.')
|
||||
end
|
||||
end else
|
||||
Error_Services('Add', 'Error in GetPMNotificationRecipients: PMSID was null')
|
||||
end
|
||||
Response = Recipients
|
||||
end service
|
||||
|
||||
Service SendPMNotifications()
|
||||
|
||||
hSysLists = Database_Services('GetTableHandle', 'SYSLISTS')
|
||||
Lock hSysLists, ServiceKeyID then
|
||||
EQU COL$PMSKEY TO 1
|
||||
EQU COL$STATUS TO 2
|
||||
EQU COL$NOTIFICAITON TO 3
|
||||
EQU COL$DUEBY To 4
|
||||
EQU COL$CURRPMKEY To 5
|
||||
PMStatuses = Pm_Services('GetPMStatuses')
|
||||
Recipients = Lsl_Users_Services('GetOnShiftUsersByClass', 'Si Shift Supervisors', 0)
|
||||
Recipients := @VM : Lsl_Users_Services('GetOnShiftUsersByClass', 'Lead Operator', 0)
|
||||
* Recipients = Lsl_Users_Services('GetOnShiftUsersByClass', 'Si Shift Supervisors', 0)
|
||||
* Recipients := @VM : Lsl_Users_Services('GetOnShiftUsersByClass', 'Lead Operator', 0)
|
||||
SentFrom = 'OI_ADMIN'
|
||||
AttachWindow = ''
|
||||
AttachKey = ''
|
||||
@ -630,7 +659,7 @@ Service SendPMNotifications()
|
||||
PMRec = Database_Services('ReadDataRow', 'PM', PMKey)
|
||||
PMSpecKey = PMStatusLine<1, COL$PMSKEY>
|
||||
PMSRec = Database_Services('ReadDataRow', 'PM_SPEC', PMSpecKey)
|
||||
//SendNotification = PMSRec<PM_SPEC_SEND_NOTIFICATION$>
|
||||
Tool = PMSRec<PM_SPEC_TOOL_ID$>
|
||||
SendEarlyNotification = PMSRec<PM_SPEC_SEND_EARLY_NOTIFICATION$>
|
||||
SendDueNotification = PMSRec<PM_SPEC_SEND_DUE_NOTIFICATION$>
|
||||
SendLateNotification = PMSRec<PM_SPEC_SEND_LATE_NOTIFICATION$>
|
||||
@ -638,8 +667,9 @@ Service SendPMNotifications()
|
||||
Begin Case
|
||||
Case Status EQ 'EARLY'
|
||||
IF SendEarlyNotification then
|
||||
Recipients = PM_Services('GetPMNotificationRecipients', PMSpecKey)
|
||||
Subject = 'PM Task Coming Due'
|
||||
Message = PMDesc:" is coming due. Scheduled due by " : OCONV(PMStatusLine<1,COL$DUEBY>, 'DT')
|
||||
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)
|
||||
PMRec<PM_EARLY_NOTIF_SENT$> = Datetime()
|
||||
@ -647,8 +677,9 @@ Service SendPMNotifications()
|
||||
end
|
||||
Case Status EQ 'DUE'
|
||||
If SendDueNotification then
|
||||
Recipients = PM_Services('GetPMNotificationRecipients', PMSpecKey)
|
||||
Subject = 'PM Task Due'
|
||||
Message = PMDesc:" is due. Scheduled due by " : OCONV(PMStatusLine<1,COL$DUEBY>, 'DT')
|
||||
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)
|
||||
PMRec<PM_DUE_NOTIF_SENT$> = Datetime()
|
||||
@ -656,8 +687,9 @@ Service SendPMNotifications()
|
||||
end
|
||||
Case Status EQ 'LATE'
|
||||
if SendLateNotification then
|
||||
Recipients = PM_Services('GetPMNotificationRecipients', PMSpecKey)
|
||||
Subject = 'PM overdue'
|
||||
Message = PMDesc:" is overdue. Scheduled due by " : OCONV(PMStatusLine<1,COL$DUEBY>, 'DT')
|
||||
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)
|
||||
PMRec<PM_LATE_NOTIF_SENT$> = Datetime()
|
||||
@ -671,6 +703,67 @@ Service SendPMNotifications()
|
||||
|
||||
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()
|
||||
|
||||
@ -697,13 +790,26 @@ Service GetPMStatuses()
|
||||
CurrDt = Date()
|
||||
CurrDtm = Datetime()
|
||||
PmsRec = Database_Services('ReadDataRow', 'PM_SPEC', PmsKey)
|
||||
CurrPMId = PmsRec<PM_SPEC_PM_KEYS$, 1>
|
||||
CurrPmRec = Database_Services('ReadDataRow', 'PM', CurrPMId)
|
||||
EarlyStart = ICONV(obj_PM_Spec('EarlyStart',PmsKey:@RM:PmsRec), 'DT')
|
||||
DueStart = ICONV(obj_PM_Spec('SchedStart',PmsKey:@RM:PmsRec), 'DT')
|
||||
LateStart = ICONV(obj_PM_Spec('LateStart',PmsKey:@RM:PmsRec), 'DT')
|
||||
Is5S = PmsRec<PM_SPEC_FIVE_S_FLAG$>
|
||||
Units = PmsRec<PM_SPEC_UNITS$>
|
||||
CurrPMId = PmsRec<PM_SPEC_PM_KEYS$, 1>
|
||||
CurrPmRec = Database_Services('ReadDataRow', 'PM', CurrPMId)
|
||||
Begin Case
|
||||
Case Units EQ 'T'
|
||||
EarlyStart = ICONV(obj_PM_Spec('EarlyStart',PmsKey:@RM:PmsRec), 'DT')
|
||||
DueStart = ICONV(obj_PM_Spec('SchedStart',PmsKey:@RM:PmsRec), 'DT')
|
||||
LateStart = ICONV(obj_PM_Spec('LateStart',PmsKey:@RM:PmsRec), 'DT')
|
||||
Case Units EQ 'D'
|
||||
EarlyStart = ICONV(obj_PM_Spec('EarlyStart',PmsKey:@RM:PmsRec), 'D')
|
||||
DueStart = ICONV(obj_PM_Spec('SchedStart',PmsKey:@RM:PmsRec), 'D')
|
||||
LateStart = ICONV(obj_PM_Spec('LateStart',PmsKey:@RM:PmsRec), 'D')
|
||||
Case 0
|
||||
EarlyStart = obj_PM_Spec('EarlyStart',PmsKey:@RM:PmsRec)
|
||||
DueStart = obj_PM_Spec('SchedStart',PmsKey:@RM:PmsRec)
|
||||
LateStart = obj_PM_Spec('LateStart',PmsKey:@RM:PmsRec)
|
||||
End Case
|
||||
|
||||
|
||||
SendEarly = false$
|
||||
SendDue = false$
|
||||
SendLate = false$
|
||||
@ -770,66 +876,67 @@ Service GetPMStatuses()
|
||||
end service
|
||||
|
||||
Service CompleteScrubberPM(ScrubberID)
|
||||
Option = ''
|
||||
Option = ''
|
||||
Flag = ''
|
||||
keylist = ''
|
||||
Query = ''
|
||||
Open 'DICT.PM_SPEC' to PmsDict then
|
||||
Query := 'TOOL_ID':@VM:ScrubberID:@FM
|
||||
Query := 'TOOL_ID':@VM:ScrubberID:@FM
|
||||
Btree.Extract(Query, 'PM_SPEC', PmsDict, keylist, '', Flag)
|
||||
end
|
||||
ScrubberPMSpecKeys = keylist
|
||||
If DCOUNT(ScrubberPMSpecKeys, @VM) GT 0 then
|
||||
for each PMSKey in keylist using @VM
|
||||
PMKeys = XLATE('PM_SPEC', PMSKey, 'PM_KEYS', 'X')
|
||||
If DCount(PMKeys, @VM GT 0) then
|
||||
for each PMKey in PMKeys using @VM
|
||||
Pm_Services('CompleteNonToolPM', PMKey, 'SYSTEM', DateTime())
|
||||
If Error_Services('HasError') then
|
||||
ErrMsg = Error_Services('GetMessage')
|
||||
Error_Services('Add', 'Error trying to complete Scrubber PM:' : ErrMsg)
|
||||
LogData = ''
|
||||
LogData<1> = OConv(Datetime(), 'DT2/^H')
|
||||
LogData<2> = ScrubberID
|
||||
LogData<3> = 'Error'
|
||||
LogData<4> = 'PM ' : PMKey : '. ' : ErrMsg
|
||||
Logging_Services('AppendLog', objLogScrubbers, LogData, @RM, @FM)
|
||||
end else
|
||||
LogData = ''
|
||||
LogData<1> = OConv(Datetime(), 'DT2/^H')
|
||||
LogData<2> = ScrubberID
|
||||
LogData<3> = 'Success'
|
||||
LogData<4> = 'PM ' : PMKey : ' Completed successfully'
|
||||
Logging_Services('AppendLog', objLogScrubbers, LogData, @RM, @FM)
|
||||
end
|
||||
Next PMKey
|
||||
end else
|
||||
ErrMsg = 'There were no scheduled PMs for ' : ScrubberID
|
||||
Error_Services('Add', ErrMsg)
|
||||
LogData = ''
|
||||
LogData<1> = OConv(Datetime(), 'DT2/^H')
|
||||
LogData<2> = ScrubberID
|
||||
LogData<3> = 'Error'
|
||||
LogData<4> = ErrMsg
|
||||
Logging_Services('AppendLog', objLogScrubbers, LogData, @RM, @FM)
|
||||
end
|
||||
Next PMSKey
|
||||
for each PMSKey in keylist using @VM
|
||||
PMKeys = XLATE('PM_SPEC', PMSKey, 'PM_KEYS', 'X')
|
||||
If DCount(PMKeys, @VM GT 0) then
|
||||
for each PMKey in PMKeys using @VM
|
||||
Pm_Services('CompleteNonToolPM', PMKey, 'SYSTEM', DateTime())
|
||||
If Error_Services('HasError') then
|
||||
ErrMsg = Error_Services('GetMessage')
|
||||
Error_Services('Add', 'Error trying to complete Scrubber PM:' : ErrMsg)
|
||||
LogData = ''
|
||||
LogData<1> = OConv(Datetime(), 'DT2/^H')
|
||||
LogData<2> = ScrubberID
|
||||
LogData<3> = 'Error'
|
||||
LogData<4> = 'PM ' : PMKey : '. ' : ErrMsg
|
||||
Logging_Services('AppendLog', objLogScrubbers, LogData, @RM, @FM)
|
||||
end else
|
||||
LogData = ''
|
||||
LogData<1> = OConv(Datetime(), 'DT2/^H')
|
||||
LogData<2> = ScrubberID
|
||||
LogData<3> = 'Success'
|
||||
LogData<4> = 'PM ' : PMKey : ' Completed successfully'
|
||||
Logging_Services('AppendLog', objLogScrubbers, LogData, @RM, @FM)
|
||||
end
|
||||
Next PMKey
|
||||
end else
|
||||
ErrMsg = 'There were no scheduled PMs for ' : ScrubberID
|
||||
Error_Services('Add', ErrMsg)
|
||||
LogData = ''
|
||||
LogData<1> = OConv(Datetime(), 'DT2/^H')
|
||||
LogData<2> = ScrubberID
|
||||
LogData<3> = 'Error'
|
||||
LogData<4> = ErrMsg
|
||||
Logging_Services('AppendLog', objLogScrubbers, LogData, @RM, @FM)
|
||||
end
|
||||
Next PMSKey
|
||||
end else
|
||||
ErrMsg = 'There were no defined PMs for ' : ScrubberID
|
||||
Error_Services('Add', ErrMsg)
|
||||
|
||||
Error_Services('Add', ErrMsg)
|
||||
LogData = ''
|
||||
LogData<1> = OConv(Datetime(), 'DT2/^H')
|
||||
LogData<2> = ScrubberID
|
||||
LogData<3> = 'Error'
|
||||
LogData<4> = ErrMsg
|
||||
Logging_Services('AppendLog', objLogScrubbers, LogData, @RM, @FM)
|
||||
ErrMsg = 'There were no defined PMs for ' : ScrubberID
|
||||
Error_Services('Add', ErrMsg)
|
||||
|
||||
Error_Services('Add', ErrMsg)
|
||||
LogData = ''
|
||||
LogData<1> = OConv(Datetime(), 'DT2/^H')
|
||||
LogData<2> = ScrubberID
|
||||
LogData<3> = 'Error'
|
||||
LogData<4> = ErrMsg
|
||||
Logging_Services('AppendLog', objLogScrubbers, LogData, @RM, @FM)
|
||||
end
|
||||
|
||||
|
||||
end service
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user