44using BHD_ServerManager . Classes . SupportClasses ;
55using HawkSyncShared . DTOs ;
66using static BHD_ServerManager . Classes . InstanceManagers . adminInstanceManager ;
7+ using HawkSyncShared . Instances ;
78
89namespace BHD_ServerManager . Forms . Panels ;
910
@@ -13,6 +14,8 @@ public partial class tabAdmin : UserControl
1314 // FIELDS
1415 // ================================================================================
1516
17+ private adminInstance adminInstance => CommonCore . instanceAdmin ! ;
18+
1619 private int _selectedUserID = - 1 ;
1720 private bool _isEditMode = false ;
1821
@@ -31,10 +34,31 @@ public tabAdmin()
3134 {
3235 InitializeComponent ( ) ;
3336 InitializeEvents ( ) ;
37+
38+ adminInstanceManager . LoadUsersCache ( ) ;
3439 LoadUserList ( ) ;
40+
3541 SetFormMode ( FormMode . View ) ;
3642 }
3743
44+ public void tickerAdmin_Tick ( )
45+ {
46+ if ( InvokeRequired )
47+ {
48+ Invoke ( new Action ( tickerAdmin_Tick ) ) ;
49+ return ;
50+ }
51+
52+ //Periodic tasks can be added here if needed
53+ if ( adminInstance . ForceUIUpdate )
54+ {
55+ adminInstanceManager . LoadUsersCache ( ) ;
56+ LoadUserList ( ) ;
57+ adminInstance . ForceUIUpdate = false ;
58+ }
59+
60+ }
61+
3862 private void InitializeEvents ( )
3963 {
4064 // Grid events
@@ -312,13 +336,14 @@ private void CreateUser()
312336 }
313337
314338 // Build request
315- var request = new CreateUserRequest (
316- Username : textBox_username . Text . Trim ( ) ,
317- Password : textBox_password . Text ,
318- Permissions : GetSelectedPermissions ( ) ,
319- IsActive : checkBox_userActive . Checked ,
320- Notes : textBox_userNotes . Text . Trim ( )
321- ) ;
339+ var request = new CreateUserRequest
340+ {
341+ Username = textBox_username . Text . Trim ( ) ,
342+ Password = textBox_password . Text ,
343+ Permissions = GetSelectedPermissions ( ) ,
344+ IsActive = checkBox_userActive . Checked ,
345+ Notes = textBox_userNotes . Text . Trim ( )
346+ } ;
322347
323348 // Call manager (cache will be auto-updated)
324349 var result = adminInstanceManager . CreateUser ( request ) ;
@@ -343,16 +368,17 @@ private void CreateUser()
343368 private void UpdateUser ( )
344369 {
345370 // Build request
346- var request = new UpdateUserRequest (
347- UserID : _selectedUserID ,
348- Username : textBox_username . Text . Trim ( ) ,
349- NewPassword : string . IsNullOrWhiteSpace ( textBox_password . Text )
371+ var request = new UpdateUserRequest
372+ {
373+ UserID = _selectedUserID ,
374+ Username = textBox_username . Text . Trim ( ) ,
375+ NewPassword = string . IsNullOrWhiteSpace ( textBox_password . Text )
350376 ? null
351377 : textBox_password . Text ,
352- Permissions : GetSelectedPermissions ( ) ,
353- IsActive : checkBox_userActive . Checked ,
354- Notes : textBox_userNotes . Text . Trim ( )
355- ) ;
378+ Permissions = GetSelectedPermissions ( ) ,
379+ IsActive = checkBox_userActive . Checked ,
380+ Notes = textBox_userNotes . Text . Trim ( )
381+ } ;
356382
357383 // Call manager (cache will be auto-updated)
358384 var result = adminInstanceManager . UpdateUser ( request ) ;
0 commit comments