Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OaaS/HeuristicLab.Services.Optimization.Web/Helpers/ControllerService.cs @ 10879

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

#1888:

  • Janitor is now working as expected in Windows Azure
  • Added basic support for experiments (draggable experiments)
  • Added methods to save/read experiments from TableStorage
  • The job status can now be retrieved by using the GetTasks/GetTaskData methods
  • Added a class to convert JSON-objects to Algorithm instances
  • Web page: Added experiment button to navigation
File size: 1.4 KB
RevLine 
[9215]1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Web;
5using System.Web.Mvc;
6using HeuristicLab.Services.Optimization.ControllerService.General;
7using HeuristicLab.Services.Optimization.ControllerService;
8using System.ServiceModel;
9using System.Web.Security;
10using System.ServiceModel.Description;
11
12namespace HeuristicLab.Services.Optimization.Web.Helpers
13{
14    public class ControllerServiceHelper
15    {
16      public static readonly string DEFAULT_CONTROLLER_ENDPOINT = Configuration.ControllerEndpointName;
17
18      public delegate T ControllerServiceDelegate<T>(IControllerService service);
19     
20      private string pw;
21
22      public ControllerServiceHelper(string pw) {
23        this.pw = pw;
24      }
25
26      public bool Valid { get { return pw != null; } }
27
28      public T withControllerService<T>(ControllerServiceDelegate<T> del) {
29        if (!Valid)
30          return default(T);
31
32        using (var cf = new ChannelFactory<IControllerService>(DEFAULT_CONTROLLER_ENDPOINT)) {
33          var credentialBehaviour = cf.Endpoint.Behaviors.Find<ClientCredentials>();
34          credentialBehaviour.UserName.UserName = Membership.GetUser().UserName;         
35          credentialBehaviour.UserName.Password = pw;
36          var controllerProxy = cf.CreateChannel();
37          return del(controllerProxy);
38        }
39      }
40    }
41}
Note: See TracBrowser for help on using the repository browser.