- Timestamp:
- 05/03/16 17:13:50 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Hubs/ProgressHub.cs
r13739 r13827 6 6 using System.Linq; 7 7 using System.Threading.Tasks; 8 using HeuristicLab.Data; 9 using System.Reflection; 8 10 9 11 namespace HeuristicLab.Clients.Hive.WebJobManager … … 26 28 userId = Guid.Empty; 27 29 } 28 else { 30 else 31 { 29 32 userId = Guid.Parse(uid); 30 33 fileopener = weblog.getFileOpener(userId); … … 51 54 if (name != null) 52 55 fileopener.Job.Job.Name = name; 53 if (resource != null && resource != "")56 if (resource != null && resource != "") 54 57 { 55 58 fileopener.Job.Job.ResourceNames += "/" + resource; … … 70 73 {//check if upper job 71 74 current.ItemTask.ComputeInParallel = !current.ItemTask.ComputeInParallel; 72 73 } 74 else { 75 76 } 77 else 78 { 75 79 for (var i = 0; i < arr.Length; i++) 76 80 { … … 89 93 90 94 } 91 else {//not deep enough, select right path 95 else 96 {//not deep enough, select right path 92 97 if (current.ItemTask.Item is BatchRun) 93 98 current = current.ChildHiveTasks[arr[i][1]]; // select right batch … … 115 120 116 121 } 117 else { 122 else 123 { 118 124 for (var i = 0; i < arr.Length; i++) 119 125 {//loop for depth … … 132 138 133 139 } 134 else {//not deep enough, choose right path 140 else 141 {//not deep enough, choose right path 135 142 if (current.ItemTask.Item is BatchRun) 136 143 current = current.ChildHiveTasks[arr[i][1]]; // select right batch … … 177 184 178 185 } 186 public void paraEdit(int[][] arr, string problem, string name, string type, string value) 187 { 188 189 190 loader(); 191 HiveTask current = fileopener.Job.HiveTasks.ToList()[0]; 192 if (arr.Length == 0) 193 {//check if upper job 194 if (current.ItemTask.Item is Algorithm) 195 { 196 searchEditPara(current, problem, name, type, value); 197 } 198 } 199 else 200 { 201 for (var i = 0; i < arr.Length; i++) 202 {//loop for depth 203 if (i == arr.Length - 1) 204 {//Right depth reached, change priority for current 205 if (current.ItemTask.Item is BatchRun) 206 { 207 current = current.ChildHiveTasks[arr[i][1]]; 208 } 209 else if (current.ItemTask.Item is Experiment) 210 { 211 current = current.ChildHiveTasks[arr[i][0]]; 212 } 213 if (current.ItemTask.Item is Algorithm) 214 { 215 searchEditPara(current, problem, name, type, value); 216 } 217 } 218 else 219 {//not deep enough, choose right path 220 if (current.ItemTask.Item is BatchRun) 221 current = current.ChildHiveTasks[arr[i][1]]; // select right batch 222 else if (current.ItemTask.Item is Experiment) 223 current = current.ChildHiveTasks[arr[i][0]]; // select right sub task from experiment 224 } 225 } 226 } 227 } 228 /// <summary> 229 /// Generic parameter setter 230 /// </summary> 231 /// <param name="curr">Current task to edit </param> 232 /// <param name="problem">Problem parameter or normal parameter</param> 233 /// <param name="name">Property name</param> 234 /// <param name="type">Datatype</param> 235 /// <param name="value">New value</param> 236 private void searchEditPara(HiveTask curr, string problem, string name, string type, string value) 237 { 238 var prob = problem == "True" ? true : false; 239 240 var dattype = Type.GetType(type); 241 if (dattype == null) 242 {//Use assemblies to find correct datatype 243 foreach (var a in AppDomain.CurrentDomain.GetAssemblies()) 244 { 245 dattype = a.GetType(type); 246 if (dattype != null) 247 break; 248 } 249 } 250 //find parse method 251 var parse = dattype.GetMethod("Parse", new[] { typeof(string) }); 252 253 if (parse != null) 254 { 255 //Parses string to correct datatype 256 var val = parse.Invoke(null, new object[] { value }); 257 258 //BUGGERS 259 if (name == "ReevaluateElites") 260 name = "ReevaluteElites"; 261 if (name == "DominateOnEqualQualities" || name == "PlusSelection" || name == "ReevaluteElites") 262 val = ((BoolValue)val).Value; 263 264 // if (name == "ReduceToPopulationSize") 265 //name += "Parameter"; 266 267 try 268 { 269 Algorithm alg = (Algorithm)curr.ItemTask.Item; 270 if (prob) 271 alg.Problem.GetType().GetProperty(name).SetValue(alg, val); 272 else 273 alg.GetType().GetProperty(name).SetValue(alg, val); 274 } 275 catch (NullReferenceException e) 276 { 277 Console.WriteLine("NullRefException: " + name + " - " + type); 278 } 279 catch(TargetException e) 280 { 281 Console.WriteLine("TargetException: " + name + " - " + type); 282 } 283 } 284 285 } 179 286 180 287 }
Note: See TracChangeset
for help on using the changeset viewer.