Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OaaS/HeuristicLab.Services.Optimization.Web/Controllers/OptimizationController.cs @ 8506

Last change on this file since 8506 was 8506, checked in by fschoepp, 10 years ago

#1888:

  • Web project now creates custom html for each type we want to enter / display
  • Added endpointConfigurationName to HiveServiceLocator (because Web Project contains more than one endpoint configuration)
  • Removed logging statement from ConfigurationService to prevent exception during failure of loading ConfigurationSettings
  • ApplicationManager: Changed default implementation to WebApplicationManager (instead of LightWeight) for testing purposes within Web Project
  • WebApplicationManager: The application manager which returns plugin descriptors from the currently loaded assemblies (instead of LightweightAppManager)
  • HiveService: Fixed a transaction bug
  • IControllerService: Created a method to dispatch Scenarios to certain IScenarioManager (in this case HiveScenarioManager)
  • Added more mappable types to ControllerModel
  • PlaceholderControllerService dispatches all Scenarios to the HiveScenarioManager
  • Web project now dispatches the scenario to the controller after pressing "Run Job"
File size: 3.5 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Web;
5using System.Web.Mvc;
6using System.ServiceModel;
7using HeuristicLab.Services.Optimization.ControllerService;
8using HeuristicLab.Services.Optimization.ControllerService.Model;
9using System.ServiceModel.Description;
10using System.Web.Security;
11
12namespace HeuristicLab.Services.Optimization.Web.Controllers
13{
14    [Authorize(Roles="Web User")]
15    public class OptimizationController : Controller
16    {
17      public const string DEFAULT_CONTROLLER_ENDPOINT = "WSHttpBinding_IControllerService";
18        //
19        // GET: /Optimization/       
20
21        public ActionResult Index()
22        {
23          IEnumerable<OptimizationScenario> scenarios;
24          using (var cf = new ChannelFactory<IControllerService>(OptimizationController.DEFAULT_CONTROLLER_ENDPOINT)) {
25            var credentialBehaviour = cf.Endpoint.Behaviors.Find<ClientCredentials>();
26            credentialBehaviour.UserName.UserName = Membership.GetUser().UserName;
27            credentialBehaviour.UserName.Password = Session["pw"] as string;
28            var controllerProxy = cf.CreateChannel();
29            scenarios = controllerProxy.GetOptimizationScenarios();
30          }
31          return View(scenarios);
32        }
33
34        public ActionResult ProblemParameters(string scenario) {
35          OptimizationScenario optScenario;         
36          using (var cf = new ChannelFactory<IControllerService>(OptimizationController.DEFAULT_CONTROLLER_ENDPOINT)) {
37            var credentialBehaviour = cf.Endpoint.Behaviors.Find<ClientCredentials>();
38            credentialBehaviour.UserName.UserName = Membership.GetUser().UserName;
39            credentialBehaviour.UserName.Password = Session["pw"] as string;
40            var controllerProxy = cf.CreateChannel();
41            optScenario = controllerProxy.GetOptimizationScenarioByName(scenario);
42            Session["scenario"] = optScenario;
43          }
44          return View(optScenario.InputParameters);
45        }
46
47        [HttpPost]
48        public ActionResult ProblemParameters(InputParameters parameters) {
49          if (ModelState.IsValid) {
50            return RedirectToAction("AlgorithmParameters", parameters);
51          }
52          return View(parameters);       
53        }
54
55        public ActionResult AlgorithmParameters() {
56          return View((Session["scenario"] as OptimizationScenario).AlgorithmParameters);
57        }
58
59        [HttpPost]
60        public ActionResult AlgorithmParameters(AlgorithmParameters parameters) {
61          if (ModelState.IsValid) {
62            return RedirectToAction("ScheduleJob");
63          }
64          return View(parameters);
65        }
66
67        public ActionResult ScheduleJob() {
68          return View(Session["scenario"]);
69        }
70
71        [HttpPost]
72        public ActionResult ScheduleJob(OptimizationScenario scenario) {
73          using (var cf = new ChannelFactory<IControllerService>(OptimizationController.DEFAULT_CONTROLLER_ENDPOINT)) {
74            var credentialBehaviour = cf.Endpoint.Behaviors.Find<ClientCredentials>();
75            credentialBehaviour.UserName.UserName = Membership.GetUser().UserName;
76            credentialBehaviour.UserName.Password = Session["pw"] as string;
77            var controllerProxy = cf.CreateChannel();
78            controllerProxy.ScheduleOptimizationScenario(Session["scenario"] as OptimizationScenario);
79          }
80          return RedirectToAction("Index");
81        }
82    }
83}
Note: See TracBrowser for help on using the repository browser.