Changeset 9215 for branches/OaaS/HeuristicLab.Services.Optimization.Web/Controllers/AdminController.cs
- Timestamp:
- 02/11/13 10:15:52 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OaaS/HeuristicLab.Services.Optimization.Web/Controllers/AdminController.cs
r8958 r9215 13 13 using System.Web.Security; 14 14 using HeuristicLab.Services.Optimization.ControllerService.Model; 15 using HeuristicLab.Services.Optimization.Web.Helpers; 15 16 16 17 namespace HeuristicLab.Services.Optimization.Web.Controllers … … 19 20 public class AdminController : Controller 20 21 { 21 public delegate T ControllerServiceDelegate<T>(IControllerService service); 22 public delegate void ControllerServiceDelegate(IControllerService service); 23 24 public T withControllerService<T>(ControllerServiceDelegate<T> del) { 25 using (var cf = new ChannelFactory<IControllerService>(OptimizationController.DEFAULT_CONTROLLER_ENDPOINT)) { 26 var credentialBehaviour = cf.Endpoint.Behaviors.Find<ClientCredentials>(); 27 credentialBehaviour.UserName.UserName = Membership.GetUser().UserName; 28 credentialBehaviour.UserName.Password = Session["pw"] as string; 29 var controllerProxy = cf.CreateChannel(); 30 return del(controllerProxy); 22 private ControllerServiceHelper ControllerService { 23 get { 24 var helper = new ControllerServiceHelper(Session["pw"] as string); 25 if (!helper.Valid) { 26 Response.Redirect("/Account/Logon"); 27 } 28 return helper; 29 } 31 30 } 32 }33 34 public void withControllerService(ControllerServiceDelegate del) {35 using (var cf = new ChannelFactory<IControllerService>(OptimizationController.DEFAULT_CONTROLLER_ENDPOINT)) {36 var credentialBehaviour = cf.Endpoint.Behaviors.Find<ClientCredentials>();37 credentialBehaviour.UserName.UserName = Membership.GetUser().UserName;38 credentialBehaviour.UserName.Password = Session["pw"] as string;39 var controllerProxy = cf.CreateChannel();40 del(controllerProxy);41 }42 }43 31 // 44 32 // GET: /Admin/ … … 46 34 public ActionResult Index() 47 35 { 48 var names = withControllerService<IEnumerable<string>>((service) => {36 var names = ControllerService.withControllerService<IEnumerable<string>>((service) => { 49 37 User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string }; 50 38 return service.GetOptimizationScenarioNames(); … … 68 56 } 69 57 70 var ok = withControllerService<bool>((service) => {58 var ok = ControllerService.withControllerService<bool>((service) => { 71 59 OptimizationModel model = new OptimizationModel(); 72 60 User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string }; … … 78 66 79 67 public ActionResult DeleteScenario(string id) { 80 withControllerService<bool>((service) => {68 ControllerService.withControllerService<bool>((service) => { 81 69 User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string }; 82 70 return service.DeleteHiveScenario(u, id);
Note: See TracChangeset
for help on using the changeset viewer.