- Timestamp:
- 04/21/16 16:48:34 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Controllers/ResourceController.cs
r13754 r13782 1 using HeuristicLab.Clients.Access.Administration; 1 using HeuristicLab.Clients.Access; 2 using HeuristicLab.Clients.Access.Administration; 2 3 using HeuristicLab.Clients.Hive.WebJobManager.Services; 3 4 using Microsoft.AspNet.Hosting; … … 8 9 using System.Linq; 9 10 using System.ServiceModel.Security; 11 using System.Threading; 10 12 using System.Threading.Tasks; 11 13 … … 17 19 private HiveServiceLocatorWeb serviceLocator; 18 20 private AccessAdministrationClient accessClient; 21 private HiveAdminClientWeb adminClient; 19 22 private Guid userId; 20 23 … … 37 40 userId = Guid.Parse(u); 38 41 serviceLocator = weblog.getServiceLocator(userId); 42 adminClient = weblog.getAdminClient(userId); 39 43 accessClient = weblog.getAccessAdminClient(userId); 40 44 return serviceLocator.CheckLogin(); … … 56 60 } 57 61 } 62 [HttpPost] 63 public IActionResult changeParent(string inpid, string inpidpar) 64 { 65 if (init()) 66 { 67 var gid = Guid.Parse(inpid); 68 69 70 adminClient.Refresh(); 71 var tochange = adminClient.Resources.ToList().Find(x => x.Id == gid); 72 73 if (inpidpar != null && inpidpar != "") { 74 Guid tempid = Guid.Parse(inpidpar); 75 while (tempid != null) 76 { 77 if (tempid != gid) 78 { 79 tempid = (Guid)adminClient.Resources.ToList().Find(x => x.Id == tempid).ParentResourceId; 80 } 81 else 82 break; 83 } 84 if(tempid == null) 85 tochange.ParentResourceId = Guid.Parse(inpidpar); 86 } 87 else 88 tochange.ParentResourceId = null; 89 adminClient.Store(tochange, CancellationToken.None); 90 91 return RedirectToAction("Index", "Resource"); 92 } 93 else 94 { 95 return RedirectToAction("Index", "Home"); 96 } 97 } 98 [HttpPost] 99 public IActionResult deleteClientGroup(string inpid) 100 { 101 if (init()) 102 { 103 var gid = Guid.Parse(inpid); 104 105 adminClient.Refresh(); 106 var group = adminClient.Resources.ToList().Find(x => x.Id == gid); 107 var list = adminClient.Resources.ToList().FindAll(x => x.ParentResourceId == gid); 108 foreach(var cl in list) 109 { 110 cl.ParentResourceId = group.ParentResourceId; 111 adminClient.Store(cl, CancellationToken.None); 112 } 113 adminClient.Delete(group); 114 115 return RedirectToAction("Index", "Resource"); 116 } 117 else 118 { 119 return RedirectToAction("Index", "Home"); 120 } 121 } 122 123 [HttpPost] 124 public IActionResult newClientGroup(string inpname, int inpheart, string inpparent, string[] clientstoadd) 125 { 126 if (init()) { 127 adminClient.Refresh(); 128 129 SlaveGroup sg = new SlaveGroup(); 130 sg.Id = Guid.Empty; 131 sg.Name = inpname; 132 sg.HbInterval = inpheart; 133 if (inpparent != "") 134 sg.ParentResourceId = Guid.Parse(inpparent); 135 sg.OwnerUserId = serviceLocator.getHiveServiceClient().GetUserIdByUsername(serviceLocator.getHiveServiceClient().ClientCredentials.UserName.UserName); 136 adminClient.Store(sg, CancellationToken.None); 137 adminClient.Refresh(); 138 var id = adminClient.Resources.ToList().Find(x => x.Name == inpname).Id; 139 foreach(var s in clientstoadd) 140 { 141 var cid = Guid.Parse(s); 142 var client = adminClient.Resources.ToList().Find(x => x.Id == cid); 143 client.ParentResourceId = id; 144 adminClient.Store(client, CancellationToken.None); 145 } 146 147 return RedirectToAction("Index", "Resource"); 148 } 149 else 150 { 151 return RedirectToAction("Index", "Home"); 152 } 153 } 58 154 } 59 155 }
Note: See TracChangeset
for help on using the changeset viewer.