1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Web;
|
---|
5 | using System.Web.Mvc;
|
---|
6 | using HeuristicLab.Services.Optimization.ControllerService.Parsers;
|
---|
7 | using HeuristicLab.Services.Optimization.ControllerService.Model;
|
---|
8 | using HeuristicLab.Services.Optimization.Web.Models;
|
---|
9 |
|
---|
10 | using System.Web.Security;
|
---|
11 |
|
---|
12 | namespace 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 | }
|
---|