Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OaaS/HeuristicLab.Services.Optimization.Web/Models/OptimizationModels.cs @ 9070

Last change on this file since 9070 was 9062, checked in by fschoepp, 12 years ago

#1888:
Backend changes:

  • Simplified job state detection (only one hive call will be made to detect all states now, instead of one additional call per job)
  • Reorganized classes (moved model classes into Model folder)

Website changes:

  • Website now heavily uses JavaScript to achieve better user experience
  • JavaScript degrades gracefully, except for plots
  • Tables: Added jquery-datatable-plugin to extend tables (pagination + search functionality)
  • OaaS-Website now uses the design of the HL websites (found in WebApplication branch)
  • Added jqplot to render zoomable line plots for HL-Datatables
  • Styling.js: Plots will be generated by using an ajax call; additional jquery-styling occurs within this file.
  • Added jquery-ui-1.9.2 which is capable of handling/rendering tabs, accordions and resizers.
File size: 2.8 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Web;
5using System.Web.Mvc;
6using HeuristicLab.Services.Optimization.ControllerService.Model;
7
8namespace HeuristicLab.Services.Optimization.Web.Models {
9
10  public class OptimizationModel {
11    public IEnumerable<OptimizationScenario> Scenarios { get; set; }
12    public IEnumerable<Job> Jobs { get; set; }
13    public Operation Operation { get; set; }
14  }
15
16  public class JobDetailsModel {
17    public IList<Run> Runs { get; set; }
18    public Job Job { get; set; }
19  }
20
21  public enum Operation {
22    DeleteJob
23  }
24
25  public class ProblemParametersModelBinder : IModelBinder {
26    public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) {
27      var scenario = controllerContext.HttpContext.Session["scenario"] as OptimizationScenario;
28      foreach (var key in controllerContext.RequestContext.HttpContext.Request.Form.AllKeys) {
29        var value = bindingContext.ValueProvider.GetValue(key);
30        string realKey = key;
31        string realValue = value.AttemptedValue;
32
33        if (key.Contains("_")) {
34          var tableEntry = key.Split('_');
35          realKey = tableEntry[0];
36          //var param2 = (from par in scenario.InputParameters.Items where par.Name == tableEntry[0] select par).FirstOrDefault();
37          realValue = "";
38          for (int i = 1; i < tableEntry.Length; i++) {
39            realValue += tableEntry[i] + ":";
40          }
41          realValue += value.AttemptedValue;
42        }
43        var param = (from par in scenario.InputParameters.Items where par.Value.Name == realKey select par).FirstOrDefault();
44        if (param != null && !param.Value.TrySetFromString(realValue)) {
45          bindingContext.ModelState.AddModelError(bindingContext.ModelName, new Exception(string.Format("Unable to parse {0} into destination type {1}", value, param.Type)));
46        }
47      }
48      return scenario.InputParameters;
49    }
50  }
51
52  public class AlgorithmParametersModelBinder : IModelBinder {
53    public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) {
54      var scenario = controllerContext.HttpContext.Session["scenario"] as OptimizationScenario;
55      foreach (var key in controllerContext.RequestContext.HttpContext.Request.Form.AllKeys) {
56        var value = bindingContext.ValueProvider.GetValue(key);
57        var param = (from par in scenario.AlgorithmParameters.Items where par.Value.Name == key select par).FirstOrDefault();
58        if (param != null && !param.Value.TrySetFromString(value.AttemptedValue)) {
59          bindingContext.ModelState.AddModelError(bindingContext.ModelName, new Exception(string.Format("Unable to parse {0} into destination type {1}", value, param.Type)));
60        }
61      }
62      return scenario.AlgorithmParameters;
63    }
64  }
65}
Note: See TracBrowser for help on using the repository browser.