using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using System.ServiceModel; using HeuristicLab.Services.Optimization.ControllerService; using HeuristicLab.Services.Optimization.ControllerService.Model; using System.ServiceModel.Description; using System.Web.Security; namespace HeuristicLab.Services.Optimization.Web.Controllers { [Authorize(Roles="Web User")] public class OptimizationController : Controller { public const string DEFAULT_CONTROLLER_ENDPOINT = "WSHttpBinding_IControllerService"; // // GET: /Optimization/ public ActionResult Index() { IEnumerable scenarios; using (var cf = new ChannelFactory(OptimizationController.DEFAULT_CONTROLLER_ENDPOINT)) { var credentialBehaviour = cf.Endpoint.Behaviors.Find(); credentialBehaviour.UserName.UserName = Membership.GetUser().UserName; credentialBehaviour.UserName.Password = Session["pw"] as string; var controllerProxy = cf.CreateChannel(); scenarios = controllerProxy.GetOptimizationScenarios(); } return View(scenarios); } public ActionResult ProblemParameters(string scenario) { OptimizationScenario optScenario; using (var cf = new ChannelFactory(OptimizationController.DEFAULT_CONTROLLER_ENDPOINT)) { var credentialBehaviour = cf.Endpoint.Behaviors.Find(); credentialBehaviour.UserName.UserName = Membership.GetUser().UserName; credentialBehaviour.UserName.Password = Session["pw"] as string; var controllerProxy = cf.CreateChannel(); optScenario = controllerProxy.GetOptimizationScenarioByName(scenario); } return View(optScenario); } [HttpPost] public ActionResult ProblemParameters(OptimizationScenario scenario) { if (ModelState.IsValid) { // store it... maybe } return View(scenario); } } }