Free cookie consent management tool by TermsFeed Policy Generator

source: branches/1888_OaaS/HeuristicLab.Services.Optimization.Web/Controllers/JobController.cs @ 18066

Last change on this file since 18066 was 9395, checked in by fschoepp, 12 years ago

#1888:

  • Added visual extensions (dynamic JavaScript) which will be used to render additional result parameters specific to scenarios (e. g. create a graphical representation of a TSP).
  • Added relationship between jobs and experiments (otherwise, it's not possible to get the job's experiment).
  • Updated Admin page to allow removal/addition of visual extensions.
  • Added back-end logic to store/retrieve/delete visual extensions.
  • Added visual extension functionality to the JavaScript views/controllers (job.*.js).
  • Added tsp.js which is a visual extension for the "Genetic Algorithm - TSP" scenario. It adds a graphical representation of the TSP (just like the C# version does) to the results.
File size: 2.7 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Web;
5using System.Web.Mvc;
6using HeuristicLab.Services.Optimization.ControllerService.Parsers;
7using HeuristicLab.Services.Optimization.ControllerService.Model;
8using HeuristicLab.Services.Optimization.Web.Models;
9
10using System.Web.Security;
11
12namespace HeuristicLab.Services.Optimization.Web.Controllers
13{
14    [Authorize(Roles = "Web User")]
15    public class JobController : BaseController
16    {
17      //
18      // GET: /Job/   
19      public ActionResult Index() {
20        RedirectToLoginIfNecessary("%2fJob");
21        return View();
22      }
23
24      [HttpDelete]
25      public JsonResult Job(string jobId) {
26        var success = ControllerService.withControllerService<bool>((service) => {
27          User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string };
28          return service.DeleteJob(u, jobId);
29        });
30        return Json(success, JsonRequestBehavior.DenyGet);
31      }
32
33      [HttpGet]
34      public JsonResult JobList() {
35        var jobs = ControllerService.withControllerService<IEnumerable<Job>>((service) => {
36          User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string };
37          return service.GetJobs(u);
38        });
39        return Json(jobs, JsonRequestBehavior.AllowGet);
40      }
41
42      /*[HttpGet]
43      public JsonResult Job(string jobId) {
44        var job = ControllerService.withControllerService<Job>((service) => {
45          User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string };
46          return service.GetJob(u, jobId);
47        });
48        return Json(job, JsonRequestBehavior.AllowGet);
49      }*/
50
51      [HttpGet]
52      public ActionResult RunList(string jobId) {
53        var runs = ControllerService.withControllerService<IList<Run>>((service) => {
54          User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string };
55          return service.GetJobResults(u, jobId);
56        });
57        return Content(AlgorithmConverter.ConvertRunsToJson(runs).ToString(), "application/json", System.Text.Encoding.UTF8);
58      }
59
60      [HttpGet]
61      public JsonResult VisualExtension(string scenarioId) {
62        var extension = ControllerService.withControllerService<VisualExtension>((service) => {
63          User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string };
64          return service.GetVisualExtension(scenarioId);
65        });
66        return Json(extension, JsonRequestBehavior.AllowGet);
67      }
68    }
69}
Note: See TracBrowser for help on using the repository browser.