- Timestamp:
- 04/26/16 11:30:46 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Hubs/CalendarHub.cs
r13782 r13795 1 1 using HeuristicLab.Clients.Access.Administration; 2 2 using HeuristicLab.Clients.Hive.WebJobManager.Services; 3 using HeuristicLab.Clients.Hive.WebJobManager.ViewModels.User; 3 4 using Microsoft.AspNet.SignalR; 4 5 using Newtonsoft.Json; … … 16 17 private Guid userId; 17 18 private HiveAdminClientWeb adminClient; 19 private HiveServiceLocatorWeb servloc; 20 private AccessAdministrationClient accessClient; 18 21 private void loader() 19 22 { … … 28 31 userId = Guid.Parse(uid); 29 32 adminClient = weblog.getAdminClient(userId); 33 servloc = weblog.getServiceLocator(userId); 34 accessClient = weblog.getAccessAdminClient(userId); 30 35 } 31 36 } … … 34 39 loader(); 35 40 adminClient.Refresh(); 36 41 UserViewModel vm = new UserViewModel(accessClient).refreshAll(); 42 var users = JsonConvert.SerializeObject(vm.users); 43 var groups = JsonConvert.SerializeObject(vm.ugroups); 37 44 var res = JsonConvert.SerializeObject(adminClient.Resources); 38 Clients.Caller.processData(res );45 Clients.Caller.processData(res, users, groups); 39 46 } 40 47 public void requestDownTime(string id) … … 47 54 var down = JsonConvert.SerializeObject(adminClient.Downtimes); 48 55 Clients.Caller.processDowntime(id, down); 56 } 57 public void requestPermissions(string id) 58 { 59 loader(); 60 Guid r = Guid.Parse(id); 61 var perm = servloc.CallHiveService(x => x.GetResourcePermissions(r)); 62 Clients.Caller.processPermissions(id, JsonConvert.SerializeObject(perm)); 63 } 64 65 public void changePermissions(string[] perms, string idresource) 66 { 67 loader(); 68 var res = Guid.Parse(idresource); 69 var exist = servloc.CallHiveService(x => x.GetResourcePermissions(res)); 70 List<Guid> newPerms = new List<Guid>(); 71 List<Guid> revokePerms = new List<Guid>(); 72 for (var i = 0; i < perms.Length; i++) 73 { 74 var p = Guid.Parse(perms[i]); 75 var elemid = exist.FindIndex(x => x.GrantedUserId == p); 76 if (elemid != -1) 77 { 78 exist[elemid].GrantedUserId = Guid.Empty; 79 } 80 else 81 { 82 newPerms.Add(p); 83 } 84 } 85 servloc.CallHiveService(x => x.GrantResourcePermissions(res, newPerms)); 86 foreach (var ex in exist) 87 { 88 if(ex.GrantedUserId != Guid.Empty) 89 { 90 revokePerms.Add(ex.GrantedUserId); 91 } 92 } 93 servloc.CallHiveService(x => x.RevokeResourcePermissions(res, revokePerms)); 94 requestPermissions(idresource); 49 95 } 50 96 public void toggleDisposable(string id)
Note: See TracChangeset
for help on using the changeset viewer.