added AD group support to notifications system

This commit is contained in:
Infineon\StieberD
2024-10-04 17:35:08 -07:00
parent 0b5ce72c39
commit 2a5abee93e
38 changed files with 9811 additions and 2732 deletions

View File

@ -25,6 +25,7 @@ $insert LOGICAL
$insert SERVICE_SETUP
$Insert LSL_USERS_EQU
$Insert RLIST_EQUATES
$Insert NOTIFICATION_EQUATES
equ crlf$ to \0D0A\
equ tab$ to char(09)
@ -40,11 +41,17 @@ EQU FRIDAY$ to 5
EQU SATURDAY$ to 6
EQU SUNDAY$ to 7
Declare Function Get.RecCount, SRP_Datetime, Datetime, SRP_MATH, Lsl_Users_Services
Declare Function DCount
Declare Function Database_Services,
Declare Function Environment_Services
Declare subroutine Btree.Extract
Declare Function Get.RecCount, SRP_Datetime, Datetime, SRP_MATH, Lsl_Users_Services, Active_Directory_Services
Declare Function DCount, Database_Services, Environment_Services, SRP_Array, Logging_Services
Declare subroutine Btree.Extract, Logging_Services
LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\LSLUsers'
LogDate = Oconv(Date(), 'D4/')
LogTime = Oconv(Time(), 'MTS')
LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : ' Notification Groups Update Log.csv'
Headers = 'Logging DTM' : @FM : 'Notification ID' : @FM : 'Notes'
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.')
@ -187,6 +194,28 @@ Service GetOnShiftUsersByClass(Class, IncludeNextShift)
end service
Service GetOnShiftUsers()
DatetimeNow = OConv(SRP_DateTime("Now"), 'DT')
CurrentShift = Lsl_Users_Services('GetShiftByDate', DatetimeNow)
Open 'DICT.LSL_USERS' to DictLSLUsers then
SearchString = ''
SearchString := 'SHIFT' : @VM : CurrentShift : @VM : '' : @FM ; // Include office personnel (i.e. no shift assigned)
SearchString := 'ACTIVE' : @VM : True$ : @FM
LSLUsersKeys = ''
Btree.Extract(SearchString, 'LSL_USERS', DictLSLUsers, LSLUsersKeys, '', '')
ErrCode = ''
IF Get_Status(ErrCode) then
ErrorMsg = 'Error in ':Service:' service. Error calling Btree.Extract. Error code ':ErrCode:'.'
end
Response = LSLUsersKeys
end else
ErrorMsg = 'Error in ':Service:' service. Error opening LSL_USERS dictionary.'
end
end service
Service GetShiftByDate(Date, GenerateFlag)
OnShift = ''; *Return Value
@ -350,3 +379,86 @@ Service GetShiftByDate(Date, GenerateFlag)
end service
Service UpdateNotificationGroups()
hSysLists = Database_Services('GetTableHandle', 'SYSLISTS')
Lock hSysLists, ServiceKeyID then
Open 'NOTIFICATION' to hTable then
EOF = False$
Select hTable
Loop
ReadNext KeyId else EOF = True$
Until EOF
Lock hTable, KeyId then
Read Rec from hTable, KeyId then
UseAD = Rec<NOTIFICATION_USE_ACTIVE_DIRECTORY$>
If UseAD then
LSLUserList = ''
// Update LSL_User list based on current members in Active Directory groups
ADGroups = Rec<NOTIFICATION_ACTIVE_DIRECTORY_GROUPS$>
For each GroupName in ADGroups using @VM
MemberList = Active_Directory_Services('GetADGroupMembersByGroupName', GroupName, 'INFINEON')
MemberList = SRP_Array('Rotate', MemberList, @FM, @VM)
ADUserNames = MemberList<1>
LSLUserNames = ''
LSLNames = ''
Open 'DICT.LSL_USERS' to hDict then
For each ADUserName in ADUserNames using @VM setting vPos
Query = 'DOMAIN_USERNAME':@VM:ADUserName:@FM:'ACTIVE':@VM:True$:@FM
Flag = ''
LSLUsername = ''
Btree.Extract(Query, 'LSL_USERS', hDict, LSLUsername, '', Flag)
If Flag EQ 0 then
If LSLUsername NE '' then
LSLUserList<0, -1> = LSLUsername
end else
LogData = ''
LogData<1> = LoggingDtm
LogData<2> = KeyId
LogData<3> = 'No LSL_USERS record found for active directory member "':ADUserName:'".'
Logging_Services('AppendLog', objLog, LogData, @RM, @FM)
end
end else
LogData = ''
LogData<1> = LoggingDtm
LogData<2> = KeyId
LogData<3> = 'Btree.Extract call failed for DOMAIN_USERNAME "':ADUserName:'".'
Logging_Services('AppendLog', objLog, LogData, @RM, @FM)
end
Next ADUserName
end
Next GroupName
LSLUserList = SRP_Array('Clean', LSLUserList, 'TrimAndMakeUnique', @VM)
LSLUserList = SRP_Array('SortSimpleList', LSLUserList, 'AscendingText', @VM)
Rec<NOTIFICATION_USER_ID$> = LSLUserList
Write Rec on hTable, KeyId else
LogData = ''
LogData<1> = LoggingDtm
LogData<2> = KeyId
LogData<3> = 'Failed to write record during update.'
Logging_Services('AppendLog', objLog, LogData, @RM, @FM)
end
end
end else
LogData = ''
LogData<1> = LoggingDtm
LogData<2> = KeyId
LogData<3> = 'Failed to read record during update.'
Logging_Services('AppendLog', objLog, LogData, @RM, @FM)
end
Unlock hTable, KeyId else
LogData = ''
LogData<1> = LoggingDtm
LogData<2> = KeyId
LogData<3> = 'Failed to unlock record during update.'
Logging_Services('AppendLog', objLog, LogData, @RM, @FM)
end
end
Repeat
end
Unlock hSysLists, ServiceKeyID else Null
end
end service