Free cookie consent management tool by TermsFeed Policy Generator

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

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

#1888:

  • Created a project which contains the back-end controller for the Optimization WebSite
  • Added a WCF-back-end-controller which generates all available optimization problems (currently in-memory solution: PlaceholderControllerService.cs)
  • Created a WebRole using ASP.NET MVC 3 for the Optimization Web Site
  • WebSite authenticates users with the HeuristicLab.Authentication membership provider and database
  • WebSite crawls and displays all available optimization scenarios by using the WCF-back-end controller (test with: http://localhost:.../optimization)
File size: 2.2 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          }
43          return View(optScenario);
44        }
45
46        [HttpPost]
47        public ActionResult ProblemParameters(OptimizationScenario scenario) {
48          if (ModelState.IsValid) {
49            // store it... maybe
50          }
51          return View(scenario);
52        }
53
54    }
55}
Note: See TracBrowser for help on using the repository browser.