Modified PM Specs to use AD Groups to send notifications
This commit is contained in:
parent
c20f94a26f
commit
d637ac8067
File diff suppressed because it is too large
Load Diff
@ -27,7 +27,21 @@ $Insert SERVICE_SETUP
|
||||
$Insert APP_INSERTS
|
||||
$Insert REVDOTNETEQUATES
|
||||
|
||||
Declare subroutine Set_Property.Net
|
||||
Declare function Logging_Services, Environment_Services, Active_Directory_Services
|
||||
Declare subroutine Set_Property.Net, Logging_Services, Set_Status
|
||||
|
||||
LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\ActiveDirectory'
|
||||
LogDate = Oconv(Date(), 'D4/')
|
||||
LogTime = Oconv(Time(), 'MTS')
|
||||
LoggingDTM = LogDate : ' ' : LogTime ; // Logging DTM
|
||||
|
||||
LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : ' ActiveDirectoryAuthLog.csv'
|
||||
Headers = 'Logging DTM' : @FM : 'Username' : @FM : 'Authenticated'
|
||||
objADAuthLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, ',', Headers, '', False$, False$)
|
||||
|
||||
LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : ' ActiveDirectoryLog.csv'
|
||||
Headers = 'Logging DTM' : @FM : 'Operation' : @FM : 'Message'
|
||||
objADLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, ',', Headers, '', False$, False$)
|
||||
|
||||
GoToService
|
||||
|
||||
@ -58,13 +72,18 @@ Service AuthenticateUser(Username, Password, Domain)
|
||||
Free_Class.Net(objPC)
|
||||
end
|
||||
end
|
||||
Response = Authenticated
|
||||
LogData = ''
|
||||
LogData<1> = LoggingDTM
|
||||
LogData<2> = Username
|
||||
LogData<3> = Authenticated
|
||||
Logging_Services('AppendLog', objADAuthLog, LogData, @RM, @FM, False$)
|
||||
Response = Authenticated
|
||||
|
||||
end service
|
||||
|
||||
|
||||
Service GetADGroups(Username, Domain)
|
||||
|
||||
|
||||
ADGroups = ''
|
||||
DotNetHandle = StartDotNet("","4.0")
|
||||
DotNetDir = CheckDotNet('4.0'):'\'
|
||||
@ -96,7 +115,7 @@ Service GetADGroups(Username, Domain)
|
||||
CurrPrinName = Get_Property.Net(objCurrPrin, 'Name', 0)
|
||||
If CurrPrinName NE 'Domain Users' then ADGroups<-1> = CurrPrinName
|
||||
Free_Class.Net(objCurrPrin)
|
||||
end
|
||||
end
|
||||
end
|
||||
Repeat
|
||||
Free_Class.Net(objEnum)
|
||||
@ -118,25 +137,191 @@ End Service
|
||||
|
||||
|
||||
Service GetComputerDomain()
|
||||
|
||||
|
||||
Domain = ''
|
||||
DotNetHandle = StartDotNet("","4.0")
|
||||
DotNetDir = CheckDotNet('4.0'):'\'
|
||||
DirDllPath = DotNetDir:'System.DirectoryServices.dll'
|
||||
Set_Property.Net(DotNetHandle, "AssemblyName", DirDllPath)
|
||||
If Not(Get_Status(errCode)) then
|
||||
objDomain = Create_Class.Net(DotNetHandle, "System.DirectoryServices.ActiveDirectory.Domain", 0, '', '')
|
||||
If Not(Get_status(errCode)) then
|
||||
ObjCompDomain = Send_Message.Net(objDomain, 'GetComputerDomain', '', '', True$)
|
||||
If Not(Get_Status(errCode)) then
|
||||
Domain = Get_Property.Net(objCompDomAin, 'Name', False$)
|
||||
Free_class.Net(objCompDomain)
|
||||
end
|
||||
Free_Class.Net(objDomain)
|
||||
end
|
||||
objDomain = Create_Class.Net(DotNetHandle, "System.DirectoryServices.ActiveDirectory.Domain", 0, '', '')
|
||||
If Not(Get_status(errCode)) then
|
||||
ObjCompDomain = Send_Message.Net(objDomain, 'GetComputerDomain', '', '', True$)
|
||||
If Not(Get_Status(errCode)) then
|
||||
Domain = Get_Property.Net(objCompDomAin, 'Name', False$)
|
||||
Free_class.Net(objCompDomain)
|
||||
end
|
||||
Free_Class.Net(objDomain)
|
||||
end
|
||||
end
|
||||
Response = Domain
|
||||
|
||||
end service
|
||||
|
||||
Service GetADGroupMembers(GroupName, Domain)
|
||||
Set_Status(0)
|
||||
Users = ''
|
||||
ErrMessage = ''
|
||||
If GroupName NE '' AND Domain NE '' then
|
||||
|
||||
DotNetHandle = StartDotNet("","4.0")
|
||||
DotNetDir = CheckDotNet('4.0'):'\'
|
||||
AccountMgmtDllPath = DotNetDir:'System.DirectoryServices.AccountManagement.dll'
|
||||
Set_Property.Net(DotNetHandle, "AssemblyName", AccountMgmtDllPath)
|
||||
If Not(Get_Status(errCode)) then
|
||||
Params = 'Domain':@FM:Domain
|
||||
ParamTypes = 'System.DirectoryServices.AccountManagement.ContextType':@FM:'System.String'
|
||||
objPC = Create_Class.Net(DotNetHandle, "System.DirectoryServices.AccountManagement.PrincipalContext", 0, Params, ParamTypes)
|
||||
If Not(Get_Status(errCode)) then
|
||||
objGroupPrincipal = Create_Class.Net(DotNetHandle, "System.DirectoryServices.AccountManagement.GroupPrincipal", 0, objPC, 'RevDotNet');//forced an error here
|
||||
If Not(Get_Status(errCode)) then
|
||||
ThisGroup = Send_Message.Net(objGroupPrincipal, 'FindByIdentity', objPC:@FM:GroupName, 'RevDotNet':@FM:'System.String', 1)
|
||||
objPrinSearcher = Create_Class.Net(DotNetHandle, "System.DirectoryServices.AccountManagement.PrincipalSearcher", 0, objGroupPrincipal, 'RevDotNet')
|
||||
if Not(Get_Status(errCode)) then
|
||||
objPrinSearcher = Send_Message.Net(ThisGroup, 'GetMembers', '', '', 1)
|
||||
if Not(Get_Status(errCode)) then
|
||||
objEnum = Send_Message.Net(objPrinSearcher, 'GetEnumerator', '', '', 1)
|
||||
Loop
|
||||
Done = Send_Message.Net(objEnum, 'MoveNext', '', '', 0)
|
||||
Until Done EQ 'False' OR Done EQ ''
|
||||
If Not(Get_Status(errCode)) then
|
||||
ThisUser = Get_Property.Net(objEnum, 'Current', 1)
|
||||
If Not(Get_Status(errCode)) then
|
||||
Username = Get_Property.Net(ThisUser, 'Name', 0)
|
||||
UserADAttributes = Active_Directory_Services('GetADUserAttributes', Username, Domain)
|
||||
swap @FM with @VM in UserADAttributes
|
||||
users<-1> = UserADAttributes
|
||||
Free_Class.Net(username)
|
||||
end
|
||||
Free_Class.Net(ThisUser)
|
||||
end
|
||||
Repeat
|
||||
Free_Class.Net(objEnum)
|
||||
end else
|
||||
ErrMessage = 'Error applying searcher object for group.'
|
||||
end
|
||||
|
||||
end else
|
||||
ErrMessage = 'Error creating searcher object.'
|
||||
end
|
||||
Free_Class.Net(objPrinSearcher)
|
||||
end else
|
||||
ErrMessage = 'Error creating Group Principle object.'
|
||||
end
|
||||
end else
|
||||
ErrMessage = 'Error creating Principle Context object.'
|
||||
end
|
||||
Free_Class.Net(objGroupPrincipal)
|
||||
end else
|
||||
ErrMessage = 'Error creating dotnet object.'
|
||||
end
|
||||
Free_Class.Net(objPC)
|
||||
If ErrMessage EQ '' then
|
||||
LogData = ''
|
||||
LogData<1> = LoggingDTM
|
||||
LogData<2> = 'GetADGroupMembers'
|
||||
LogData<3> = 'Successfully retrieved members of AD group ' : GroupName : ' within the ' : Domain : ' domain.'
|
||||
Logging_Services('AppendLog', objADLog, LogData, @RM, @FM, False$)
|
||||
end else
|
||||
|
||||
LogData = ''
|
||||
LogData<1> = LoggingDTM
|
||||
LogData<2> = 'GetADGroupMembers'
|
||||
LogData<3> = 'Error getting members of AD group ' : GroupName : ' within the ' : Domain : ' domain. ' : ErrMessage
|
||||
Logging_Services('AppendLog', objADLog, LogData, @RM, @FM, False$)
|
||||
end
|
||||
end else
|
||||
LogData = ''
|
||||
LogData<1> = LoggingDTM
|
||||
LogData<2> = 'GetADGroupMembers'
|
||||
LogData<3> = 'Error getting members of AD group ' : GroupName : ' within the ' : Domain : ' domain. Either the group name or domain name was empty.'
|
||||
Logging_Services('AppendLog', objADLog, LogData, @RM, @FM, False$)
|
||||
end
|
||||
Response = Users
|
||||
end service
|
||||
|
||||
Service GetADUserAttributes(Username, Domain)
|
||||
Set_Status(0)
|
||||
ThisUser = ''
|
||||
ErrMessage = ''
|
||||
If Username NE '' AND Domain NE '' then
|
||||
DotNetHandle = StartDotNet("","4.0")
|
||||
DotNetDir = CheckDotNet('4.0'):'\'
|
||||
AccountMgmtDllPath = DotNetDir:'System.DirectoryServices.AccountManagement.dll'
|
||||
Set_Property.Net(DotNetHandle, "AssemblyName", AccountMgmtDllPath)
|
||||
If Not(Get_Status(errCode)) then
|
||||
Params = 'Domain':@FM:'Infineon'
|
||||
ParamTypes = 'System.DirectoryServices.AccountManagement.ContextType':@FM:'System.String'
|
||||
objPC = Create_Class.Net(DotNetHandle, "System.DirectoryServices.AccountManagement.PrincipalContext", 0, Params, ParamTypes)
|
||||
If Not(Get_Status(errCode)) then
|
||||
objUserPrincipal = Create_Class.Net(DotNetHandle, "System.DirectoryServices.AccountManagement.UserPrincipal", 0, objPC, 'RevDotNet')
|
||||
If Not(Get_Status(errCode)) then
|
||||
Set_Property.Net(objUserPrincipal, 'Name', Username)
|
||||
objPrinSearcher = Create_Class.Net(DotNetHandle, "System.DirectoryServices.AccountManagement.PrincipalSearcher", 0, objUserPrincipal, 'RevDotNet')
|
||||
If Not(Get_Status(errCode)) then
|
||||
objUserPrincipal = Send_Message.Net(objPrinSearcher, 'FindOne', '', '', 1)
|
||||
If Not(Get_Status(errCode)) then
|
||||
UserName = Get_Property.Net(objUserPrincipal, 'Name', 0)
|
||||
Email = Get_Property.Net(objUserPrincipal, 'EmailAddress', 0)
|
||||
DisplayName = Get_Property.Net(objUserPrincipal, 'DisplayName', 0)
|
||||
Sid = Get_Property.Net(objUserPrincipal, 'Sid', 0)
|
||||
SamAccountName = Get_Property.Net(objUserPrincipal, 'SamAccountName', 0)
|
||||
ThisUser<1> = UserName
|
||||
ThisUser<2> = DisplayName
|
||||
ThisUser<3> = Email
|
||||
end else
|
||||
//Error getting user object
|
||||
LogData = ''
|
||||
LogData<1> = LoggingDTM
|
||||
LogData<2> = 'GetADUserAttributes'
|
||||
LogData<3> = 'Error getting user attributes of user: ' : Username : ' within the ' : Domain : ' domain.'
|
||||
Logging_Services('AppendLog', objADLog, LogData, @RM, @FM, False$)
|
||||
end
|
||||
Free_class.Net(objPrinSearcher)
|
||||
end else
|
||||
//error creating principle searcher
|
||||
LogData = ''
|
||||
LogData<1> = LoggingDTM
|
||||
LogData<2> = 'GetADUserAttributes'
|
||||
LogData<3> = 'Error creating principle searcher. Username: ' : Username : ' within the ' : Domain : ' domain.'
|
||||
Logging_Services('AppendLog', objADLog, LogData, @RM, @FM, False$)
|
||||
end
|
||||
Free_Class.Net(objUserPrincipal)
|
||||
end else
|
||||
//error creating user principle object
|
||||
LogData = ''
|
||||
LogData<1> = LoggingDTM
|
||||
LogData<2> = 'GetADUserAttributes'
|
||||
LogData<3> = 'Error creating principle searcher. Username' : Username : 'within the ' : Domain : ' domain.'
|
||||
Logging_Services('AppendLog', objADLog, LogData, @RM, @FM, False$)
|
||||
end
|
||||
Free_Class.Net(objPC)
|
||||
end else
|
||||
//Error creating principle context
|
||||
LogData = ''
|
||||
LogData<1> = LoggingDTM
|
||||
LogData<2> = 'GetADUserAttributes'
|
||||
LogData<3> = 'Error creating principle context Username' : Username : 'within the ' : Domain : ' domain.'
|
||||
Logging_Services('AppendLog', objADLog, LogData, @RM, @FM, False$)
|
||||
end
|
||||
end else
|
||||
//error calling dotnet
|
||||
LogData = ''
|
||||
LogData<1> = LoggingDTM
|
||||
LogData<2> = 'GetADUserAttributes'
|
||||
LogData<3> = 'Error creating dotnet object. Username' : Username : 'within the ' : Domain : ' domain.'
|
||||
Logging_Services('AppendLog', objADLog, LogData, @RM, @FM, False$)
|
||||
end
|
||||
end else
|
||||
//Error, missing username or domain name
|
||||
LogData = ''
|
||||
LogData<1> = LoggingDTM
|
||||
LogData<2> = 'GetADUserAttributes'
|
||||
LogData<3> = 'Missing username or domain name'
|
||||
Logging_Services('AppendLog', objADLog, LogData, @RM, @FM, False$)
|
||||
end
|
||||
Response = ThisUser
|
||||
end service
|
||||
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -7,15 +7,18 @@ COMPILE FUNCTION PM_Spec(EntID,Event,Parm1,Parm2,Parm3,Parm4,Parm5)
|
||||
*/
|
||||
|
||||
DECLARE SUBROUTINE Set_Property, End_Dialog, Send_Event, Set_Status, obj_Tables, Post_Event
|
||||
DECLARE SUBROUTINE ErrMsg, Send_Message, Set_Property, Send_Event, Btree.Extract, obj_AppWindow
|
||||
DECLARE SUBROUTINE obj_Notes, Security_Err_Msg, End_Window, Forward_Event, Start_Window, Create_Note
|
||||
DECLARE SUBROUTINE ErrMsg, Send_Message, Set_Property, Send_Event, Btree.Extract, obj_AppWindow, Delete
|
||||
DECLARE SUBROUTINE obj_Notes, Security_Err_Msg, End_Window, Forward_Event, Start_Window, Create_Note, Database_Services
|
||||
|
||||
DECLARE FUNCTION Get_Property, Get_Status, Dialog_Box, Utility, obj_Popup, Popup
|
||||
DECLARE FUNCTION Send_Message, Msg, NextKey
|
||||
DECLARE FUNCTION Send_Message, Msg, NextKey, Database_Services, Msg, Error_Services
|
||||
|
||||
$INSERT MSG_EQUATES
|
||||
$INSERT APPCOLORS
|
||||
$INSERT PM_EQUATES
|
||||
$Insert PM_Spec_Equates
|
||||
|
||||
|
||||
|
||||
EQU CRLF$ TO \0D0A\
|
||||
EQU TAB$ TO \09\
|
||||
@ -46,6 +49,8 @@ BEGIN CASE
|
||||
CASE EntID = @WINDOW:'.LU_PMS_ID' AND Event = 'CLICK' ; GOSUB LUPMSId
|
||||
CASE EntID = @WINDOW:'.LU_TOOL_ID' AND Event = 'CLICK' ; GOSUB LUToolID
|
||||
CASE EntID = @WINDOW:'.LU_TIME_CD' AND Event = 'CLICK' ; GOSUB LUInterval
|
||||
Case EntID = @Window:'.PUB_ADD_NOTIFY_GROUP' AND Event = 'CLICK'; GoSub AddNotificationGroup
|
||||
Case EntID = @Window:'.PUB_DELETE_NOTIFY_GROUP'AND Event = 'CLICK'; GoSub DeleteNotificationGroup
|
||||
|
||||
CASE 1
|
||||
ErrorMsg = 'Unknown Parameters ':EntID:' - ':Event:' passed to commuter'
|
||||
@ -138,6 +143,10 @@ Refresh:
|
||||
END
|
||||
NEXT Line
|
||||
NEXT I
|
||||
ThisPMSpecRec = Database_Services('ReadDataRow', 'PM_SPEC', @ID, 1, 0, 0)
|
||||
ADNotificationGroups = ThisPMSpecRec<PM_SPEC_AD_NOTIFICATION_GROUPS$>
|
||||
Set_Property(@Window : '.EDT_NOTIFICATION_GROUPS', 'ARRAY', ADNotificationGroups)
|
||||
|
||||
|
||||
RETURN
|
||||
|
||||
@ -262,3 +271,60 @@ PMKeyDC:
|
||||
|
||||
RETURN
|
||||
|
||||
AddNotificationGroup:
|
||||
Def = ""
|
||||
Def<MTEXT$> = "Enter in an existing Distribution List Name:"
|
||||
Def<MTYPE$> = "RE"
|
||||
Def<MICON$> = "?"
|
||||
Group = Msg(@window, Def)
|
||||
|
||||
If Group NE '' then
|
||||
//Save any uncommited changes
|
||||
UpdatedRec = Get_Property (@Window, "ATRECORD")
|
||||
Locate Group in UpdatedRec<PM_SPEC_AD_NOTIFICATION_GROUPS$> using @VM setting gPos then
|
||||
Text = "Distribution list is already assigned."
|
||||
Msg(@window, Text)
|
||||
end else
|
||||
UpdatedRec<PM_SPEC_AD_NOTIFICATION_GROUPS$, -1> = Group
|
||||
Database_Services('WriteDataRow', 'PM_SPEC', @ID, UpdatedRec, 1, 0, 1)
|
||||
if Error_Services('NoError') then
|
||||
Set_Property (@Window, "ATRECORD", UpdatedRec)
|
||||
Set_Property(@Window, 'SAVEWARN', 0)
|
||||
Text = "Distribution list has been added."
|
||||
Msg(@window, Text)
|
||||
GoSub Refresh
|
||||
end else
|
||||
ErrMsg = Error_Services('GetMessage')
|
||||
Text = "Error while adding to PM Spec record. " : ErrMsg
|
||||
Msg(@window, Text)
|
||||
end
|
||||
end
|
||||
end
|
||||
return
|
||||
|
||||
DeleteNotificationGroup:
|
||||
PMSpecID = @ID
|
||||
NotifArray = Get_Property(@Window:'.EDT_NOTIFICATION_GROUPS', 'ARRAY')
|
||||
SelectedPos = Get_Property(@Window: '.EDT_NOTIFICATION_GROUPS', "SELPOS")<2>
|
||||
GroupToDelete = NotifArray<1,SelectedPos>
|
||||
If GroupToDelete NE '' then
|
||||
UpdatedRec = Get_Property (@Window, "ATRECORD")
|
||||
Locate GroupToDelete in UpdatedRec<PM_SPEC_AD_NOTIFICATION_GROUPS$> using @VM setting gPos then
|
||||
UpdatedRec = Delete(UpdatedRec, PM_SPEC_AD_NOTIFICATION_GROUPS$, gPos, 0)
|
||||
Database_Services('WriteDataRow', 'PM_SPEC', PMSpecID, UpdatedRec, 1, 0, 1)
|
||||
if Error_Services('NoError') then
|
||||
Set_Property (@Window, "ATRECORD", UpdatedRec)
|
||||
Set_Property(@Window, 'SAVEWARN', 0)
|
||||
Text = "Distribution list has been removed."
|
||||
Msg(@window, Text)
|
||||
GoSub Refresh
|
||||
end else
|
||||
ErrMsg = Error_Services('GetMessage')
|
||||
Text = "Error while deleting notification group PM Spec record. " : ErrMsg
|
||||
Msg(@window, Text)
|
||||
end
|
||||
end
|
||||
end
|
||||
return
|
||||
|
||||
|
||||
|
@ -34,6 +34,8 @@ Equ PM_SPEC_SEND_DUE_NOTIFICATION$ To 23
|
||||
Equ PM_SPEC_SEND_LATE_NOTIFICATION$ To 24
|
||||
Equ PM_SPEC_LAST_PM_COMP_DTM$ To 25
|
||||
Equ PM_SPEC_PM_CLASS$ To 26
|
||||
Equ PM_SPEC_AD_NOTIFICATION_GROUPS$ To 27
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user