1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Web;
|
---|
5 | using System.Web.Mvc;
|
---|
6 | using System.ServiceModel;
|
---|
7 | using HeuristicLab.Services.Optimization.ControllerService;
|
---|
8 | using HeuristicLab.Services.Optimization.ControllerService.Model;
|
---|
9 | using System.ServiceModel.Description;
|
---|
10 | using System.Web.Security;
|
---|
11 |
|
---|
12 | namespace 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 | }
|
---|