- Timestamp:
- 02/19/13 08:46:01 (12 years ago)
- Location:
- branches/OaaS/HeuristicLab.Services.Optimization.Web/Controllers
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OaaS/HeuristicLab.Services.Optimization.Web/Controllers/ExperimentController.cs
r9215 r9227 8 8 using HeuristicLab.Services.Optimization.ControllerService.Model; 9 9 using System.Web.Security; 10 using Mvc3TestApplication.Binders; 11 using HeuristicLab.Services.Optimization.ControllerService.Parsers; 10 12 11 13 namespace HeuristicLab.Services.Optimization.Web.Controllers … … 41 43 foreach (var scenario in scenarios) 42 44 model.Scenarios.Add(scenario); 45 46 Session["experiment"] = new Experiment(); 47 43 48 return View(model); 44 49 } 50 51 public ActionResult New() { 52 return Index(); 53 } 54 55 public Experiment Experiment { get { return Session["experiment"] as Experiment; } set { Session["experiment"] = value;} } 45 56 46 57 [HttpPost] … … 63 74 if (currentNode.title == "Experiment") 64 75 continue; 65 experiment. Scenarios.Add(new OptimizationScenario() { Id= currentNode.title });76 experiment.Algorithm.Add(new Algorithm() { Name = currentNode.title }); 66 77 } 67 78 … … 94 105 return RedirectToAction("Edit"); 95 106 } 107 108 [HttpPost] 109 public JsonResult SaveExperiment([ExperimentJson] Experiment experiment) { 110 return Json( 111 new { 112 Success = ControllerService.withControllerService<bool>(service => { 113 User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string }; 114 return service.SaveExperiment(u, experiment); 115 }) 116 }); 117 } 118 119 private JsonResult ComplexExperimentCase(string scenario) { 120 // complex case, find children of experiment 121 var model = new GetParametersModel() { Type = "Complex" }; 122 model.Subnames = new List<string>(); 123 124 var experiment = ControllerService.withControllerService<Experiment>(service => { 125 User user = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string }; 126 return service.GetExperimentByName(user, scenario); 127 }); 128 129 // TODO: Make a tree out of subnames!! 130 if (experiment != null) 131 foreach (var algo in experiment.Algorithm) 132 model.Subnames.Add(algo.Name); 133 134 return Json(model, JsonRequestBehavior.AllowGet); 135 } 136 137 [HttpGet] 138 public JsonResult GetParameters(string scenario, string context, int index) { 139 if (context == "Experiment" || context == null) { 140 var optimizationScenario = ControllerService.withControllerService<OptimizationScenario>(service => { 141 return service.GetOptimizationScenarioByName(scenario); 142 }); 143 144 if (optimizationScenario != null) { 145 var model = new GetParametersModel() { Type = "Basic" }; 146 model.Algorithm = optimizationScenario.FirstAlgorithm; 147 model.Algorithm.Mapper = optimizationScenario.Id; 148 var json = Json(model, JsonRequestBehavior.AllowGet); 149 return json; 150 } 151 else { 152 // complex case, find children of experiment 153 var model = new GetParametersModel() { Type = "Complex" }; 154 model.Subnames = new List<string>(); 155 156 var experiment = ControllerService.withControllerService<Experiment>(service => { 157 User user = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string }; 158 return service.GetExperimentByName(user, scenario); 159 }); 160 161 // TODO: Make a tree out of subnames!! 162 if (experiment != null) 163 foreach (var algo in experiment.Algorithm) 164 model.Subnames.Add(algo.Name); 165 166 return Json(model, JsonRequestBehavior.AllowGet); 167 } 168 } 169 else { 170 var experiment = ControllerService.withControllerService<Experiment>(service => { 171 User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string }; 172 return service.GetExperimentByName(u, context); 173 }); 174 175 // if child algorithm is a complex algorithm, return as such 176 if (experiment.Algorithm[index].ChildAlgorithms.Count > 0) { 177 var model = new GetParametersModel() { Type = "Complex" }; 178 model.Subnames = new List<string>(); 179 foreach (var algo in experiment.Algorithm[index].ChildAlgorithms) 180 model.Subnames.Add(algo.Name); 181 return Json(model, JsonRequestBehavior.AllowGet); 182 } 183 else { 184 // otherwise we have the algorithms just below it 185 var model = new GetParametersModel() { Type = "Basic" }; 186 model.Algorithm = experiment.Algorithm[index]; 187 model.Algorithm.Mapper = experiment.Algorithm[index].Name; 188 var json = Json(model, JsonRequestBehavior.AllowGet); 189 return json; 190 } 191 } 192 } 96 193 } 97 194 } -
branches/OaaS/HeuristicLab.Services.Optimization.Web/Controllers/OptimizationController.cs
r9215 r9227 57 57 58 58 public ActionResult JobDetails(string jobId) { 59 Job job = ControllerService.withControllerService<Job>((service) => {59 var model = ControllerService.withControllerService<JobDetailsModel>((service) => { 60 60 User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string }; 61 return service.GetJob(u, jobId); 61 var job = service.GetJob(u, jobId); 62 var runs = service.GetJobResults(u, jobId); 63 return new JobDetailsModel() { Job = job, Runs = runs }; 62 64 }); 63 var runs = ControllerService.withControllerService<IList<Run>>((service) => { 64 User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string }; 65 return service.GetJobResults(u, jobId); 66 }); 67 JobDetailsModel jdm = new JobDetailsModel() { Job = job, Runs = runs }; 68 Session["jobDetails"] = jdm; 69 return View(jdm); 70 } 65 Session["jobDetails"] = model; 66 return View(model); 67 } 71 68 72 69 [HttpPost]
Note: See TracChangeset
for help on using the changeset viewer.