using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using HeuristicLab.Services.Optimization.ControllerService.Parsers; using HeuristicLab.Services.Optimization.ControllerService.Model; using HeuristicLab.Services.Optimization.Web.Models; using System.Web.Security; namespace HeuristicLab.Services.Optimization.Web.Controllers { [Authorize(Roles = "Web User")] public class JobController : BaseController { // // GET: /Job/ public ActionResult Index() { RedirectToLoginIfNecessary("%2fJob"); return View(); } [HttpDelete] public JsonResult Job(string jobId) { var success = ControllerService.withControllerService((service) => { User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string }; return service.DeleteJob(u, jobId); }); return Json(success, JsonRequestBehavior.DenyGet); } [HttpGet] public JsonResult JobList() { var jobs = ControllerService.withControllerService>((service) => { User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string }; return service.GetJobs(u); }); return Json(jobs, JsonRequestBehavior.AllowGet); } /*[HttpGet] public JsonResult Job(string jobId) { var job = ControllerService.withControllerService((service) => { User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string }; return service.GetJob(u, jobId); }); return Json(job, JsonRequestBehavior.AllowGet); }*/ [HttpGet] public ActionResult RunList(string jobId) { var runs = ControllerService.withControllerService>((service) => { User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string }; return service.GetJobResults(u, jobId); }); return Content(AlgorithmConverter.ConvertRunsToJson(runs).ToString(), "application/json", System.Text.Encoding.UTF8); } [HttpGet] public JsonResult VisualExtension(string scenarioId) { var extension = ControllerService.withControllerService((service) => { User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string }; return service.GetVisualExtension(scenarioId); }); return Json(extension, JsonRequestBehavior.AllowGet); } } }