Changeset 9227 for branches/OaaS/HeuristicLab.Services.Optimization.Web
- Timestamp:
- 02/19/13 08:46:01 (12 years ago)
- Location:
- branches/OaaS/HeuristicLab.Services.Optimization.Web
- Files:
-
- 14 added
- 5 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] -
branches/OaaS/HeuristicLab.Services.Optimization.Web/HeuristicLab.Services.Optimization.Web.csproj
r9215 r9227 97 97 </ItemGroup> 98 98 <ItemGroup> 99 <Content Include="Content\ajax-loader.gif" /> 100 <Content Include="Content\Datatypemapping.js" /> 99 101 <Content Include="Content\dynatree\dist\jquery.dynatree.min.js" /> 100 102 <Content Include="Content\dynatree\src\skin\icons-rtl.gif" /> … … 105 107 <Content Include="Content\dynatree\src\skin\vline.gif" /> 106 108 <Content Include="Content\ExperimentSupport.js" /> 109 <Compile Include="Binders\AlgorithmJsonAttribute.cs" /> 107 110 <Compile Include="Controllers\AccountController.cs" /> 108 111 <Compile Include="Controllers\AdminController.cs" /> … … 369 372 </None> 370 373 <Content Include="Views\Status\Index.cshtml" /> 374 <Content Include="Views\Experiment\New.cshtml" /> 371 375 </ItemGroup> 372 376 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> -
branches/OaaS/HeuristicLab.Services.Optimization.Web/Models/ExperimentModel.cs
r9215 r9227 3 3 using System.Linq; 4 4 using System.Web; 5 using HeuristicLab.Services.Optimization.ControllerService.Model; 5 6 6 7 namespace HeuristicLab.Services.Optimization.Web.Models { … … 16 17 public Node Experiment { get; set; } 17 18 public string Name { get; set; } 19 } 20 21 public class GetParametersModel { 22 public string Type { get; set; } 23 public Algorithm Algorithm { get; set; } 24 public IList<string> Subnames { get; set; } 18 25 } 19 26 -
branches/OaaS/HeuristicLab.Services.Optimization.Web/Views/Shared/_Layout.cshtml
r9215 r9227 30 30 <script type="text/javascript" src="@Url.Content("~/Content/dynatree/dist/jquery.dynatree.min.js")"></script> 31 31 <script type="text/javascript" src="@Url.Content("~/Content/ExperimentSupport.js")"></script> 32 33 <!-- Experiment Additions --> 34 <script src="@Url.Content("~/Content/Datatypemapping.js")" type="text/javascript"></script> 35 <link href="@Url.Content("~/Content/smartwizard2.0/styles/smart_wizard.css")" rel="stylesheet" type="text/css" /> 36 <script type="text/javascript" src="@Url.Content("~/Content/smartwizard2.0/js/jquery.smartWizard-2.0.min.js")"></script> 32 37 </head> 33 38 <body>
Note: See TracChangeset
for help on using the changeset viewer.