442 lines
14 KiB
Plaintext
442 lines
14 KiB
Plaintext
Compile function NDW_NOTIFICATION_EVENTS(CtrlEntId, Event, @PARAMS)
|
|
/***********************************************************************************************************************
|
|
|
|
This program is proprietary and is not to be used by or disclosed to others, nor is it to be copied without written
|
|
permission from Infineon.
|
|
|
|
Name : NDW_Notification_Events
|
|
|
|
Description : This function acts as a commuter module for all events related to this window.
|
|
|
|
Notes : Commuter Modules are automatically called from the Promoted_Events function which is called by the
|
|
application-specific promoted event handler. This makes it possible to add QuickEvents that need to
|
|
execute Basic+ logic without having use the Form Designer to make the association, although this is
|
|
limited to the events which are currently promoted.
|
|
|
|
If the form needs to call the commuter module directly then the QuickEvent parameters should be
|
|
formatted like this:
|
|
|
|
'@SELF','@EVENT',['@PARAM1','@PARAMx']
|
|
|
|
Parameters :
|
|
CtrlEntId [in] -- The fully qualified name of the control calling the promoted event
|
|
Event [in] -- The event being executed. See the Notes section regarding "PRE" events
|
|
Param1-15 [in] -- Additional event parameter holders
|
|
EventFlow [out] -- Set to 1 or 0 so the calling event knows whether or not to chain forward. See comments in
|
|
EVENT_SETUP insert
|
|
|
|
History : (Date, Initials, Notes)
|
|
09/30/24 djs Created initial commuter module.
|
|
|
|
***********************************************************************************************************************/
|
|
#pragma precomp SRP_PreCompiler
|
|
#window NDW_NOTIFICATION
|
|
|
|
$Insert EVENT_SETUP
|
|
$Insert APP_INSERTS
|
|
$Insert MSG_EQUATES
|
|
$Insert POPUP_EQUATES
|
|
$Insert NOTIFICATION_EQUATES
|
|
|
|
EQU READONLY_GREEN$ TO 192 + (220*256) + (192*65536)
|
|
|
|
Declare function Admin_User, Database_Services, Error_Services, Active_Directory_Services, SRP_Array
|
|
Declare subroutine PlaceDialog, Error_Services, Database_Services, Btree.Extract
|
|
|
|
GoToEvent Event for CtrlEntId else
|
|
// Event not implemented
|
|
end
|
|
|
|
Return EventFlow or 1
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// EVENT HANDLERS
|
|
//-----------------------------------------------------------------------------
|
|
|
|
Event WINDOW.CREATE(CreateParam)
|
|
|
|
PlaceDialog(-2, -2)
|
|
ColorArray = Send_Message(@Window:'.EDT_LSL_USERS', "COLOR_BY_POS", 2, 0)
|
|
ColorArray<1> = READONLY_GREEN$
|
|
Send_Message(@Window:'.EDT_LSL_USERS', "COLOR_BY_POS", 1, 0, ColorArray)
|
|
Send_Message(@Window:'.EDT_LSL_USERS', "COLOR_BY_POS", 2, 0, ColorArray)
|
|
Send_Message(@Window:'.EDT_AD_GROUPS', "COLOR_BY_POS", 1, 0, ColorArray)
|
|
Send_Message(@Window:'.EDT_AD_GROUPS', "COLOR_BY_POS", 2, 0, ColorArray)
|
|
Send_Message(@Window:'.EDT_AD_GROUPS', "COLOR_BY_POS", 3, 0, ColorArray)
|
|
|
|
End Event
|
|
|
|
|
|
Event WINDOW.READ()
|
|
|
|
Key = Get_Property(@Window:'.EDL_NOTIFICATION_ID', 'TEXT')
|
|
Begin Case
|
|
Case Key EQ ''
|
|
Set_Property(@Window:'.EDT_LSL_USERS', 'ENABLED', False$)
|
|
Case RowExists('NOTIFICATION', Key)
|
|
// Populate form
|
|
HaveLock = Database_Services('GetKeyIDLock', 'NOTIFICATION', Key, True$)
|
|
If HaveLock then
|
|
Set_Property(@Window, '@HAVE_LOCK', HaveLock)
|
|
Set_Property(@Window, '@LOCK_KEY', Key)
|
|
|
|
Set_Property(@Window:'.EDL_DESCRIPTION', 'ENABLED', True$)
|
|
Set_Property(@Window:'.CHK_USE_AD', 'ENABLED', True$)
|
|
Set_Property(@Window:'.CHK_LIMIT_TO_ACTIVE_SHIFT', True$)
|
|
Set_Property(@Window:'.PUB_CLEAR', 'ENABLED', True$)
|
|
Set_Property(@Window:'.PUB_DELETE', 'ENABLED', True$)
|
|
Set_Property(@Window:'.PUB_SAVE', 'ENABLED', True$)
|
|
NotifyRec = Database_Services('ReadDataRow', 'NOTIFICATION', Key)
|
|
If Error_Services('NoError') then
|
|
Set_Property(@Window, '@RECORD', NotifyRec)
|
|
Set_Property(@Window:'.EDL_DESCRIPTION', 'TEXT', NotifyRec<NOTIFICATION_DESC$>)
|
|
UseAD = NotifyRec<NOTIFICATION_USE_ACTIVE_DIRECTORY$>
|
|
Set_Property(@Window:'.CHK_USE_AD', 'DEFPROP', UseAD)
|
|
LimitOnShift = NotifyRec<NOTIFICATION_LIMIT_TO_ACTIVE_SHIFT$>
|
|
Set_Property(@Window:'.CHK_LIMIT_TO_ACTIVE_SHIFT', 'DEFPROP', LimitOnShift)
|
|
|
|
LSLUsers = NotifyRec<NOTIFICATION_USER_ID$>
|
|
LSLUsernames = Xlate('LSL_USERS', LSLUsers, 'FIRST_LAST', 'X')
|
|
LSLUsersArray = LSLUsers : @FM : LSLUsernames
|
|
Set_Property(@Window:'.EDT_LSL_USERS', 'ARRAY', LSLUsersArray)
|
|
ADGroups = NotifyRec<NOTIFICATION_ACTIVE_DIRECTORY_GROUPS$>
|
|
GroupList = ''
|
|
If ADGroups NE '' then
|
|
For each ADGroup in ADGroups using @VM setting vPos
|
|
GroupList<-1> = Active_Directory_Services('GetADGroupsByString', ADGroup, 'INFINEON')
|
|
Next ADGroup
|
|
end
|
|
Set_Property(@Window:'.EDT_AD_GROUPS', 'LIST', GroupList)
|
|
GoSub EnableControls
|
|
end else
|
|
Msg(@Window, '', 'OK', '', 'Error':@FM:'Error locking NOTIFICATION record "':Key:'" for update!')
|
|
end
|
|
end else
|
|
Msg(@Window, '', 'OK', '', 'Error':@FM:'Error reading NOTIFICATION record "':Key:'"!')
|
|
end
|
|
Case Otherwise$
|
|
// User is creating a new record
|
|
Set_Property(@Window:'.PUB_ADD_USERS', 'ENABLED', True$)
|
|
GoSub EnableControls
|
|
End Case
|
|
|
|
end event
|
|
|
|
|
|
Event WINDOW.CLEAR(bSaveKey, bSuppressWarning, bMaintainFocus)
|
|
|
|
GoSub EnableControls
|
|
Set_Property(@Window:'.PUB_DELETE', 'ENABLED', False$)
|
|
Set_Property(@Window:'.PUB_CLEAR', 'ENABLED', True$)
|
|
Set_Property(@Window:'.EDL_DESCRIPTION', 'ENABLED', False$)
|
|
Set_Property(@Window:'.CHK_USE_AD', 'ENABLED', False$)
|
|
Set_Property(@Window:'.CHK_LIMIT_TO_ACTIVE_SHIFT', 'ENABLED', False$)
|
|
|
|
Set_Property(@Window:'.PUB_ADD_USERS', 'ENABLED', False$)
|
|
Set_Property(@Window:'.REM_ADD_USERS', 'ENABLED', False$)
|
|
|
|
Set_Property(@Window:'.GRB_AD_GROUPS', 'ENABLED', False$)
|
|
Set_Property(@Window:'.EDT_AD_GROUPS', 'ENABLED', False$)
|
|
Set_Property(@Window:'.PUB_ADD_GROUPS', 'ENABLED', False$)
|
|
Set_Property(@Window:'.REM_ADD_GROUPS', 'ENABLED', False$)
|
|
|
|
end event
|
|
|
|
|
|
Event WINDOW.WRITE()
|
|
|
|
Key = Get_Property(@Window:'.EDL_NOTIFICATION_ID', 'TEXT')
|
|
NotifyRec = Get_Property(@Window, '@RECORD')
|
|
NotifyRec<NOTIFICATION_DESC$> = Get_Property(@Window:'.EDL_DESCRIPTION', 'TEXT')
|
|
UserArray = Get_Property(@Window:'.EDT_LSL_USERS', 'ARRAY')
|
|
UserIds = UserArray<1>
|
|
NotifyRec<NOTIFICATION_USER_ID$> = UserIds
|
|
GroupArray = Get_Property(@Window:'.EDT_AD_GROUPS', 'ARRAY')
|
|
GroupIds = GroupArray<1>
|
|
NotifyRec<NOTIFICATION_ACTIVE_DIRECTORY_GROUPS$> = GroupIds
|
|
NotifyRec<NOTIFICATION_USE_ACTIVE_DIRECTORY$> = Get_Property(@Window:'.CHK_USE_AD', 'DEFPROP')
|
|
NotifyRec<NOTIFICATION_LIMIT_TO_ACTIVE_SHIFT$> = Get_Property(@Window:'.CHK_LIMIT_TO_ACTIVE_SHIFT', 'DEFPROP')
|
|
Database_Services('WriteDataRow', 'NOTIFICATION', Key, NotifyRec, True$, False$, True$)
|
|
If Error_Services('NoError') then
|
|
GoSub UnlockRec
|
|
Post_Event(@Window, 'CLEAR')
|
|
end else
|
|
Msg(@Window, '', 'OK', '', 'Error':@FM:Error_Services('GetMessage'))
|
|
end
|
|
|
|
end event
|
|
|
|
|
|
Event WINDOW.CLOSE(CancelFlag, CloseFlags)
|
|
|
|
GoSub UnlockRec
|
|
|
|
end event
|
|
|
|
|
|
Event PUB_SAVE.CLICK()
|
|
|
|
Post_Event(@Window, 'WRITE')
|
|
|
|
end event
|
|
|
|
|
|
Event PUB_CLEAR.CLICK()
|
|
|
|
GoSub UnlockRec
|
|
Post_Event(@Window, 'CLEAR')
|
|
|
|
end event
|
|
|
|
|
|
Event PUB_LU_ID.CLICK()
|
|
|
|
TypeOver = ''
|
|
TypeOver<PSELECT$> = 1
|
|
NotifyID = Popup(@WINDOW,TypeOver,'NOTIFICATION')
|
|
IF NotifyID NE '' THEN
|
|
Set_Property(@Window:'.EDL_NOTIFICATION_ID', 'TEXT', NotifyID)
|
|
end
|
|
|
|
end event
|
|
|
|
|
|
Event EDT_LSL_USERS.ROWSELCHANGED(SelRow, SelState)
|
|
|
|
GoSub EnableControls
|
|
|
|
end event
|
|
|
|
|
|
Event EDT_AD_GROUPS.ROWSELCHANGED(SelRow, SelState)
|
|
|
|
GoSub EnableControls
|
|
|
|
end event
|
|
|
|
|
|
Event EDL_NOTIFICATION_ID.CHANGED(NewData)
|
|
|
|
If NewData NE '' then
|
|
GoSub UnlockRec
|
|
Post_Event(@Window, 'READ')
|
|
end
|
|
|
|
end event
|
|
|
|
|
|
Event EDL_NOTIFICATION_ID.LOSTFOCUS(Flag, FocusID)
|
|
|
|
If Flag EQ 1 then
|
|
GoSub UnlockRec
|
|
Post_Event(@Window, 'READ')
|
|
end
|
|
|
|
end event
|
|
|
|
|
|
Event PUB_ADD_USERS.CLICK()
|
|
|
|
CurrUserIDs = Get_Property(@Window:'.EDT_LSL_USERS','ARRAY')<1>
|
|
CurrUserIDsTrimmed = ''
|
|
FOR I = 1 TO COUNT(CurrUserIDs,@VM) + (CurrUserIDs NE '')
|
|
IF CurrUserIDs<1,I> NE '' THEN
|
|
CurrUserIDsTrimmed<1,I> = CurrUserIDs<1,I>
|
|
END
|
|
NEXT I
|
|
CurrUserIDs = CurrUserIDsTrimmed
|
|
|
|
NewUserIDs = Popup(@WINDOW,'','SHOW_USERS')
|
|
|
|
IF NewUserIDs = '' OR NewUserIDs = CHAR(27) THEN RETURN
|
|
|
|
FOR I = 1 TO COUNT(NewUserIDs,@VM) + (NewUserIDs NE '')
|
|
NewUserID = NewUserIDs<1,I>
|
|
LOCATE NewUserID IN CurrUserIDs BY 'AL' USING @VM SETTING POS ELSE
|
|
CurrUserIDs = INSERT(CurrUserIDs,1,POS,0,NewUserID)
|
|
END
|
|
|
|
NEXT I
|
|
|
|
LSLNames = Xlate('LSL_USERS', CurrUserIDs, 'FIRST_LAST', 'X')
|
|
NewArray = CurrUserIDs : @FM : LSLNames
|
|
Set_Property(@Window:'.EDT_LSL_USERS', 'ARRAY', NewArray)
|
|
|
|
end event
|
|
|
|
|
|
Event PUB_REM_USERS.CLICK()
|
|
|
|
SelRows = Get_Property(@Window:'.EDT_LSL_USERS', 'SELPOS')
|
|
SelRows = SelRows<2>
|
|
SelData = ''
|
|
NewList = ''
|
|
If SelRows NE '' then
|
|
DataList = Get_Property(@Window:'.EDT_LSL_USERS', 'LIST')
|
|
For each Row in DataList using @FM setting RowIndex
|
|
If Not(InList(SelRows, RowIndex, @VM)) then NewList<-1> = Row
|
|
Next Row
|
|
Set_Property(@Window:'.EDT_LSL_USERS', 'LIST', NewList)
|
|
GoSub EnableControls
|
|
end
|
|
|
|
end event
|
|
|
|
|
|
Event PUB_ADD_GROUPS.CLICK()
|
|
|
|
GroupArray = Get_Property(@Window:'.EDT_AD_GROUPS', 'ARRAY')
|
|
GroupIds = GroupArray<1>
|
|
SelGroups = Dialog_Box('NDW_ACTIVE_DIRECTORY_GROUPS', @Window, GroupIds)
|
|
If SelGroups NE '' then
|
|
Set_Property(@Window:'.EDT_AD_GROUPS', 'LIST', SelGroups)
|
|
|
|
Def = ""
|
|
Def<MCOL$> = -2
|
|
Def<MROW$> = -2
|
|
Def<MTEXT$> = "Updating LSL user list..."
|
|
Def<MTYPE$> = "U"
|
|
MsgUp = Msg(@window, Def) ;* display the processing message
|
|
|
|
GroupArray = Get_Property(@Window:'.EDT_AD_GROUPS', 'ARRAY')
|
|
GroupIds = GroupArray<1>
|
|
|
|
LSLUserNames = ''
|
|
LSLNames = ''
|
|
If GroupIds NE '' then
|
|
For each GroupId in GroupIds using @VM
|
|
MemberList = Active_Directory_Services('GetADGroupMembersByGroupName', GroupId, 'INFINEON')
|
|
MemberList = SRP_Array('Rotate', MemberList, @FM, @VM)
|
|
ADUserNames = MemberList<1>
|
|
|
|
Open 'DICT.LSL_USERS' to hDict then
|
|
For each ADUserName in ADUserNames using @VM setting vPos
|
|
Query = 'DOMAIN_USERNAME':@VM:ADUserName:@FM
|
|
Flag = ''
|
|
LSLUsername = ''
|
|
Btree.Extract(Query, 'LSL_USERS', hDict, LSLUsername, '', Flag)
|
|
If LSLUsername NE '' then LSLUsernames<0, -1> = LSLUsername<0, 1>
|
|
Next ADUserName
|
|
end
|
|
Next GroupId
|
|
If LSLUsernames NE '' then
|
|
LSLNames = Xlate('LSL_USERS', LSLUserNames, 'FIRST_LAST', 'X')
|
|
end
|
|
end
|
|
Array = LSLUsernames : @FM : LSLNames
|
|
Set_Property(@Window:'.EDT_LSL_USERS', 'ARRAY', Array)
|
|
|
|
Msg(@window, MsgUp) ;* take down the processing message
|
|
end
|
|
|
|
end event
|
|
|
|
|
|
Event PUB_REM_GROUPS.CLICK()
|
|
|
|
SelRows = Get_Property(@Window:'.EDT_AD_GROUPS', 'SELPOS')
|
|
SelRows = SelRows<2>
|
|
SelData = ''
|
|
NewList = ''
|
|
If SelRows NE '' then
|
|
DataList = Get_Property(@Window:'.EDT_AD_GROUPS', 'LIST')
|
|
For each Row in DataList using @FM setting RowIndex
|
|
If Not(InList(SelRows, RowIndex, @VM)) then NewList<-1> = Row
|
|
Next Row
|
|
Set_Property(@Window:'.EDT_AD_GROUPS', 'LIST', NewList)
|
|
GoSub EnableControls
|
|
end
|
|
|
|
end event
|
|
|
|
|
|
Event CHK_USE_AD.CLICK()
|
|
|
|
GoSub EnableControls
|
|
|
|
end event
|
|
|
|
|
|
EnableControls:
|
|
|
|
NotifyID = Get_Property(@Window:'.EDL_NOTIFICATION_ID', 'TEXT')
|
|
UseAD = Get_Property(@Window:'.CHK_USE_AD', 'DEFPROP')
|
|
|
|
Set_Property(@Window:'.PUB_CLEAR', 'ENABLED', (NotifyID NE ''))
|
|
Set_Property(@Window:'.EDL_DESCRIPTION', 'ENABLED', (NotifyID NE ''))
|
|
Set_Property(@Window:'.CHK_USE_AD', 'ENABLED', (NotifyID NE ''))
|
|
|
|
If UseAD NE True$ then Set_Property(@Window:'.CHK_LIMIT_TO_ACTIVE_SHIFT', 'DEFPROP', False$)
|
|
Set_Property(@Window:'.CHK_LIMIT_TO_ACTIVE_SHIFT', 'ENABLED', UseAD)
|
|
|
|
Set_Property(@Window:'.PUB_ADD_USERS', 'ENABLED', (UseAD NE True$))
|
|
Set_Property(@Window:'.EDT_LSL_USERS', 'ENABLED', (NotifyID NE ''))
|
|
|
|
If NotifyID NE '' then
|
|
Backcolor = WHITE$
|
|
end else
|
|
Backcolor = GREY$
|
|
end
|
|
|
|
Set_Property(@Window:'.EDT_LSL_USERS', 'BACKCOLOR', Backcolor)
|
|
|
|
Set_Property(@Window:'.GRB_AD_GROUPS', 'ENABLED', (UseAD EQ True$))
|
|
Set_Property(@Window:'.PUB_ADD_GROUPS', 'ENABLED', (UseAD EQ True$))
|
|
Set_Property(@Window:'.EDT_AD_GROUPS', 'ENABLED', (UseAD EQ True$))
|
|
|
|
If ( (NotifyID NE '') and (UseAD EQ True$) ) then
|
|
Backcolor = WHITE$
|
|
end else
|
|
Backcolor = GREY$
|
|
end
|
|
Set_Property(@Window:'.EDT_AD_GROUPS', 'BACKCOLOR', Backcolor)
|
|
|
|
DelBtnEnabled = False$
|
|
SelRows = Get_Property(@Window:'.EDT_LSL_USERS', 'SELPOS')
|
|
SelRows = SelRows<2>
|
|
SelData = ''
|
|
If SelRows NE '' then
|
|
Data = Get_Property(@Window:'.EDT_LSL_USERS', 'LIST')
|
|
Convert @VM to '' in Data
|
|
For each Row in SelRows using @VM
|
|
If Data<Row> NE '' then
|
|
SelData<-1> = Data<Row>
|
|
end
|
|
Next Row
|
|
If (SelData NE '') and (UseAD NE True$) then DelBtnEnabled = True$
|
|
end
|
|
Set_Property(@Window:'.PUB_REM_USERS', 'ENABLED', DelBtnEnabled)
|
|
|
|
DelBtnEnabled = False$
|
|
SelRows = Get_Property(@Window:'.EDT_AD_GROUPS', 'SELPOS')
|
|
SelRows = SelRows<2>
|
|
SelData = ''
|
|
If SelRows NE '' then
|
|
Data = Get_Property(@Window:'.EDT_AD_GROUPS', 'LIST')
|
|
Convert @VM to '' in Data
|
|
For each Row in SelRows using @VM
|
|
If Data<Row> NE '' then
|
|
SelData<-1> = Data<Row>
|
|
end
|
|
Next Row
|
|
If (SelData NE '') and (UseAD EQ True$) then DelBtnEnabled = True$
|
|
end
|
|
Set_Property(@Window:'.PUB_REM_GROUPS', 'ENABLED', DelBtnEnabled)
|
|
|
|
return
|
|
|
|
|
|
UnlockRec:
|
|
|
|
Key = Get_Property(@Window, '@LOCK_KEY')
|
|
If Key NE '' then
|
|
HaveLock = Get_Property(@Window, '@HAVE_LOCK')
|
|
If HaveLock then
|
|
Database_Services('ReleaseKeyIDLock', 'NOTIFICATION', Key)
|
|
end
|
|
end
|
|
|
|
return
|
|
|
|
|