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.Web.Models;
|
---|
7 | using HeuristicLab.Services.Optimization.Web.Helpers;
|
---|
8 | using System.Web.Security;
|
---|
9 | using HeuristicLab.Services.Optimization.ControllerService.Model;
|
---|
10 |
|
---|
11 | namespace HeuristicLab.Services.Optimization.Web.Controllers
|
---|
12 | {
|
---|
13 | public class StatusController : Controller {
|
---|
14 | private ControllerServiceHelper ControllerService {
|
---|
15 | get {
|
---|
16 | var helper = new ControllerServiceHelper(Session["pw"] as string);
|
---|
17 | if (!helper.Valid) {
|
---|
18 | Response.Redirect("/Account/Logon?ReturnUrl=%2fStatus");
|
---|
19 | }
|
---|
20 | return helper;
|
---|
21 | }
|
---|
22 | }
|
---|
23 |
|
---|
24 | //
|
---|
25 | // GET: /Status/
|
---|
26 |
|
---|
27 | public ActionResult Index() {
|
---|
28 | var statModel = ControllerService.withControllerService<StatusModel>((service) => {
|
---|
29 | var model = new StatusModel();
|
---|
30 | User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string };
|
---|
31 | model.Jobs = service.GetJobs(u).ToList();
|
---|
32 | return model;
|
---|
33 | });
|
---|
34 | return View(statModel);
|
---|
35 | }
|
---|
36 |
|
---|
37 | [HttpGet]
|
---|
38 | public JsonResult GetTasks(string jobId) {
|
---|
39 | var job = ControllerService.withControllerService<Job>((service) => {
|
---|
40 | User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string };
|
---|
41 | return service.GetTasks(u, jobId);
|
---|
42 | });
|
---|
43 |
|
---|
44 | return Json(job, JsonRequestBehavior.AllowGet);
|
---|
45 | }
|
---|
46 |
|
---|
47 | [HttpGet]
|
---|
48 | public JsonResult GetTaskData(string jobId, string taskId) {
|
---|
49 | var t1 = ControllerService.withControllerService<Task>((service) => {
|
---|
50 | User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string };
|
---|
51 | return service.GetTaskData(u, jobId, taskId);
|
---|
52 | });
|
---|
53 | return Json(t1, JsonRequestBehavior.AllowGet);
|
---|
54 | }
|
---|
55 | }
|
---|
56 | }
|
---|