Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/11/13 10:15:52 (11 years ago)
Author:
fschoepp
Message:

#1888:

  • Janitor is now working as expected in Windows Azure
  • Added basic support for experiments (draggable experiments)
  • Added methods to save/read experiments from TableStorage
  • The job status can now be retrieved by using the GetTasks/GetTaskData methods
  • Added a class to convert JSON-objects to Algorithm instances
  • Web page: Added experiment button to navigation
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/OaaS/HeuristicLab.Services.Optimization.Web/Controllers/OptimizationController.cs

    r9166 r9215  
    1111using HeuristicLab.Services.Optimization.Web.Models;
    1212using HeuristicLab.Services.Optimization.ControllerService.General;
     13using HeuristicLab.Services.Optimization.Web.Helpers;
    1314
    1415namespace HeuristicLab.Services.Optimization.Web.Controllers
     
    1617    [Authorize(Roles="Web User")]
    1718    public class OptimizationController : Controller
    18     {
    19       public static readonly string DEFAULT_CONTROLLER_ENDPOINT = Configuration.ControllerEndpointName;
     19    {     
     20        private ControllerServiceHelper ControllerService {
     21          get {
     22            var helper = new ControllerServiceHelper(Session["pw"] as string);
     23            if (!helper.Valid) {
     24              Response.Redirect("/Account/Logon?ReturnUrl=%2fOptimization");
     25            }
     26            return helper;
     27          }
     28        }
    2029
    21       public delegate T ControllerServiceDelegate<T>(IControllerService service);
    22       public delegate void ControllerServiceDelegate(IControllerService service);
    23 
    24       public T withControllerService<T>(ControllerServiceDelegate<T> del) {
    25         if (Session["pw"] == null)
    26           Response.Redirect("/Account/Logon");
    27 
    28         using (var cf = new ChannelFactory<IControllerService>(DEFAULT_CONTROLLER_ENDPOINT)) {
    29           var credentialBehaviour = cf.Endpoint.Behaviors.Find<ClientCredentials>();
    30           credentialBehaviour.UserName.UserName = Membership.GetUser().UserName;
    31           credentialBehaviour.UserName.Password = Session["pw"] as string;
    32           var controllerProxy = cf.CreateChannel();
    33           return del(controllerProxy);
    34         }
    35       }
    36 
    37       public void withControllerService(ControllerServiceDelegate del) {
    38         if (Session["pw"] == null)
    39           Response.Redirect("/Account/Logon");
    40 
    41         using (var cf = new ChannelFactory<IControllerService>(DEFAULT_CONTROLLER_ENDPOINT)) {         
    42           var credentialBehaviour = cf.Endpoint.Behaviors.Find<ClientCredentials>();
    43           credentialBehaviour.UserName.UserName = Membership.GetUser().UserName;
    44           credentialBehaviour.UserName.Password = Session["pw"] as string;         
    45           var controllerProxy = cf.CreateChannel();
    46           del(controllerProxy);
    47         }
    48       }
    4930        //
    50         // GET: /Optimization/       
    51 
     31        // GET: /Optimization/   
    5232        public ActionResult Index()
    5333        {
    54           var optModel = withControllerService<OptimizationModel>((service) => {
     34          var optModel = ControllerService.withControllerService<OptimizationModel>((service) => {
    5535            OptimizationModel model = new OptimizationModel();
    5636            model.Scenarios = service.GetOptimizationScenarios();
     
    5838            model.Jobs = service.GetJobs(u);
    5939            return model;
    60           });
     40          });         
    6141          return View(optModel);
    6242        }
    6343
    6444        public ActionResult ProblemParameters(string scenario) {
    65           var optScenario = withControllerService<OptimizationScenario>((service) => {
     45          var optScenario = ControllerService.withControllerService<OptimizationScenario>((service) => {
    6646            return service.GetOptimizationScenarioByName(scenario);
    6747          });
     
    7757
    7858        public ActionResult JobDetails(string jobId) {
    79           Job job = withControllerService<Job>((service) => {
     59          Job job = ControllerService.withControllerService<Job>((service) => {
    8060            User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string };
    8161            return service.GetJob(u, jobId);
    8262          });
    83           var runs = withControllerService<IList<Run>>((service) => {
     63          var runs = ControllerService.withControllerService<IList<Run>>((service) => {
    8464            User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string };
    8565            return service.GetJobResults(u, jobId);
     
    9272        [HttpPost]
    9373        public ActionResult JobDetails(Job job) {
    94           withControllerService((service) => {
     74          ControllerService.withControllerService<bool>((service) => {
    9575            User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string };
    96             service.DeleteJob(u, job.Id);
     76            return service.DeleteJob(u, job.Id);
    9777          });
    9878          return RedirectToAction("Index");
     
    125105        [HttpPost]
    126106        public ActionResult ScheduleJob(ScheduleJobModel jobModel) {
    127           using (var cf = new ChannelFactory<IControllerService>(OptimizationController.DEFAULT_CONTROLLER_ENDPOINT)) {
    128             var credentialBehaviour = cf.Endpoint.Behaviors.Find<ClientCredentials>();
    129             credentialBehaviour.UserName.UserName = Membership.GetUser().UserName;
    130             credentialBehaviour.UserName.Password = Session["pw"] as string;
    131             var controllerProxy = cf.CreateChannel();
     107          var success = ControllerService.withControllerService<bool>((service) => {
    132108            User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string };
    133109            var scenario = Session["scenario"] as OptimizationScenario;
    134110            var details = new JobExecutionDetails() { Group = jobModel.Group, JobTitle = jobModel.Name, Repititions = jobModel.Repetitions };
    135             controllerProxy.ScheduleOptimizationScenario(u, scenario, details);
    136           }
     111            return service.ScheduleOptimizationScenario(u, scenario, details);
     112          });
    137113          return RedirectToAction("Index");
    138114        }
Note: See TracChangeset for help on using the changeset viewer.