Index: branches/OaaS/HeuristicLab.Clients.Hive.JobManager/3.3/HeuristicLab.Clients.Hive.JobManager-3.3.csproj
===================================================================
--- branches/OaaS/HeuristicLab.Clients.Hive.JobManager/3.3/HeuristicLab.Clients.Hive.JobManager-3.3.csproj	(revision 8956)
+++ branches/OaaS/HeuristicLab.Clients.Hive.JobManager/3.3/HeuristicLab.Clients.Hive.JobManager-3.3.csproj	(revision 8958)
@@ -82,4 +82,6 @@
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="HeuristicLab.Analysis-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
+    <Reference Include="HeuristicLab.Visualization.ChartControlsExtensions-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
     <Reference Include="System" />
     <Reference Include="System.Configuration" />
@@ -149,4 +151,8 @@
   </ItemGroup>
   <ItemGroup>
+    <ProjectReference Include="..\..\HeuristicLab.Analysis.Views\3.3\HeuristicLab.Analysis.Views-3.3.csproj">
+      <Project>{76945D76-CA61-4147-9DC2-0ACDCDDF87F9}</Project>
+      <Name>HeuristicLab.Analysis.Views-3.3</Name>
+    </ProjectReference>
     <ProjectReference Include="..\..\HeuristicLab.Clients.Hive.Views\3.3\HeuristicLab.Clients.Hive.Views-3.3.csproj">
       <Project>{E1D6C801-892A-406A-B606-F158E36DD3C3}</Project>
@@ -224,4 +230,9 @@
       <Private>False</Private>
     </ProjectReference>
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="Views\RefreshableHiveJobView.resx">
+      <DependentUpon>RefreshableHiveJobView.cs</DependentUpon>
+    </EmbeddedResource>
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Index: branches/OaaS/HeuristicLab.Clients.Hive.Slave/3.3/HeuristicLab.Clients.Hive.Slave-3.3.csproj
===================================================================
--- branches/OaaS/HeuristicLab.Clients.Hive.Slave/3.3/HeuristicLab.Clients.Hive.Slave-3.3.csproj	(revision 8956)
+++ branches/OaaS/HeuristicLab.Clients.Hive.Slave/3.3/HeuristicLab.Clients.Hive.Slave-3.3.csproj	(revision 8958)
@@ -167,5 +167,7 @@
     <Compile Include="TraceCom.cs" />
     <Compile Include="WcfService.cs" />
-    <None Include="app.config" />
+    <None Include="app.config">
+      <SubType>Designer</SubType>
+    </None>
     <None Include="Plugin.cs.frame" />
     <Compile Include="Plugin.cs" />
Index: branches/OaaS/HeuristicLab.PluginInfrastructure/3.3/Manager/PluginValidator.cs
===================================================================
--- branches/OaaS/HeuristicLab.PluginInfrastructure/3.3/Manager/PluginValidator.cs	(revision 8956)
+++ branches/OaaS/HeuristicLab.PluginInfrastructure/3.3/Manager/PluginValidator.cs	(revision 8958)
@@ -488,4 +488,11 @@
     }
 
+    private string AssemblyDirectory(Assembly assem) {
+      string codeBase = assem.CodeBase;
+      UriBuilder uri = new UriBuilder(codeBase);
+      string path = Uri.UnescapeDataString(uri.Path);
+      return Path.GetFullPath(path);      
+    }
+
 
     private bool IsAnyDependencyDisabled(PluginDescription descr, List<PluginDescription> disabledPlugins) {
@@ -512,5 +519,6 @@
             try {
               string assemblyName = (from assembly in AppDomain.CurrentDomain.ReflectionOnlyGetAssemblies()
-                                     where string.Equals(Path.GetFullPath(assembly.Location), Path.GetFullPath(assemblyLocation), StringComparison.CurrentCultureIgnoreCase)
+                                     where string.Equals(Path.GetFullPath(assembly.Location), Path.GetFullPath(assemblyLocation), StringComparison.CurrentCultureIgnoreCase) ||
+                                           string.Equals(AssemblyDirectory(assembly), Path.GetFullPath(assemblyLocation), StringComparison.CurrentCultureIgnoreCase)
                                      select assembly.FullName).Single();
               // now load the assemblies into the execution context  
Index: branches/OaaS/HeuristicLab.PluginInfrastructure/3.3/WebApplicationManager.cs
===================================================================
--- branches/OaaS/HeuristicLab.PluginInfrastructure/3.3/WebApplicationManager.cs	(revision 8956)
+++ branches/OaaS/HeuristicLab.PluginInfrastructure/3.3/WebApplicationManager.cs	(revision 8958)
@@ -88,4 +88,12 @@
     }
 
+    static private string AssemblyDirectory {
+      get {
+        string codeBase = Assembly.GetExecutingAssembly().CodeBase;
+        UriBuilder uri = new UriBuilder(codeBase);
+        string path = Uri.UnescapeDataString(uri.Path);
+        return Path.GetDirectoryName(path);
+      }
+    }
     // find all types implementing IPlugin in the reflectionOnlyAssemblies and create a list of plugin descriptions
     // the dependencies in the plugin descriptions are not yet set correctly because we need to create
@@ -93,6 +101,32 @@
     private List<PluginDescription> GatherPluginDescriptions()
     {
-      List<PluginDescription> pluginDescriptions = new List<PluginDescription>();
-      foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
+      /*List<PluginDescription> pluginDescriptions = new List<PluginDescription>();
+
+      // load all assemblies that are available in the project folders
+      var loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies().ToList();
+      IList<string> loadedPaths = new List<string>();
+      foreach (var asm in loadedAssemblies) {
+        try {
+          loadedPaths.Add(asm.Location);
+        }
+        catch (Exception ex) {
+        }
+      }*/
+      /*var assembliePaths = from location in loadedAssemblies                           
+                           select location.Location;
+
+      var loadedPaths = loadedAssemblies.Select(a => a.Location).ToArray();*/
+      var pv = new PluginValidator() { PluginDir = AssemblyDirectory };
+      pv.DiscoverAndCheckPlugins();
+      return pv.Plugins.ToList();
+      /*var pluginManager = new PluginManager(AssemblyDirectory);
+      pluginManager.DiscoverAndCheckPlugins();
+      return pluginManager.Plugins.ToList();*/
+
+      /*var referencedPaths = Directory.GetFiles(AssemblyDirectory, "*.dll");
+      var toLoad = referencedPaths.Where(r => !loadedPaths.Contains(r, StringComparer.InvariantCultureIgnoreCase)).ToList();
+      toLoad.ForEach(path => loadedAssemblies.Add(AppDomain.CurrentDomain.Load(AssemblyName.GetAssemblyName(path))));
+      
+      foreach (Assembly assembly in loadedAssemblies)
       {
         // GetExportedTypes throws FileNotFoundException when a referenced assembly
@@ -106,4 +140,6 @@
                                            where !t.IsAbstract && t.GetInterfaces().Any(x => x.AssemblyQualifiedName == typeof(IPlugin).AssemblyQualifiedName)
                                            select GetPluginDescription(t);
+
+          // TODO: Also load all plugin descriptors from assemblies liying in the app domain folder!!!!!
           pluginDescriptions.AddRange(assemblyPluginDescriptions);
         }
@@ -122,5 +158,5 @@
         }
       }
-      return pluginDescriptions;
+      return pluginDescriptions;*/
     }
 
Index: branches/OaaS/HeuristicLab.Services.Optimization.Controller/Azure/DAL.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Controller/Azure/DAL.cs	(revision 8958)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Controller/Azure/DAL.cs	(revision 8958)
@@ -0,0 +1,132 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Services.Optimization.ControllerService.Interfaces;
+using Microsoft.WindowsAzure;
+using Microsoft.WindowsAzure.StorageClient;
+
+namespace HeuristicLab.Services.Optimization.ControllerService.Azure {
+  public static class AzureConstants {
+    public static readonly string SCENARIO_TABLE = "Scenario";
+    public static readonly string SCENARIO_BLOB_CONTAINER = "scenario";
+    public static readonly string CLOUD_SETTINGS_KEY = "Cloudia.WindowsAzure.Storage";
+  }
+
+  public class ScenarioDao : IScenarioDao {    
+    public CloudTableClient TableClient { get; set; }
+
+    public bool Add(ScenarioEntity entity) {
+      TableServiceContext serviceContext = TableClient.GetDataServiceContext();
+      TableClient.CreateTableIfNotExist(AzureConstants.SCENARIO_TABLE);
+      ScenarioEntity dbEntity = (from e in serviceContext.CreateQuery<ScenarioEntity>(AzureConstants.SCENARIO_TABLE)
+                               where e.RowKey == entity.RowKey
+                               select e).FirstOrDefault();
+      if (dbEntity != null)
+        return false;
+
+      serviceContext.AddObject(AzureConstants.SCENARIO_TABLE, entity);
+      serviceContext.SaveChanges();
+      return true;
+    }
+
+    public bool DeleteByName(string scenarioName) {
+      TableServiceContext serviceContext = TableClient.GetDataServiceContext();
+      TableClient.CreateTableIfNotExist(AzureConstants.SCENARIO_TABLE);
+      ScenarioEntity entity = (from e in serviceContext.CreateQuery<ScenarioEntity>(AzureConstants.SCENARIO_TABLE)
+                               where e.RowKey == scenarioName
+                               select e).FirstOrDefault();
+      if (entity == null)
+        return false;
+
+      serviceContext.DeleteObject(entity);
+      serviceContext.SaveChangesWithRetries();
+      return true;
+    }
+
+    public ScenarioEntity FindByName(string scenarioName) {
+      TableServiceContext serviceContext = TableClient.GetDataServiceContext();
+      TableClient.CreateTableIfNotExist(AzureConstants.SCENARIO_TABLE);
+      ScenarioEntity entity = (from e in serviceContext.CreateQuery<ScenarioEntity>(AzureConstants.SCENARIO_TABLE)
+                               where e.RowKey == scenarioName
+                               select e).FirstOrDefault();
+      return entity;
+    }
+
+
+    public IEnumerable<ScenarioEntity> GetAllEntities() {
+      TableServiceContext serviceContext = TableClient.GetDataServiceContext();
+      TableClient.CreateTableIfNotExist(AzureConstants.SCENARIO_TABLE);
+      return (from e in serviceContext.CreateQuery<ScenarioEntity>(AzureConstants.SCENARIO_TABLE)
+             select e).AsEnumerable();
+    }
+  }
+
+  public class BlobDao : IBlobDao {
+    public CloudBlobClient BlobClient { get; set; }
+
+    public bool Add(StringEntry entry) {
+      CloudBlobContainer container = BlobClient.GetContainerReference(AzureConstants.SCENARIO_BLOB_CONTAINER);
+      container.CreateIfNotExist();
+      var blob = container.GetBlobReference(entry.Key);
+      blob.UploadText(entry.Text);
+      return true;
+    }
+
+    public bool DeleteByKey(string entryKey) {
+      CloudBlobContainer container = BlobClient.GetContainerReference(AzureConstants.SCENARIO_BLOB_CONTAINER);
+      container.CreateIfNotExist();
+      var blob = container.GetBlobReference(entryKey);
+      return blob.DeleteIfExists();
+    }
+
+    public StringEntry FindByKey(string entryKey) {
+      CloudBlobContainer container = BlobClient.GetContainerReference(AzureConstants.SCENARIO_BLOB_CONTAINER);
+      container.CreateIfNotExist();
+      var blob = container.GetBlobReference(entryKey);
+      return new StringEntry() { Key = entryKey, Text = blob.DownloadText() };      
+    }
+  }
+
+  public class AzureDataAccessLayer : IDataAccessLayer {
+    private IScenarioDao scenarioDao;
+    private IBlobDao blobDao;
+
+    private CloudStorageAccount storageAccount;
+
+    private CloudStorageAccount StorageAccount {
+      get {
+        if (storageAccount == null) {
+          storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting(AzureConstants.CLOUD_SETTINGS_KEY));
+        }
+        return storageAccount; 
+      }      
+    }
+
+    public IScenarioDao ScenarioDao {
+      get {
+        if (scenarioDao == null) {
+          scenarioDao = new ScenarioDao();
+        }
+        return scenarioDao;
+      }
+    }
+
+    public IBlobDao BlobDao {
+      get {
+        if (blobDao == null) {
+          blobDao = new BlobDao();
+        }
+        return blobDao;
+      }
+    }
+
+    public IScenarioDao CreateScenarioDao() {
+      return new ScenarioDao() { TableClient = StorageAccount.CreateCloudTableClient() };
+    }
+
+    public IBlobDao CreateBlobDao() {
+      return new BlobDao() { BlobClient = StorageAccount.CreateCloudBlobClient() };
+    }
+  }
+}
Index: branches/OaaS/HeuristicLab.Services.Optimization.Controller/HL/HLMapper.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Controller/HL/HLMapper.cs	(revision 8958)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Controller/HL/HLMapper.cs	(revision 8958)
@@ -0,0 +1,68 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Data;
+using HeuristicLab.Services.Optimization.ControllerService.Model;
+using HeuristicLab.Optimization;
+using HeuristicLab.Encodings.PermutationEncoding;
+using HeuristicLab.Core;
+
+namespace HeuristicLab.Services.Optimization.ControllerService {
+  public interface IScenarioMapper {
+    void MapScenario(OptimizationScenario scenario, IAlgorithm algorithm);
+  }
+
+  public static class HLMapper {
+    public static DoubleValue ConvertToDoubleValue(Parameter parameter) {
+      var dv = parameter.Value as DecimalValue;
+      return new DoubleValue(dv.Value);      
+    }
+
+    public static Permutation ConvertToPermutation(Parameter parameter) {
+      double[] input = (parameter.Value as DecimalVector).Value;
+      int[] arr = new int[input.Length];
+      for (int i = 0; i < input.Length; i++) {
+        arr[i] = Convert.ToInt32(input[i]);
+      }
+      var valueObj = new HeuristicLab.Encodings.PermutationEncoding.Permutation(Encodings.PermutationEncoding.PermutationTypes.RelativeUndirected, arr);
+      return valueObj;
+    }
+
+    public static DoubleMatrix ConvertToDoubleMatrix(Parameter parameter) {
+      var matrix = parameter.Value as DecimalMatrix;
+      // TODO: Check for empty matrices
+      double[,] data = new double[matrix.Value.Length, matrix.Value[0].Length];
+      for (int i=0; i < matrix.Value.Length; i++) {
+        for (int j=0; j < matrix.Value[i].Length; j++) {
+          data[i,j] = matrix.Value[i][j];
+        }
+      }
+      return new DoubleMatrix(data);
+    }
+
+    public static HeuristicLab.Data.BoolValue ConvertToBoolValue(Parameter parameter) {
+      return new HeuristicLab.Data.BoolValue((parameter.Value as HeuristicLab.Services.Optimization.ControllerService.Model.BoolValue).Value);
+    }
+
+    public static IntValue ConvertToIntValue(Parameter parameter) {
+      return new IntValue((int)(parameter.Value as DecimalValue).Value);
+    }
+
+    public static PercentValue ConvertToPercentValue(Parameter parameter) {
+      return new PercentValue((parameter.Value as DecimalValue).Value / 100);
+    }
+
+    public static string GetStringValue(Parameter parameter) {
+      return (parameter.Value as HeuristicLab.Services.Optimization.ControllerService.Model.TypeValue).Value;
+    }
+
+    public static T FindInItemSet<T>(Core.IItemSet<T> items, Parameter what) where T : class,Core.INamedItem {
+      return items.FirstOrDefault((entry) => { return entry.Name == (what.Value as HeuristicLab.Services.Optimization.ControllerService.Model.TypeValue).Value; });
+    }
+
+    public static T FindOperator<T>(IProblem problem, Parameter what) where T : IOperator {
+      return problem.Operators.OfType<T>().FirstOrDefault((item) => { return item.ItemName == (what.Value as HeuristicLab.Services.Optimization.ControllerService.Model.TypeValue).Value; });
+    }
+  }
+}
Index: branches/OaaS/HeuristicLab.Services.Optimization.Controller/HL/HiveMapper.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Controller/HL/HiveMapper.cs	(revision 8958)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Controller/HL/HiveMapper.cs	(revision 8958)
@@ -0,0 +1,20 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Data;
+
+namespace HeuristicLab.Services.Optimization.ControllerService.Model {
+  public static class HiveMapper {    
+    public static double FindDoubleValue(this InputParameters ip, string what) {     
+      foreach (var param in ip.Items) {
+        if (param.Value.Name == what) {
+          var dv = param.Value as DecimalValue;
+          //DoubleValue result = new DoubleValue(dv.Value);
+          return dv.Value;
+        }
+      }
+      return 0.0;
+    }
+  }
+}
Index: branches/OaaS/HeuristicLab.Services.Optimization.Controller/HL/HiveScenarioManager.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Controller/HL/HiveScenarioManager.cs	(revision 8958)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Controller/HL/HiveScenarioManager.cs	(revision 8958)
@@ -0,0 +1,401 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Services.Optimization.ControllerService.Interfaces;
+using HeuristicLab.Optimization;
+using HeuristicLab.Algorithms.GeneticAlgorithm;
+using HeuristicLab.Problems.TravelingSalesman;
+using HeuristicLab;
+using System.Reflection;
+using HeuristicLab.Services.Optimization.ControllerService.Model;
+using HeuristicLab.Core;
+using System.Collections;
+using HeuristicLab.Clients.Hive;
+using System.Threading;
+using HeuristicLab.Data;
+using System.IO;
+using Microsoft.WindowsAzure;
+using Microsoft.WindowsAzure.StorageClient;
+using HeuristicLab.Services.Optimization.ControllerService.Azure;
+
+namespace HeuristicLab.Services.Optimization.ControllerService {
+  public class ScenarioEntity : TableServiceEntity {
+
+    public ScenarioEntity() {
+    }
+    
+    public ScenarioEntity(string scenarioName, string scenario, string mapper) {
+      PartitionKey = "ScenarioPartition";
+      RowKey = scenarioName;
+      Scenario = scenario;
+      Mapper = mapper;
+    }    
+
+    public string Scenario { get; set; }
+
+    public string Mapper { get; set; }
+  }
+
+  public class HiveScenarioManager : IScenarioManager {
+    private static IScenarioMapper tspMapper;
+    private static object lockable;
+    private Dictionary<string, IScenarioMapper> mappers = new Dictionary<string, IScenarioMapper>();
+    private IDataAccessLayer dal = new AzureDataAccessLayer();
+
+    public static readonly string SCENARIO_TABLE = "Scenario";
+
+    static HiveScenarioManager() {
+      lockable = new object();
+    }
+
+    public void DispatchScenario(Model.User user, Model.OptimizationScenario scenario) {
+      Experiment experiment = new Experiment();
+      var problem = new TravelingSalesmanProblem();
+      var algo = new GeneticAlgorithm();
+      algo.Problem = problem;      
+      
+      IScenarioMapper mapper = GetMapper(scenario);
+      mapper.MapScenario(scenario, algo);  
+
+      //experiment.Optimizers.Add(algo);
+      SendExperimentToHive(user, algo);
+    }
+
+    static public string AssemblyDirectory {
+      get {
+        string codeBase = Assembly.GetExecutingAssembly().CodeBase;
+        UriBuilder uri = new UriBuilder(codeBase);
+        string path = Uri.UnescapeDataString(uri.Path);
+        return Path.GetDirectoryName(path);
+      }
+    }
+
+    private IScenarioMapper CompileMapper(string scenarioMapper) {
+       // http://stackoverflow.com/questions/3188882/compile-and-run-dynamic-code-without-generating-exe
+      using (var csCodeProvider = new Microsoft.CSharp.CSharpCodeProvider()) {
+        var cp = new System.CodeDom.Compiler.CompilerParameters() {
+          GenerateInMemory = true
+        };
+
+        var referencedPaths = Directory.GetFiles(AssemblyDirectory, "*.dll");
+        foreach (var loadedAssembly in referencedPaths) {
+          cp.ReferencedAssemblies.Add(loadedAssembly);
+        }
+        cp.ReferencedAssemblies.Add("System.dll");
+        cp.ReferencedAssemblies.Add("System.Core.dll");
+        cp.ReferencedAssemblies.Add("System.Data.dll");
+        cp.ReferencedAssemblies.Add("System.Xml.dll");
+        cp.ReferencedAssemblies.Add("System.Xml.Linq.dll");
+
+        var res = csCodeProvider.CompileAssemblyFromSource(
+          cp,
+          scenarioMapper
+        );
+
+        foreach (var error in res.Errors) {
+          Console.WriteLine(error);
+        }
+        
+        var firstMapper = res.CompiledAssembly.GetTypes().Where(p => typeof(IScenarioMapper).IsAssignableFrom(p)).FirstOrDefault();        
+        return Activator.CreateInstance(firstMapper) as IScenarioMapper;
+      }
+    }
+
+    private IScenarioMapper GetMapper(Model.OptimizationScenario scenario) {
+      if (!mappers.ContainsKey(scenario.Name)) {
+        lock (lockable) {
+          if (mappers.ContainsKey(scenario.Name))
+            return mappers[scenario.Name];
+          
+          var mapperString = GetMapperFromBlobStore(scenario.Name);
+          var mapper = CompileMapper(mapperString);
+
+          /*@"using System;
+              using System.Collections.Generic;
+              using System.Linq;
+              using System.Text;
+              using HeuristicLab.Data;
+              using HeuristicLab.Services.Optimization.ControllerService.Model; 
+              using HeuristicLab.Optimization;
+              using HeuristicLab.Services.Optimization.ControllerService;
+              using HeuristicLab.Algorithms.GeneticAlgorithm;
+              using HeuristicLab.Problems.TravelingSalesman;
+              public class TSPScenarioMapper : IScenarioMapper {
+                public void MapScenario(OptimizationScenario scenario, IAlgorithm algorithm) {
+                  Console.WriteLine(""Mapping scenario!"");
+                  var ga = algorithm as GeneticAlgorithm;
+                  var problem = algorithm.Problem as TravelingSalesmanProblem;
+                  
+                  problem.BestKnownQuality = HLMapper.ConvertToDoubleValue(scenario.InputParameters.FindByName(""BestKnownQuality""));
+                  problem.BestKnownSolution = HLMapper.ConvertToPermutation(scenario.InputParameters.FindByName(""BestKnownSolution""));
+                  problem.Coordinates = HLMapper.ConvertToDoubleMatrix(scenario.InputParameters.FindByName(""Coordinates""));
+                  var evalParam = HLMapper.GetStringValue(scenario.InputParameters.FindByName(""EvaluatorParameter""));
+                  if (evalParam == ""HeuristicLab.Problems.TravelingSalesman.TSPRoundedEuclideanPathEvaluator"") {
+                    problem.EvaluatorParameter.Value = new TSPRoundedEuclideanPathEvaluator();
+                  }
+                  else if (evalParam == ""HeuristicLab.Problems.TravelingSalesman.TSPGeoPathEvaluator"") {
+                    problem.EvaluatorParameter.Value = new TSPGeoPathEvaluator();
+                  }
+                  else {
+                    problem.EvaluatorParameter.Value = new TSPEuclideanPathEvaluator();
+                  }
+                  problem.UseDistanceMatrix = HLMapper.ConvertToBoolValue(scenario.InputParameters.FindByName(""UseDistanceMatrix""));
+                  Console.WriteLine(""Mapping algorithm..."");
+                  ga.Mutator = HLMapper.FindInItemSet<HeuristicLab.Optimization.IManipulator>(ga.MutatorParameter.ValidValues, scenario.AlgorithmParameters.FindByName(""Mutator""));
+                  ga.CrossoverParameter.Value = HLMapper.FindOperator<HeuristicLab.Optimization.ICrossover>(problem, scenario.AlgorithmParameters.FindByName(""CrossoverParameter""));
+                  ga.Elites = HLMapper.ConvertToIntValue(scenario.AlgorithmParameters.FindByName(""Elites""));
+                  ga.MaximumGenerations = HLMapper.ConvertToIntValue(scenario.AlgorithmParameters.FindByName(""MaximumGenerations""));
+                  ga.MutationProbability = HLMapper.ConvertToPercentValue(scenario.AlgorithmParameters.FindByName(""MutationProbability""));                
+                  ga.PopulationSize = HLMapper.ConvertToIntValue(scenario.AlgorithmParameters.FindByName(""PopulationSize""));
+                  ga.Seed = HLMapper.ConvertToIntValue(scenario.AlgorithmParameters.FindByName(""Seed""));
+                  ga.Selector = HLMapper.FindInItemSet<HeuristicLab.Optimization.ISelector>(ga.SelectorParameter.ValidValues, scenario.AlgorithmParameters.FindByName(""Selector""));
+                  ga.SetSeedRandomly = HLMapper.ConvertToBoolValue(scenario.AlgorithmParameters.FindByName(""SetSeedRandomly""));
+                }
+              }"*/
+            mappers[scenario.Name] = mapper;
+            return mapper;
+        } // lock        
+       } // if
+      return null;
+     }  
+
+    private void MapExperiment(Model.OptimizationScenario scenario, IAlgorithm algorithm) {      
+      IScenarioMapper mapper = GetMapper(scenario);
+      mapper.MapScenario(scenario, algorithm);     
+    }
+
+    private void SendExperimentToHive(Model.User user, IAlgorithm exp) {
+      var job = new RefreshableJob();
+      job.IsAllowedPrivileged = true;      
+      job.Job.Name = "Web Scheduled Traveling Salesman Job";
+      job.Job.ResourceNames = "TESTGROUP";
+      job.RefreshAutomatically = false;
+      job.HiveTasks.Add(new OptimizerHiveTask(exp));
+      HiveServiceLocator.Instance.Username = user.Username;
+      HiveServiceLocator.Instance.Password = user.Password;
+      HiveServiceLocator.Instance.EndpointConfigurationName = "WSHttpBinding_IHiveService";
+      
+      HiveClient.StartJob((ex) => { 
+        Console.WriteLine(ex.StackTrace); 
+      }, job, new CancellationToken());
+
+      job.StopResultPolling();
+    }
+
+
+    public IList<Model.Job> GetJobs(User user) {
+      HiveServiceLocator.Instance.Username = user.Username;
+      HiveServiceLocator.Instance.Password = user.Password;
+      HiveServiceLocator.Instance.EndpointConfigurationName = "WSHttpBinding_IHiveService";
+      var jobsLoaded = HiveServiceLocator.Instance.CallHiveService<IEnumerable<HeuristicLab.Clients.Hive.Job>>(s => s.GetJobs());
+      IList<Model.Job> jobs = new List<Model.Job>();
+      
+      foreach (var job in jobsLoaded) {
+        jobs.Add(ConvertJob(user, job));
+      }
+      return jobs;
+    }
+
+    private Model.Job ConvertJob(User user, HeuristicLab.Clients.Hive.Job job) 
+    {
+      var waitingJobs = job.JobCount - job.CalculatingCount - job.FinishedCount;
+      Model.JobState? state = null;
+      var jobTasks = HiveServiceLocator.Instance.CallHiveService<IEnumerable<HeuristicLab.Clients.Hive.LightweightTask>>(s => s.GetLightweightJobTasks(job.Id));
+      
+      foreach (var task in jobTasks) {        
+        switch (task.State) {
+          case TaskState.Aborted:
+            state = JobState.Aborted;
+            break;
+          case TaskState.Failed:
+            state = JobState.Failed;
+            break;
+        }
+      }
+      if (!state.HasValue) {
+        if (job.CalculatingCount > 0)
+          state = JobState.Calculating;
+        else if (waitingJobs > 0)
+          state = JobState.Waiting;
+        else
+          state = JobState.Finished;
+      }
+      return new Model.Job() { Id = job.Id.ToString(), Name = job.Name, Resource = job.ResourceNames, State = state.Value };
+    }
+
+
+    public Model.Job GetJob(User user, string id) {
+      HiveServiceLocator.Instance.Username = user.Username;
+      HiveServiceLocator.Instance.Password = user.Password;
+      HiveServiceLocator.Instance.EndpointConfigurationName = "WSHttpBinding_IHiveService";
+      var guid = Guid.Parse(id);
+      return ConvertJob(user, HiveServiceLocator.Instance.CallHiveService<HeuristicLab.Clients.Hive.Job>(s => s.GetJob(guid)));
+    }
+
+
+    public void DeleteJob(User user, string id) {
+      HiveServiceLocator.Instance.Username = user.Username;
+      HiveServiceLocator.Instance.Password = user.Password;
+      HiveServiceLocator.Instance.EndpointConfigurationName = "WSHttpBinding_IHiveService";
+      var guid = Guid.Parse(id);
+      HiveServiceLocator.Instance.CallHiveService(s => s.DeleteJob(guid));      
+    }
+
+    public IList<Model.Run> GetJobResults(User user, string id) {
+      HiveServiceLocator.Instance.Username = user.Username;
+      HiveServiceLocator.Instance.Password = user.Password;
+      HiveServiceLocator.Instance.EndpointConfigurationName = "WSHttpBinding_IHiveService";
+      var guid = Guid.Parse(id);
+      var jobTasks = HiveServiceLocator.Instance.CallHiveService<IEnumerable<HeuristicLab.Clients.Hive.LightweightTask>>(s => s.GetLightweightJobTasks(guid));
+
+      IList<Guid> taskIds = new List<Guid>();
+      foreach (var task in jobTasks) {
+        taskIds.Add(task.Id);
+      }
+      TaskDownloader downloader = new TaskDownloader(taskIds);
+      downloader.StartAsync();
+      while (!downloader.IsFinished) {        
+        Thread.Sleep(500);
+
+        if (downloader.IsFaulted) {
+          throw downloader.Exception;
+        }
+      }
+      IDictionary<Guid, HiveTask> hiveTasks = downloader.Results;
+      IList<Model.Run> runs = new List<Model.Run>();
+      foreach (var keyTask in hiveTasks.Keys) {
+        var oht = hiveTasks[keyTask] as OptimizerHiveTask;
+        if (oht != null) {
+          foreach (var run in oht.ItemTask.Item.Runs) {
+            Model.Run taskRun = new Model.Run();
+            taskRun.Id = taskRun.Name = run.Name;
+            IList<Parameter> resultValues = new List<Model.Parameter>();
+            foreach (var key in run.Results.Keys) {
+              var value = run.Results[key];              
+              Parameter result = MapHiveDataType(key, value);
+              resultValues.Add(result);
+            }
+            taskRun.Results = resultValues;
+            runs.Add(taskRun);
+          }
+        }
+      }
+      return runs;
+    }
+
+    //TODO: We might need images / +++
+    private Parameter MapHiveDataType(string name, IItem item) {
+      Parameter result = new Parameter();
+      result.Type = ParameterType.String;
+      if (item is IStringConvertibleValue) {
+        var value = (item as IStringConvertibleValue).GetValue();
+        result.Value = new HeuristicLab.Services.Optimization.ControllerService.Model.StringValue() { Name = name, Value = value };
+      }
+      else if (item is IStringConvertibleValueTuple) {
+        var value1 = (item as IStringConvertibleValueTuple).Item1.GetValue();
+        var value2 = (item as IStringConvertibleValueTuple).Item2.GetValue();
+        result.Value = new HeuristicLab.Services.Optimization.ControllerService.Model.StringValue() { Name = name, Value = "{" + value1 + ", " + value2 + "}" };
+      }
+      else if (item is IStringConvertibleArray) {
+        StringBuilder sb = new StringBuilder();
+        var array = item as IStringConvertibleArray;
+        if (array.Length == 0) {
+          sb.Append("[ ]");
+        } else {
+          sb.Append("[");
+          for (int i=0; i < array.Length - 1; i++) {
+            sb.Append(array.GetValue(i)).Append(", ");          
+          }
+          sb.Append(array.GetValue(array.Length - 1));
+          sb.Append(" ]");
+        }
+        var value = sb.ToString();
+        result.Value = new HeuristicLab.Services.Optimization.ControllerService.Model.StringValue() { Name = name, Value = value };
+      }
+      else if (item is IStringConvertibleMatrix) {
+        StringBuilder sb = new StringBuilder();
+        var matrix = item as IStringConvertibleMatrix;
+        if (matrix.Rows == 0 || matrix.Columns == 0) {
+          sb.Append("[ ]");
+        }
+        else {
+          sb.Append("[ ");
+          for (int r = 0; r < matrix.Rows; r++) {
+            sb.Append("( ");
+            for (int c = 0; c < matrix.Columns - 1; c++) {
+              sb.Append(matrix.GetValue(r, c)).Append(", ");
+            }
+            sb.Append(matrix.GetValue(r, matrix.Columns - 1)).Append(r < matrix.Rows - 1 ? " ), " : " )");
+          }
+          sb.Append(" ]");
+        }
+        var value = sb.ToString();
+        result.Value = new HeuristicLab.Services.Optimization.ControllerService.Model.StringValue() { Name = name, Value = value };
+      }
+      else {
+        result.Value = new HeuristicLab.Services.Optimization.ControllerService.Model.StringValue() { Name = name, Value = "Cannot be displayed as string" };
+      }
+      return result;
+    }
+
+    public bool AddScenario(User user, string scenarioName, string scenarioXml, string scenarioMapper) {
+      // create scenario mapper
+      var mapper = CompileMapper(scenarioMapper);
+      if (mapper == null)
+        return false;
+      
+      // insert into table & blob store
+      var scenDao = dal.CreateScenarioDao();
+      var blobDao = dal.CreateBlobDao();
+      
+      Guid scenarioXmlGuid = Guid.NewGuid();
+      Guid scenarioMapperGuid = Guid.NewGuid();
+      string scenarioXmlId = scenarioName + "_" + scenarioXmlGuid.ToString();
+      string scenarioMapperId = scenarioName + "_" + scenarioMapperGuid.ToString();
+      if (!blobDao.Add(new StringEntry() { Key = scenarioXmlId, Text = scenarioXml }))
+        return false;
+      if (!blobDao.Add(new StringEntry() { Key = scenarioMapperId, Text = scenarioMapper }))
+        return false;
+      if (!scenDao.Add(new ScenarioEntity(scenarioName, scenarioXmlId, scenarioMapperId)))
+        return false;
+
+      // everything stored in the DB -> add mapper to dictionary
+      if (!mappers.ContainsKey(scenarioName)) {
+        lock (lockable) {
+          if (!mappers.ContainsKey(scenarioName))
+            mappers[scenarioName] = mapper;
+        }
+      }
+      return true;
+    }
+
+    private string GetMapperFromBlobStore(string scenarioName) {
+      var scenarioDao = dal.CreateScenarioDao();
+      var blobDao = dal.CreateBlobDao();
+      var entity = scenarioDao.FindByName(scenarioName);
+      if (entity == null)
+        return null;
+
+      var mapper = blobDao.FindByKey(entity.Mapper);
+      if (mapper == null)
+        return null;
+      return mapper.Text;
+    }
+
+    public bool DeleteScenario(User user, string scenarioName) {
+      // delete from table & blob store
+      var scenarioDao = dal.CreateScenarioDao();
+      var blobDao = dal.CreateBlobDao();
+
+      var entity = scenarioDao.FindByName(scenarioName);
+      if (entity == null)
+        return false;
+
+      blobDao.DeleteByKey(entity.Mapper);
+      blobDao.DeleteByKey(entity.Scenario);
+      scenarioDao.DeleteByName(scenarioName);            
+      return true;
+    }
+  }
+}
Index: branches/OaaS/HeuristicLab.Services.Optimization.Controller/HL/HiveScenarioManagerOld.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Controller/HL/HiveScenarioManagerOld.cs	(revision 8958)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Controller/HL/HiveScenarioManagerOld.cs	(revision 8958)
@@ -0,0 +1,311 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Services.Optimization.ControllerService.Interfaces;
+using HeuristicLab.Optimization;
+using HeuristicLab.Algorithms.GeneticAlgorithm;
+using HeuristicLab.Problems.TravelingSalesman;
+using HeuristicLab;
+using System.Reflection;
+using HeuristicLab.Services.Optimization.ControllerService.Model;
+using HeuristicLab.Core;
+using System.Collections;
+using HeuristicLab.Clients.Hive;
+using System.Threading;
+using HeuristicLab.Data;
+
+namespace HeuristicLab.Services.Optimization.ControllerService {
+  public class HiveScenarioManagerOld : IScenarioManager {
+    public object MapControllerDataType(object model, Parameter param) {
+      switch (param.Type) {
+        case ParameterType.Boolean:
+          return (param.Value as Model.BoolValue).Value;
+        case ParameterType.Integer:
+          return Convert.ToInt32((param.Value as Model.DecimalValue).Value);          
+        case ParameterType.Percent:        
+        case ParameterType.Decimal:
+          return (param.Value as Model.DecimalValue).Value;
+        case ParameterType.DecimalMatrix:
+          return Utility.ToMultiD(((param.Value as Model.DecimalMatrix).Value));
+        case ParameterType.DecimalVector:
+          return (param.Value as Model.DecimalVector).Value;
+        case ParameterType.Type:
+          //TODO handle type correctly!
+          var typeValue = param.Value as Model.TypeValue;
+          
+          IProblem problem = model as IProblem;
+          IAlgorithm algoModel = model as IAlgorithm;
+          if (problem == null && algoModel != null) {
+            problem = algoModel.Problem;
+          }
+
+          if (problem != null) {
+            var toselect = problem.Operators.OfType<IOperator>().FirstOrDefault(x => x.Name == typeValue.Value);            
+            if (toselect != null) {
+              return toselect;
+            }
+          }
+          
+          string parameterPropertyName = typeValue.Name.EndsWith("Parameter") ? typeValue.Name : typeValue.Name + "Parameter";
+          var parameterProperty = model.GetType().GetProperty(parameterPropertyName);
+          if (parameterProperty != null) {
+            var parameterPropertyValue = parameterProperty.GetGetMethod().Invoke(model, null);
+            var vvProp = parameterPropertyValue.GetType().GetProperty("ValidValues");
+            if (vvProp != null) {
+              //http://stackoverflow.com/questions/245607/how-is-generic-covariance-contra-variance-implemented-in-c-sharp-4-0 because of covariance declared in IEnumerable
+              var options = vvProp.GetGetMethod().Invoke(parameterPropertyValue, null) as IEnumerable<IItem>;
+              if (options != null) {
+                var result = options.FirstOrDefault(x => x.ItemName == typeValue.Value);
+                if (result != null)
+                  return result;
+              }
+            }
+          }
+
+          Type type = null;
+          foreach (var asm in AppDomain.CurrentDomain.GetAssemblies()) {
+            type = asm.GetType(typeValue.Value);
+            if (type != null)
+              break;
+          }
+          
+          return Activator.CreateInstance(type);
+      }
+      return null;
+    }
+
+    public object CreateHLObjectForType(object obj, Type type, Parameter prop) {
+      var value = MapControllerDataType(obj, prop);
+      if (prop.Type == ParameterType.Type)
+        return value;
+
+      if (type == typeof(HeuristicLab.Encodings.PermutationEncoding.Permutation)) {
+        double[] input = value as double[];
+        int[] arr = new int[input.Length];
+        for (int i = 0; i < input.Length; i++) {
+          arr[i] = Convert.ToInt32(input[i]);
+        }
+        var valueObj = new HeuristicLab.Encodings.PermutationEncoding.Permutation(Encodings.PermutationEncoding.PermutationTypes.RelativeUndirected, arr);
+        return valueObj;
+      }
+      var propertyGetter = obj.GetType().GetProperty(prop.Value.Name).GetGetMethod();        
+      return Activator.CreateInstance(propertyGetter.ReturnType, value);
+    }
+
+    private void MapProperty(object model, Parameter prop) {
+      var propertyGetter = model.GetType().GetProperty(prop.Value.Name).GetGetMethod();
+      var propertySetter = model.GetType().GetProperty(prop.Value.Name).GetSetMethod();
+      var value = propertyGetter.Invoke(model, null);
+      var valueProperty = value != null ? value.GetType().GetProperty("Value") : null;
+      if (propertySetter != null) {
+        var instance = CreateHLObjectForType(model, propertyGetter.ReturnType, prop);
+        propertySetter.Invoke(model, new object[] { instance });
+      }
+      else if (valueProperty != null) {        
+        valueProperty.GetSetMethod().Invoke(value, new object[] { MapControllerDataType(model, prop) });
+      }
+      else {
+        Console.WriteLine("Failed to handle property!");
+      }
+    }
+
+    public void DispatchScenario(Model.User user, Model.OptimizationScenario scenario) {
+      Experiment experiment = new Experiment();
+      var problem = new TravelingSalesmanProblem();
+      foreach (var prop in scenario.InputParameters.Items) {
+        MapProperty(problem, prop);
+      }
+
+      var algo = new GeneticAlgorithm();
+      algo.Problem = problem;      
+      foreach (var prop in scenario.AlgorithmParameters.Items) {
+        MapProperty(algo, prop);
+      }
+
+      experiment.Optimizers.Add(algo);
+      SendExperimentToHive(user, experiment);
+    }
+
+    private void SendExperimentToHive(Model.User user, Experiment exp) {
+      var job = new RefreshableJob();
+      job.IsAllowedPrivileged = true;      
+      job.Job.Name = "Web Scheduled Traveling Salesman Job";
+      job.Job.ResourceNames = "TESTGROUP";
+      job.RefreshAutomatically = false;
+      job.HiveTasks.Add(new OptimizerHiveTask(exp));
+      HiveServiceLocator.Instance.Username = user.Username;
+      HiveServiceLocator.Instance.Password = user.Password;
+      HiveServiceLocator.Instance.EndpointConfigurationName = "WSHttpBinding_IHiveService";
+      
+      HiveClient.StartJob((ex) => { 
+        Console.WriteLine(ex.StackTrace); 
+      }, job, new CancellationToken());
+
+      job.StopResultPolling();
+    }
+
+
+    public IList<Model.Job> GetJobs(User user) {
+      HiveServiceLocator.Instance.Username = user.Username;
+      HiveServiceLocator.Instance.Password = user.Password;
+      HiveServiceLocator.Instance.EndpointConfigurationName = "WSHttpBinding_IHiveService";
+      var jobsLoaded = HiveServiceLocator.Instance.CallHiveService<IEnumerable<HeuristicLab.Clients.Hive.Job>>(s => s.GetJobs());
+      IList<Model.Job> jobs = new List<Model.Job>();
+      
+      foreach (var job in jobsLoaded) {
+        jobs.Add(ConvertJob(user, job));
+      }
+      return jobs;
+    }
+
+    private Model.Job ConvertJob(User user, HeuristicLab.Clients.Hive.Job job) 
+    {
+      var waitingJobs = job.JobCount - job.CalculatingCount - job.FinishedCount;
+      Model.JobState? state = null;
+      var jobTasks = HiveServiceLocator.Instance.CallHiveService<IEnumerable<HeuristicLab.Clients.Hive.LightweightTask>>(s => s.GetLightweightJobTasks(job.Id));
+      
+      foreach (var task in jobTasks) {        
+        switch (task.State) {
+          case TaskState.Aborted:
+            state = JobState.Aborted;
+            break;
+          case TaskState.Failed:
+            state = JobState.Failed;
+            break;
+        }
+      }
+      if (!state.HasValue) {
+        if (job.CalculatingCount > 0)
+          state = JobState.Calculating;
+        else if (waitingJobs > 0)
+          state = JobState.Waiting;
+        else
+          state = JobState.Finished;
+      }
+      return new Model.Job() { Id = job.Id.ToString(), Name = job.Name, Resource = job.ResourceNames, State = state.Value };
+    }
+
+
+    public Model.Job GetJob(User user, string id) {
+      HiveServiceLocator.Instance.Username = user.Username;
+      HiveServiceLocator.Instance.Password = user.Password;
+      HiveServiceLocator.Instance.EndpointConfigurationName = "WSHttpBinding_IHiveService";
+      var guid = Guid.Parse(id);
+      return ConvertJob(user, HiveServiceLocator.Instance.CallHiveService<HeuristicLab.Clients.Hive.Job>(s => s.GetJob(guid)));
+    }
+
+
+    public void DeleteJob(User user, string id) {
+      HiveServiceLocator.Instance.Username = user.Username;
+      HiveServiceLocator.Instance.Password = user.Password;
+      HiveServiceLocator.Instance.EndpointConfigurationName = "WSHttpBinding_IHiveService";
+      var guid = Guid.Parse(id);
+      HiveServiceLocator.Instance.CallHiveService(s => s.DeleteJob(guid));      
+    }
+
+    public IList<Model.Run> GetJobResults(User user, string id) {
+      HiveServiceLocator.Instance.Username = user.Username;
+      HiveServiceLocator.Instance.Password = user.Password;
+      HiveServiceLocator.Instance.EndpointConfigurationName = "WSHttpBinding_IHiveService";
+      var guid = Guid.Parse(id);
+      var jobTasks = HiveServiceLocator.Instance.CallHiveService<IEnumerable<HeuristicLab.Clients.Hive.LightweightTask>>(s => s.GetLightweightJobTasks(guid));
+
+      IList<Guid> taskIds = new List<Guid>();
+      foreach (var task in jobTasks) {
+        taskIds.Add(task.Id);
+      }
+      TaskDownloader downloader = new TaskDownloader(taskIds);
+      downloader.StartAsync();
+      while (!downloader.IsFinished) {        
+        Thread.Sleep(500);
+
+        if (downloader.IsFaulted) {
+          throw downloader.Exception;
+        }
+      }
+      IDictionary<Guid, HiveTask> hiveTasks = downloader.Results;
+      IList<Model.Run> runs = new List<Model.Run>();
+      foreach (var keyTask in hiveTasks.Keys) {
+        var oht = hiveTasks[keyTask] as OptimizerHiveTask;
+        if (oht != null) {
+          foreach (var run in oht.ItemTask.Item.Runs) {
+            Model.Run taskRun = new Model.Run();
+            taskRun.Id = taskRun.Name = run.Name;
+            IList<Parameter> resultValues = new List<Model.Parameter>();
+            foreach (var key in run.Results.Keys) {
+              var value = run.Results[key];              
+              Parameter result = MapHiveDataType(key, value);
+              resultValues.Add(result);
+            }
+            taskRun.Results = resultValues;
+            runs.Add(taskRun);
+          }
+        }
+      }
+      return runs;
+    }
+    private Parameter MapHiveDataType(string name, IItem item) {
+      Parameter result = new Parameter();
+      result.Type = ParameterType.String;
+      if (item is IStringConvertibleValue) {
+        var value = (item as IStringConvertibleValue).GetValue();
+        result.Value = new HeuristicLab.Services.Optimization.ControllerService.Model.StringValue() { Name = name, Value = value };
+      }
+      else if (item is IStringConvertibleValueTuple) {
+        var value1 = (item as IStringConvertibleValueTuple).Item1.GetValue();
+        var value2 = (item as IStringConvertibleValueTuple).Item2.GetValue();
+        result.Value = new HeuristicLab.Services.Optimization.ControllerService.Model.StringValue() { Name = name, Value = "{" + value1 + ", " + value2 + "}" };
+      }
+      else if (item is IStringConvertibleArray) {
+        StringBuilder sb = new StringBuilder();
+        var array = item as IStringConvertibleArray;
+        if (array.Length == 0) {
+          sb.Append("[ ]");
+        } else {
+          sb.Append("[");
+          for (int i=0; i < array.Length - 1; i++) {
+            sb.Append(array.GetValue(i)).Append(", ");          
+          }
+          sb.Append(array.GetValue(array.Length - 1));
+          sb.Append(" ]");
+        }
+        var value = sb.ToString();
+        result.Value = new HeuristicLab.Services.Optimization.ControllerService.Model.StringValue() { Name = name, Value = value };
+      }
+      else if (item is IStringConvertibleMatrix) {
+        StringBuilder sb = new StringBuilder();
+        var matrix = item as IStringConvertibleMatrix;
+        if (matrix.Rows == 0 || matrix.Columns == 0) {
+          sb.Append("[ ]");
+        }
+        else {
+          sb.Append("[ ");
+          for (int r = 0; r < matrix.Rows; r++) {
+            sb.Append("( ");
+            for (int c = 0; c < matrix.Columns - 1; c++) {
+              sb.Append(matrix.GetValue(r, c)).Append(", ");
+            }
+            sb.Append(matrix.GetValue(r, matrix.Columns - 1)).Append(r < matrix.Rows - 1 ? " ), " : " )");
+          }
+          sb.Append(" ]");
+        }
+        var value = sb.ToString();
+        result.Value = new HeuristicLab.Services.Optimization.ControllerService.Model.StringValue() { Name = name, Value = value };
+      }
+      else {
+        result.Value = new HeuristicLab.Services.Optimization.ControllerService.Model.StringValue() { Name = name, Value = "Cannot be displayed as string" };
+      }
+      return result;
+    }
+
+
+    public bool AddScenario(User user, string scenarioName, string scenarioXml, string scenarioMapper) {
+      throw new NotImplementedException();
+    }
+
+    public bool DeleteScenario(User user, string scenarioName) {
+      throw new NotImplementedException();
+    }
+  }
+}
Index: branches/OaaS/HeuristicLab.Services.Optimization.Controller/HL/ScenarioParser.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Controller/HL/ScenarioParser.cs	(revision 8958)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Controller/HL/ScenarioParser.cs	(revision 8958)
@@ -0,0 +1,264 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.IO;
+using System.Xml;
+using System.Globalization;
+using System.Xml.Linq;
+using HeuristicLab.Services.Optimization.ControllerService.Azure;
+using HeuristicLab.Services.Optimization.ControllerService.Interfaces;
+
+namespace HeuristicLab.Services.Optimization.ControllerService {
+  public class ScenarioParser {
+    private static IList<Model.OptimizationScenario> scenarios;
+    private static object lockable = new object();
+
+    private IDataAccessLayer dal = new AzureDataAccessLayer();
+
+    public IList<Model.OptimizationScenario> Scenarios {
+      get {
+        if (scenarios == null) {
+          lock (lockable) {
+            if (scenarios == null) {
+              ParseScenarios();
+            }
+          }
+        }
+        return scenarios;
+      }
+    }
+    
+    public Model.OptimizationScenario GetByName(string name) {
+      foreach (var scen in Scenarios) {
+        if (scen.Name == name) {
+          return scen;
+        }
+      }
+      return null;
+    }
+
+    /*// http://www.sascha-dittmann.de/post/Webseitenpfade-einer-Windows-Azure-Web-Rolle-bestimmen.aspx
+    private static IEnumerable<string> WebSiteDirectories {
+      get {
+        var roleRootDir = Environment.GetEnvironmentVariable("RdRoleRoot");
+        if (roleRootDir == null)
+          return Enumerable.Empty<string>();
+        XNamespace roleModelNs =
+          "http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition";
+        var roleModelDoc = XDocument.Load(Path.Combine(roleRootDir, "RoleModel.xml"));
+        if (roleModelDoc.Root == null)
+          return Enumerable.Empty<string>();
+
+        var sites = roleModelDoc.Root.Element(roleModelNs + "Sites");
+        if (sites == null)
+          return Enumerable.Empty<string>();
+
+        var siteElements = sites.Elements(roleModelNs + "Site");
+
+        return
+          from siteElement in siteElements
+          where siteElement.Attribute("name") != null
+                && siteElement.Attribute("name").Value == "Web"
+                && siteElement.Attribute("physicalDirectory") != null
+          select Path.Combine(roleRootDir,
+                 siteElement.Attribute("physicalDirectory").Value);
+      }
+    }
+     */
+
+    private void ParseScenarios() {
+      var scens = new List<Model.OptimizationScenario>();
+      /*string path;
+      if (WebSiteDirectories.Count() != 0) {
+        path = WebSiteDirectories.FirstOrDefault() + @"\Mappings";
+      } else {
+        path = AppDomain.CurrentDomain.BaseDirectory + @"\Mappings";
+      }
+        
+      foreach (var file in Directory.EnumerateFiles(path, "*.xml")) {
+        var scenario = ParseScenarioFromFile(file);
+        if (scenario != null)
+          scens.Add(scenario);
+      }*/
+
+      var scenarioDao = dal.CreateScenarioDao();
+      var blobDao = dal.CreateBlobDao();
+      foreach (var entity in scenarioDao.GetAllEntities()) {
+        var scenarioXml = blobDao.FindByKey(entity.Scenario).Text;
+        var scenario = ParseScenarioFromXml(scenarioXml);
+        if (scenario != null)
+          scens.Add(scenario);
+      }
+
+      scenarios = scens;
+    }
+
+    private XmlReaderSettings GetSettings() {
+      // Set the validation settings.
+      XmlReaderSettings settings = new XmlReaderSettings();
+      settings.ValidationType = ValidationType.Schema;
+      settings.Schemas.Add("urn:scenario-schema", AppDomain.CurrentDomain.BaseDirectory + @"\Mappings\scenario.xsd");      
+      return settings;
+    }
+
+    public Model.OptimizationScenario ParseScenarioFromXml(string xml) {
+      //using (var reader = XmlReader.Create(new StringReader(xml), GetSettings())) {
+        return ParseScenario(new StringReader(xml));
+      //}            
+    }
+
+   /* private Model.OptimizationScenario ParseScenarioFromFile(string filename) {
+      using (var reader = XmlReader.Create(new FileStream(filename, FileMode.Open), GetSettings())) {
+        return ParseScenario(reader);
+      }      
+    } */
+
+    private Model.OptimizationScenario ParseScenario(StringReader str) {
+      // Set the validation settings.      
+      bool isErrorPresent = false;
+      var settings = GetSettings();
+      settings.ValidationEventHandler += (sender, args) => {
+        Console.WriteLine(args.Message);
+        isErrorPresent = true;
+      };
+      Model.OptimizationScenario scenario = null;
+      using (var reader = XmlReader.Create(str, settings)) {        
+        while (!isErrorPresent && !reader.EOF) {
+          if (reader.Name == "scenario" && reader.NodeType == XmlNodeType.Element) {
+            scenario = new Model.OptimizationScenario();
+            scenario.ProblemType = reader.GetAttribute("mapper");
+            scenario.ProblemType = reader.GetAttribute("algorithmType");
+            scenario.ProblemType = reader.GetAttribute("problemType");
+          }
+          else if (reader.Name == "name") {
+            scenario.Name = reader.ReadElementContentAsString();
+            continue;
+          }
+          else if (reader.Name == "problemParameters") {
+            IList<Model.Parameter> problemParameters = ParseParameters(reader);
+            foreach (var param in problemParameters)
+              scenario.InputParameters.Items.Add(param);
+          }
+          else if (reader.Name == "algorithmParameters") {
+            IList<Model.Parameter> algoParameters = ParseParameters(reader);
+            foreach (var param in algoParameters)
+              scenario.AlgorithmParameters.Items.Add(param);
+          }
+          reader.Read();
+        }
+      }
+      
+      if (isErrorPresent)
+        return null;
+      return scenario;
+    }
+
+    struct ValueEntry {
+      public double v1;
+      public double v2;
+    };
+
+    private void ParseDecimalMatrix(Model.DecimalMatrix matrix, XmlReader reader) {      
+      IList<ValueEntry> ventries = new List<ValueEntry>();
+      while (reader.Read()) {        
+        if (reader.Name == "param")
+          break;
+        if (reader.Name == "value") {
+          var val1 = Convert.ToDouble(reader.GetAttribute("v1"), CultureInfo.InvariantCulture.NumberFormat);
+          var val2 = Convert.ToDouble(reader.GetAttribute("v2"), CultureInfo.InvariantCulture.NumberFormat);
+          ventries.Add(new ValueEntry() { v1 = val1, v2 = val2 });          
+        }
+      }
+      double[][] mat = new double[ventries.Count][];
+      int i=0;
+      foreach (var entry in ventries) {
+        mat[i] = new double[2];
+        mat[i][0] = entry.v1;
+        mat[i][1] = entry.v2;
+        i++;
+      }
+      matrix.Value = mat;
+    }
+
+    private IList<Model.Parameter> ParseParameters(XmlReader reader) {
+      IList<Model.Parameter> parameters = new List<Model.Parameter>();
+      while (reader.Read()) {
+        if (reader.Name.EndsWith("Parameters"))
+          break;
+        // parse parameter
+        if (reader.Depth == 2 && reader.Name == "param" && reader.NodeType == XmlNodeType.Element) {
+          var param = new Model.Parameter();
+          var typeAtt = reader.GetAttribute("type");
+          param.Type = (Model.ParameterType)Enum.Parse(typeof(Model.ParameterType), typeAtt);
+          switch (param.Type) {
+            case Model.ParameterType.Boolean:
+              param.Value = new Model.BoolValue() { Name = reader.GetAttribute("name"), Value = Convert.ToBoolean(reader.GetAttribute("value")) };
+              break;
+            case Model.ParameterType.Integer:
+            case Model.ParameterType.Percent:
+            case Model.ParameterType.Decimal:
+              //TODO: Check which comma char is being used; enhance to use any
+              param.Value = new Model.DecimalValue() { Name = reader.GetAttribute("name"), Value = Convert.ToDouble(reader.GetAttribute("value"), CultureInfo.InvariantCulture.NumberFormat) };
+              break;            
+            case Model.ParameterType.DecimalMatrix:
+              var decMatrix = new Model.DecimalMatrix() { Name = reader.GetAttribute("name") };
+              ParseDecimalMatrix(decMatrix, reader);
+              param.Value = decMatrix;
+              break;
+            case Model.ParameterType.DecimalVector:
+              var decVec = new Model.DecimalVector() { Name = reader.GetAttribute("name") };
+              ParseDecimalVector(decVec, reader);
+              param.Value = decVec;
+              break;
+            case Model.ParameterType.Type:
+              var type = new Model.TypeValue() { Name = reader.GetAttribute("name") };
+              ParseType(type, reader);
+              param.Value = type;
+              break;
+            case Model.ParameterType.String:
+              param.Value = new Model.StringValue() { Name = reader.GetAttribute("name"), Value = reader.GetAttribute("value") };
+              break;
+            default:
+              Console.WriteLine("Unhandled model type: " + param.Type);
+              break;
+          }
+          parameters.Add(param);
+        }
+      }
+      return parameters;
+    }
+
+    private void ParseType(Model.TypeValue type, XmlReader reader) {
+      var choices = new List<string>();
+      string selected = null;
+      while (reader.Read()) {
+        if (reader.Name == "param")
+          break;
+        if (reader.Name == "choice") {
+          var choice = reader.GetAttribute("name");
+          if (reader.HasAttributes && Convert.ToBoolean(reader.GetAttribute("selected"))) {            
+            selected = choice;
+          }
+          choices.Add(choice);
+        }
+      }
+      type.Options = choices.ToArray();
+      type.Value = selected;
+    }
+
+    private void ParseDecimalVector(Model.DecimalVector decVec, XmlReader reader) {
+      var entries = new List<double>();
+      //IList<ValueEntry> ventries = new List<ValueEntry>();
+      while (reader.Read()) {
+        if (reader.Name == "param")
+          break;
+        if (reader.Name == "value") {
+          var val1 = Convert.ToDouble(reader.GetAttribute("v1"), CultureInfo.InvariantCulture.NumberFormat);
+          entries.Add(val1);
+        }
+      }
+      decVec.Value = entries.ToArray();      
+    }
+  }
+}
Index: branches/OaaS/HeuristicLab.Services.Optimization.Controller/HLMapper.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Controller/HLMapper.cs	(revision 8956)
+++ 	(revision )
@@ -1,68 +1,0 @@
-﻿using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using HeuristicLab.Data;
-using HeuristicLab.Services.Optimization.ControllerService.Model;
-using HeuristicLab.Optimization;
-using HeuristicLab.Encodings.PermutationEncoding;
-using HeuristicLab.Core;
-
-namespace HeuristicLab.Services.Optimization.ControllerService {
-  public interface IScenarioMapper {
-    void MapScenario(OptimizationScenario scenario, IAlgorithm algorithm);
-  }
-
-  public static class HLMapper {
-    public static DoubleValue ConvertToDoubleValue(Parameter parameter) {
-      var dv = parameter.Value as DecimalValue;
-      return new DoubleValue(dv.Value);      
-    }
-
-    public static Permutation ConvertToPermutation(Parameter parameter) {
-      double[] input = (parameter.Value as DecimalVector).Value;
-      int[] arr = new int[input.Length];
-      for (int i = 0; i < input.Length; i++) {
-        arr[i] = Convert.ToInt32(input[i]);
-      }
-      var valueObj = new HeuristicLab.Encodings.PermutationEncoding.Permutation(Encodings.PermutationEncoding.PermutationTypes.RelativeUndirected, arr);
-      return valueObj;
-    }
-
-    public static DoubleMatrix ConvertToDoubleMatrix(Parameter parameter) {
-      var matrix = parameter.Value as DecimalMatrix;
-      // TODO: Check for empty matrices
-      double[,] data = new double[matrix.Value.Length, matrix.Value[0].Length];
-      for (int i=0; i < matrix.Value.Length; i++) {
-        for (int j=0; j < matrix.Value[i].Length; j++) {
-          data[i,j] = matrix.Value[i][j];
-        }
-      }
-      return new DoubleMatrix(data);
-    }
-
-    public static HeuristicLab.Data.BoolValue ConvertToBoolValue(Parameter parameter) {
-      return new HeuristicLab.Data.BoolValue((parameter.Value as HeuristicLab.Services.Optimization.ControllerService.Model.BoolValue).Value);
-    }
-
-    public static IntValue ConvertToIntValue(Parameter parameter) {
-      return new IntValue((int)(parameter.Value as DecimalValue).Value);
-    }
-
-    public static PercentValue ConvertToPercentValue(Parameter parameter) {
-      return new PercentValue((parameter.Value as DecimalValue).Value / 100);
-    }
-
-    public static string GetStringValue(Parameter parameter) {
-      return (parameter.Value as HeuristicLab.Services.Optimization.ControllerService.Model.TypeValue).Value;
-    }
-
-    public static T FindInItemSet<T>(Core.IItemSet<T> items, Parameter what) where T : class,Core.INamedItem {
-      return items.FirstOrDefault((entry) => { return entry.Name == (what.Value as HeuristicLab.Services.Optimization.ControllerService.Model.TypeValue).Value; });
-    }
-
-    public static T FindOperator<T>(IProblem problem, Parameter what) where T : IOperator {
-      return problem.Operators.OfType<T>().FirstOrDefault((item) => { return item.ItemName == (what.Value as HeuristicLab.Services.Optimization.ControllerService.Model.TypeValue).Value; });
-    }
-  }
-}
Index: branches/OaaS/HeuristicLab.Services.Optimization.Controller/HeuristicLab.Services.Optimization.ControllerService.csproj
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Controller/HeuristicLab.Services.Optimization.ControllerService.csproj	(revision 8956)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Controller/HeuristicLab.Services.Optimization.ControllerService.csproj	(revision 8958)
@@ -130,7 +130,13 @@
       <HintPath>..\bin\HeuristicLab.Tracing-3.3.dll</HintPath>
     </Reference>
+    <Reference Include="Microsoft.WindowsAzure.CloudDrive, Version=1.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
+    <Reference Include="Microsoft.WindowsAzure.Configuration, Version=1.7.0.0, Culture=neutral, processorArchitecture=MSIL" />
+    <Reference Include="Microsoft.WindowsAzure.Diagnostics, Version=1.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
+    <Reference Include="Microsoft.WindowsAzure.ServiceRuntime, Version=1.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
+    <Reference Include="Microsoft.WindowsAzure.StorageClient, Version=1.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
     <Reference Include="System" />
     <Reference Include="System.configuration" />
     <Reference Include="System.Core" />
+    <Reference Include="System.Data.Services.Client" />
     <Reference Include="System.Runtime.Serialization" />
     <Reference Include="System.ServiceModel" />
@@ -142,14 +148,16 @@
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="HiveScenarioManagerOld.cs" />
-    <Compile Include="HiveMapper.cs" />
-    <Compile Include="HiveScenarioManager.cs" />
-    <Compile Include="HLMapper.cs" />
+    <Compile Include="Azure\DAL.cs" />
+    <Compile Include="HL\HiveScenarioManagerOld.cs" />
+    <Compile Include="HL\HiveMapper.cs" />
+    <Compile Include="HL\HiveScenarioManager.cs" />
+    <Compile Include="HL\HLMapper.cs" />
     <Compile Include="Interfaces\IControllerService.cs" />
+    <Compile Include="Interfaces\DAL.cs" />
     <Compile Include="Interfaces\IScenarioManager.cs" />
     <Compile Include="Model\ControllerModel.cs" />
     <Compile Include="PlaceholderControllerService.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
-    <Compile Include="ScenarioParser.cs" />
+    <Compile Include="HL\ScenarioParser.cs" />
     <Compile Include="Utility.cs" />
   </ItemGroup>
@@ -157,4 +165,5 @@
     <WCFMetadata Include="Service References\" />
   </ItemGroup>
+  <ItemGroup />
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <PropertyGroup>
Index: branches/OaaS/HeuristicLab.Services.Optimization.Controller/HiveMapper.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Controller/HiveMapper.cs	(revision 8956)
+++ 	(revision )
@@ -1,20 +1,0 @@
-﻿using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using HeuristicLab.Data;
-
-namespace HeuristicLab.Services.Optimization.ControllerService.Model {
-  public static class HiveMapper {    
-    public static double FindDoubleValue(this InputParameters ip, string what) {     
-      foreach (var param in ip.Items) {
-        if (param.Value.Name == what) {
-          var dv = param.Value as DecimalValue;
-          //DoubleValue result = new DoubleValue(dv.Value);
-          return dv.Value;
-        }
-      }
-      return 0.0;
-    }
-  }
-}
Index: branches/OaaS/HeuristicLab.Services.Optimization.Controller/HiveScenarioManager.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Controller/HiveScenarioManager.cs	(revision 8956)
+++ 	(revision )
@@ -1,308 +1,0 @@
-﻿using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using HeuristicLab.Services.Optimization.ControllerService.Interfaces;
-using HeuristicLab.Optimization;
-using HeuristicLab.Algorithms.GeneticAlgorithm;
-using HeuristicLab.Problems.TravelingSalesman;
-using HeuristicLab;
-using System.Reflection;
-using HeuristicLab.Services.Optimization.ControllerService.Model;
-using HeuristicLab.Core;
-using System.Collections;
-using HeuristicLab.Clients.Hive;
-using System.Threading;
-using HeuristicLab.Data;
-using System.IO;
-
-namespace HeuristicLab.Services.Optimization.ControllerService {
-  public class HiveScenarioManager : IScenarioManager {
-    private static IScenarioMapper tspMapper;
-    private static object lockable;
-
-    static HiveScenarioManager() {
-      lockable = new object();
-    }
-
-    public void DispatchScenario(Model.User user, Model.OptimizationScenario scenario) {
-      Experiment experiment = new Experiment();
-      var problem = new TravelingSalesmanProblem();
-      var algo = new GeneticAlgorithm();
-      algo.Problem = problem;      
-      
-      MapExperiment(scenario, algo);
-
-      experiment.Optimizers.Add(algo);
-      SendExperimentToHive(user, experiment);
-    }
-
-    static public string AssemblyDirectory {
-      get {
-        string codeBase = Assembly.GetExecutingAssembly().CodeBase;
-        UriBuilder uri = new UriBuilder(codeBase);
-        string path = Uri.UnescapeDataString(uri.Path);
-        return Path.GetDirectoryName(path);
-      }
-    }
-
-    private IScenarioMapper GetMapper(Model.OptimizationScenario scenario) {
-      if (tspMapper == null) {
-        lock (lockable) {
-          if (tspMapper != null)
-            return tspMapper;
-          
-          // http://stackoverflow.com/questions/3188882/compile-and-run-dynamic-code-without-generating-exe
-          using (var csCodeProvider = new Microsoft.CSharp.CSharpCodeProvider()) {
-            var cp = new System.CodeDom.Compiler.CompilerParameters() {
-              GenerateInMemory = true
-            };
-
-            var referencedPaths = Directory.GetFiles(AssemblyDirectory, "*.dll");
-            foreach (var loadedAssembly in referencedPaths) {
-              cp.ReferencedAssemblies.Add(loadedAssembly);
-            }
-            cp.ReferencedAssemblies.Add("System.dll");
-            cp.ReferencedAssemblies.Add("System.Core.dll");
-            cp.ReferencedAssemblies.Add("System.Data.dll");
-            cp.ReferencedAssemblies.Add("System.Xml.dll");
-            cp.ReferencedAssemblies.Add("System.Xml.Linq.dll");
-
-            var res = csCodeProvider.CompileAssemblyFromSource(
-              cp,
-            @"using System;
-              using System.Collections.Generic;
-              using System.Linq;
-              using System.Text;
-              using HeuristicLab.Data;
-              using HeuristicLab.Services.Optimization.ControllerService.Model; 
-              using HeuristicLab.Optimization;
-              using HeuristicLab.Services.Optimization.ControllerService;
-              using HeuristicLab.Algorithms.GeneticAlgorithm;
-              using HeuristicLab.Problems.TravelingSalesman;
-              public class TSPScenarioMapper : IScenarioMapper {
-                public void MapScenario(OptimizationScenario scenario, IAlgorithm algorithm) {
-                  Console.WriteLine(""Mapping scenario!"");
-                  var ga = algorithm as GeneticAlgorithm;
-                  var problem = algorithm.Problem as TravelingSalesmanProblem;
-                  
-                  problem.BestKnownQuality = HLMapper.ConvertToDoubleValue(scenario.InputParameters.FindByName(""BestKnownQuality""));
-                  problem.BestKnownSolution = HLMapper.ConvertToPermutation(scenario.InputParameters.FindByName(""BestKnownSolution""));
-                  problem.Coordinates = HLMapper.ConvertToDoubleMatrix(scenario.InputParameters.FindByName(""Coordinates""));
-                  var evalParam = HLMapper.GetStringValue(scenario.InputParameters.FindByName(""EvaluatorParameter""));
-                  if (evalParam == ""HeuristicLab.Problems.TravelingSalesman.TSPRoundedEuclideanPathEvaluator"") {
-                    problem.EvaluatorParameter.Value = new TSPRoundedEuclideanPathEvaluator();
-                  }
-                  else if (evalParam == ""HeuristicLab.Problems.TravelingSalesman.TSPGeoPathEvaluator"") {
-                    problem.EvaluatorParameter.Value = new TSPGeoPathEvaluator();
-                  }
-                  else {
-                    problem.EvaluatorParameter.Value = new TSPEuclideanPathEvaluator();
-                  }
-                  problem.UseDistanceMatrix = HLMapper.ConvertToBoolValue(scenario.InputParameters.FindByName(""UseDistanceMatrix""));
-                  Console.WriteLine(""Mapping algorithm..."");
-                  ga.Mutator = HLMapper.FindInItemSet<HeuristicLab.Optimization.IManipulator>(ga.MutatorParameter.ValidValues, scenario.AlgorithmParameters.FindByName(""Mutator""));
-                  ga.CrossoverParameter.Value = HLMapper.FindOperator<HeuristicLab.Optimization.ICrossover>(problem, scenario.AlgorithmParameters.FindByName(""CrossoverParameter""));
-                  ga.Elites = HLMapper.ConvertToIntValue(scenario.AlgorithmParameters.FindByName(""Elites""));
-                  ga.MaximumGenerations = HLMapper.ConvertToIntValue(scenario.AlgorithmParameters.FindByName(""MaximumGenerations""));
-                  ga.MutationProbability = HLMapper.ConvertToPercentValue(scenario.AlgorithmParameters.FindByName(""MutationProbability""));                
-                  ga.PopulationSize = HLMapper.ConvertToIntValue(scenario.AlgorithmParameters.FindByName(""PopulationSize""));
-                  ga.Seed = HLMapper.ConvertToIntValue(scenario.AlgorithmParameters.FindByName(""Seed""));
-                  ga.Selector = HLMapper.FindInItemSet<HeuristicLab.Optimization.ISelector>(ga.SelectorParameter.ValidValues, scenario.AlgorithmParameters.FindByName(""Selector""));
-                  ga.SetSeedRandomly = HLMapper.ConvertToBoolValue(scenario.AlgorithmParameters.FindByName(""SetSeedRandomly""));
-                }
-              }"
-            );
-
-            foreach (var error in res.Errors) {
-              Console.WriteLine(error);
-            }
-
-            var type = res.CompiledAssembly.GetType("TSPScenarioMapper");
-            tspMapper = Activator.CreateInstance(type) as IScenarioMapper;
-          } // using
-        } // lock        
-       } // if
-       return tspMapper;
-     }  
-
-    private void MapExperiment(Model.OptimizationScenario scenario, IAlgorithm algorithm) {      
-      IScenarioMapper mapper = GetMapper(scenario);
-      mapper.MapScenario(scenario, algorithm);     
-    }
-
-    private void SendExperimentToHive(Model.User user, Experiment exp) {
-      var job = new RefreshableJob();
-      job.IsAllowedPrivileged = true;      
-      job.Job.Name = "Web Scheduled Traveling Salesman Job";
-      job.Job.ResourceNames = "TESTGROUP";
-      job.RefreshAutomatically = false;
-      job.HiveTasks.Add(new OptimizerHiveTask(exp));
-      HiveServiceLocator.Instance.Username = user.Username;
-      HiveServiceLocator.Instance.Password = user.Password;
-      HiveServiceLocator.Instance.EndpointConfigurationName = "WSHttpBinding_IHiveService";
-      
-      HiveClient.StartJob((ex) => { 
-        Console.WriteLine(ex.StackTrace); 
-      }, job, new CancellationToken());
-
-      job.StopResultPolling();
-    }
-
-
-    public IList<Model.Job> GetJobs(User user) {
-      HiveServiceLocator.Instance.Username = user.Username;
-      HiveServiceLocator.Instance.Password = user.Password;
-      HiveServiceLocator.Instance.EndpointConfigurationName = "WSHttpBinding_IHiveService";
-      var jobsLoaded = HiveServiceLocator.Instance.CallHiveService<IEnumerable<HeuristicLab.Clients.Hive.Job>>(s => s.GetJobs());
-      IList<Model.Job> jobs = new List<Model.Job>();
-      
-      foreach (var job in jobsLoaded) {
-        jobs.Add(ConvertJob(user, job));
-      }
-      return jobs;
-    }
-
-    private Model.Job ConvertJob(User user, HeuristicLab.Clients.Hive.Job job) 
-    {
-      var waitingJobs = job.JobCount - job.CalculatingCount - job.FinishedCount;
-      Model.JobState? state = null;
-      var jobTasks = HiveServiceLocator.Instance.CallHiveService<IEnumerable<HeuristicLab.Clients.Hive.LightweightTask>>(s => s.GetLightweightJobTasks(job.Id));
-      
-      foreach (var task in jobTasks) {        
-        switch (task.State) {
-          case TaskState.Aborted:
-            state = JobState.Aborted;
-            break;
-          case TaskState.Failed:
-            state = JobState.Failed;
-            break;
-        }
-      }
-      if (!state.HasValue) {
-        if (job.CalculatingCount > 0)
-          state = JobState.Calculating;
-        else if (waitingJobs > 0)
-          state = JobState.Waiting;
-        else
-          state = JobState.Finished;
-      }
-      return new Model.Job() { Id = job.Id.ToString(), Name = job.Name, Resource = job.ResourceNames, State = state.Value };
-    }
-
-
-    public Model.Job GetJob(User user, string id) {
-      HiveServiceLocator.Instance.Username = user.Username;
-      HiveServiceLocator.Instance.Password = user.Password;
-      HiveServiceLocator.Instance.EndpointConfigurationName = "WSHttpBinding_IHiveService";
-      var guid = Guid.Parse(id);
-      return ConvertJob(user, HiveServiceLocator.Instance.CallHiveService<HeuristicLab.Clients.Hive.Job>(s => s.GetJob(guid)));
-    }
-
-
-    public void DeleteJob(User user, string id) {
-      HiveServiceLocator.Instance.Username = user.Username;
-      HiveServiceLocator.Instance.Password = user.Password;
-      HiveServiceLocator.Instance.EndpointConfigurationName = "WSHttpBinding_IHiveService";
-      var guid = Guid.Parse(id);
-      HiveServiceLocator.Instance.CallHiveService(s => s.DeleteJob(guid));      
-    }
-
-    public IList<Model.Run> GetJobResults(User user, string id) {
-      HiveServiceLocator.Instance.Username = user.Username;
-      HiveServiceLocator.Instance.Password = user.Password;
-      HiveServiceLocator.Instance.EndpointConfigurationName = "WSHttpBinding_IHiveService";
-      var guid = Guid.Parse(id);
-      var jobTasks = HiveServiceLocator.Instance.CallHiveService<IEnumerable<HeuristicLab.Clients.Hive.LightweightTask>>(s => s.GetLightweightJobTasks(guid));
-
-      IList<Guid> taskIds = new List<Guid>();
-      foreach (var task in jobTasks) {
-        taskIds.Add(task.Id);
-      }
-      TaskDownloader downloader = new TaskDownloader(taskIds);
-      downloader.StartAsync();
-      while (!downloader.IsFinished) {        
-        Thread.Sleep(500);
-
-        if (downloader.IsFaulted) {
-          throw downloader.Exception;
-        }
-      }
-      IDictionary<Guid, HiveTask> hiveTasks = downloader.Results;
-      IList<Model.Run> runs = new List<Model.Run>();
-      foreach (var keyTask in hiveTasks.Keys) {
-        var oht = hiveTasks[keyTask] as OptimizerHiveTask;
-        if (oht != null) {
-          foreach (var run in oht.ItemTask.Item.Runs) {
-            Model.Run taskRun = new Model.Run();
-            taskRun.Id = taskRun.Name = run.Name;
-            IList<Parameter> resultValues = new List<Model.Parameter>();
-            foreach (var key in run.Results.Keys) {
-              var value = run.Results[key];              
-              Parameter result = MapHiveDataType(key, value);
-              resultValues.Add(result);
-            }
-            taskRun.Results = resultValues;
-            runs.Add(taskRun);
-          }
-        }
-      }
-      return runs;
-    }
-
-    //TODO: We might need images / +++
-    private Parameter MapHiveDataType(string name, IItem item) {
-      Parameter result = new Parameter();
-      result.Type = ParameterType.String;
-      if (item is IStringConvertibleValue) {
-        var value = (item as IStringConvertibleValue).GetValue();
-        result.Value = new HeuristicLab.Services.Optimization.ControllerService.Model.StringValue() { Name = name, Value = value };
-      }
-      else if (item is IStringConvertibleValueTuple) {
-        var value1 = (item as IStringConvertibleValueTuple).Item1.GetValue();
-        var value2 = (item as IStringConvertibleValueTuple).Item2.GetValue();
-        result.Value = new HeuristicLab.Services.Optimization.ControllerService.Model.StringValue() { Name = name, Value = "{" + value1 + ", " + value2 + "}" };
-      }
-      else if (item is IStringConvertibleArray) {
-        StringBuilder sb = new StringBuilder();
-        var array = item as IStringConvertibleArray;
-        if (array.Length == 0) {
-          sb.Append("[ ]");
-        } else {
-          sb.Append("[");
-          for (int i=0; i < array.Length - 1; i++) {
-            sb.Append(array.GetValue(i)).Append(", ");          
-          }
-          sb.Append(array.GetValue(array.Length - 1));
-          sb.Append(" ]");
-        }
-        var value = sb.ToString();
-        result.Value = new HeuristicLab.Services.Optimization.ControllerService.Model.StringValue() { Name = name, Value = value };
-      }
-      else if (item is IStringConvertibleMatrix) {
-        StringBuilder sb = new StringBuilder();
-        var matrix = item as IStringConvertibleMatrix;
-        if (matrix.Rows == 0 || matrix.Columns == 0) {
-          sb.Append("[ ]");
-        }
-        else {
-          sb.Append("[ ");
-          for (int r = 0; r < matrix.Rows; r++) {
-            sb.Append("( ");
-            for (int c = 0; c < matrix.Columns - 1; c++) {
-              sb.Append(matrix.GetValue(r, c)).Append(", ");
-            }
-            sb.Append(matrix.GetValue(r, matrix.Columns - 1)).Append(r < matrix.Rows - 1 ? " ), " : " )");
-          }
-          sb.Append(" ]");
-        }
-        var value = sb.ToString();
-        result.Value = new HeuristicLab.Services.Optimization.ControllerService.Model.StringValue() { Name = name, Value = value };
-      }
-      else {
-        result.Value = new HeuristicLab.Services.Optimization.ControllerService.Model.StringValue() { Name = name, Value = "Cannot be displayed as string" };
-      }
-      return result;
-    }
-  }
-}
Index: branches/OaaS/HeuristicLab.Services.Optimization.Controller/HiveScenarioManagerOld.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Controller/HiveScenarioManagerOld.cs	(revision 8956)
+++ 	(revision )
@@ -1,302 +1,0 @@
-﻿using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using HeuristicLab.Services.Optimization.ControllerService.Interfaces;
-using HeuristicLab.Optimization;
-using HeuristicLab.Algorithms.GeneticAlgorithm;
-using HeuristicLab.Problems.TravelingSalesman;
-using HeuristicLab;
-using System.Reflection;
-using HeuristicLab.Services.Optimization.ControllerService.Model;
-using HeuristicLab.Core;
-using System.Collections;
-using HeuristicLab.Clients.Hive;
-using System.Threading;
-using HeuristicLab.Data;
-
-namespace HeuristicLab.Services.Optimization.ControllerService {
-  public class HiveScenarioManagerOld : IScenarioManager {
-    public object MapControllerDataType(object model, Parameter param) {
-      switch (param.Type) {
-        case ParameterType.Boolean:
-          return (param.Value as Model.BoolValue).Value;
-        case ParameterType.Integer:
-          return Convert.ToInt32((param.Value as Model.DecimalValue).Value);          
-        case ParameterType.Percent:        
-        case ParameterType.Decimal:
-          return (param.Value as Model.DecimalValue).Value;
-        case ParameterType.DecimalMatrix:
-          return Utility.ToMultiD(((param.Value as Model.DecimalMatrix).Value));
-        case ParameterType.DecimalVector:
-          return (param.Value as Model.DecimalVector).Value;
-        case ParameterType.Type:
-          //TODO handle type correctly!
-          var typeValue = param.Value as Model.TypeValue;
-          
-          IProblem problem = model as IProblem;
-          IAlgorithm algoModel = model as IAlgorithm;
-          if (problem == null && algoModel != null) {
-            problem = algoModel.Problem;
-          }
-
-          if (problem != null) {
-            var toselect = problem.Operators.OfType<IOperator>().FirstOrDefault(x => x.Name == typeValue.Value);            
-            if (toselect != null) {
-              return toselect;
-            }
-          }
-          
-          string parameterPropertyName = typeValue.Name.EndsWith("Parameter") ? typeValue.Name : typeValue.Name + "Parameter";
-          var parameterProperty = model.GetType().GetProperty(parameterPropertyName);
-          if (parameterProperty != null) {
-            var parameterPropertyValue = parameterProperty.GetGetMethod().Invoke(model, null);
-            var vvProp = parameterPropertyValue.GetType().GetProperty("ValidValues");
-            if (vvProp != null) {
-              //http://stackoverflow.com/questions/245607/how-is-generic-covariance-contra-variance-implemented-in-c-sharp-4-0 because of covariance declared in IEnumerable
-              var options = vvProp.GetGetMethod().Invoke(parameterPropertyValue, null) as IEnumerable<IItem>;
-              if (options != null) {
-                var result = options.FirstOrDefault(x => x.ItemName == typeValue.Value);
-                if (result != null)
-                  return result;
-              }
-            }
-          }
-
-          Type type = null;
-          foreach (var asm in AppDomain.CurrentDomain.GetAssemblies()) {
-            type = asm.GetType(typeValue.Value);
-            if (type != null)
-              break;
-          }
-          
-          return Activator.CreateInstance(type);
-      }
-      return null;
-    }
-
-    public object CreateHLObjectForType(object obj, Type type, Parameter prop) {
-      var value = MapControllerDataType(obj, prop);
-      if (prop.Type == ParameterType.Type)
-        return value;
-
-      if (type == typeof(HeuristicLab.Encodings.PermutationEncoding.Permutation)) {
-        double[] input = value as double[];
-        int[] arr = new int[input.Length];
-        for (int i = 0; i < input.Length; i++) {
-          arr[i] = Convert.ToInt32(input[i]);
-        }
-        var valueObj = new HeuristicLab.Encodings.PermutationEncoding.Permutation(Encodings.PermutationEncoding.PermutationTypes.RelativeUndirected, arr);
-        return valueObj;
-      }
-      var propertyGetter = obj.GetType().GetProperty(prop.Value.Name).GetGetMethod();        
-      return Activator.CreateInstance(propertyGetter.ReturnType, value);
-    }
-
-    private void MapProperty(object model, Parameter prop) {
-      var propertyGetter = model.GetType().GetProperty(prop.Value.Name).GetGetMethod();
-      var propertySetter = model.GetType().GetProperty(prop.Value.Name).GetSetMethod();
-      var value = propertyGetter.Invoke(model, null);
-      var valueProperty = value != null ? value.GetType().GetProperty("Value") : null;
-      if (propertySetter != null) {
-        var instance = CreateHLObjectForType(model, propertyGetter.ReturnType, prop);
-        propertySetter.Invoke(model, new object[] { instance });
-      }
-      else if (valueProperty != null) {        
-        valueProperty.GetSetMethod().Invoke(value, new object[] { MapControllerDataType(model, prop) });
-      }
-      else {
-        Console.WriteLine("Failed to handle property!");
-      }
-    }
-
-    public void DispatchScenario(Model.User user, Model.OptimizationScenario scenario) {
-      Experiment experiment = new Experiment();
-      var problem = new TravelingSalesmanProblem();
-      foreach (var prop in scenario.InputParameters.Items) {
-        MapProperty(problem, prop);
-      }
-
-      var algo = new GeneticAlgorithm();
-      algo.Problem = problem;      
-      foreach (var prop in scenario.AlgorithmParameters.Items) {
-        MapProperty(algo, prop);
-      }
-
-      experiment.Optimizers.Add(algo);
-      SendExperimentToHive(user, experiment);
-    }
-
-    private void SendExperimentToHive(Model.User user, Experiment exp) {
-      var job = new RefreshableJob();
-      job.IsAllowedPrivileged = true;      
-      job.Job.Name = "Web Scheduled Traveling Salesman Job";
-      job.Job.ResourceNames = "TESTGROUP";
-      job.RefreshAutomatically = false;
-      job.HiveTasks.Add(new OptimizerHiveTask(exp));
-      HiveServiceLocator.Instance.Username = user.Username;
-      HiveServiceLocator.Instance.Password = user.Password;
-      HiveServiceLocator.Instance.EndpointConfigurationName = "WSHttpBinding_IHiveService";
-      
-      HiveClient.StartJob((ex) => { 
-        Console.WriteLine(ex.StackTrace); 
-      }, job, new CancellationToken());
-
-      job.StopResultPolling();
-    }
-
-
-    public IList<Model.Job> GetJobs(User user) {
-      HiveServiceLocator.Instance.Username = user.Username;
-      HiveServiceLocator.Instance.Password = user.Password;
-      HiveServiceLocator.Instance.EndpointConfigurationName = "WSHttpBinding_IHiveService";
-      var jobsLoaded = HiveServiceLocator.Instance.CallHiveService<IEnumerable<HeuristicLab.Clients.Hive.Job>>(s => s.GetJobs());
-      IList<Model.Job> jobs = new List<Model.Job>();
-      
-      foreach (var job in jobsLoaded) {
-        jobs.Add(ConvertJob(user, job));
-      }
-      return jobs;
-    }
-
-    private Model.Job ConvertJob(User user, HeuristicLab.Clients.Hive.Job job) 
-    {
-      var waitingJobs = job.JobCount - job.CalculatingCount - job.FinishedCount;
-      Model.JobState? state = null;
-      var jobTasks = HiveServiceLocator.Instance.CallHiveService<IEnumerable<HeuristicLab.Clients.Hive.LightweightTask>>(s => s.GetLightweightJobTasks(job.Id));
-      
-      foreach (var task in jobTasks) {        
-        switch (task.State) {
-          case TaskState.Aborted:
-            state = JobState.Aborted;
-            break;
-          case TaskState.Failed:
-            state = JobState.Failed;
-            break;
-        }
-      }
-      if (!state.HasValue) {
-        if (job.CalculatingCount > 0)
-          state = JobState.Calculating;
-        else if (waitingJobs > 0)
-          state = JobState.Waiting;
-        else
-          state = JobState.Finished;
-      }
-      return new Model.Job() { Id = job.Id.ToString(), Name = job.Name, Resource = job.ResourceNames, State = state.Value };
-    }
-
-
-    public Model.Job GetJob(User user, string id) {
-      HiveServiceLocator.Instance.Username = user.Username;
-      HiveServiceLocator.Instance.Password = user.Password;
-      HiveServiceLocator.Instance.EndpointConfigurationName = "WSHttpBinding_IHiveService";
-      var guid = Guid.Parse(id);
-      return ConvertJob(user, HiveServiceLocator.Instance.CallHiveService<HeuristicLab.Clients.Hive.Job>(s => s.GetJob(guid)));
-    }
-
-
-    public void DeleteJob(User user, string id) {
-      HiveServiceLocator.Instance.Username = user.Username;
-      HiveServiceLocator.Instance.Password = user.Password;
-      HiveServiceLocator.Instance.EndpointConfigurationName = "WSHttpBinding_IHiveService";
-      var guid = Guid.Parse(id);
-      HiveServiceLocator.Instance.CallHiveService(s => s.DeleteJob(guid));      
-    }
-
-    public IList<Model.Run> GetJobResults(User user, string id) {
-      HiveServiceLocator.Instance.Username = user.Username;
-      HiveServiceLocator.Instance.Password = user.Password;
-      HiveServiceLocator.Instance.EndpointConfigurationName = "WSHttpBinding_IHiveService";
-      var guid = Guid.Parse(id);
-      var jobTasks = HiveServiceLocator.Instance.CallHiveService<IEnumerable<HeuristicLab.Clients.Hive.LightweightTask>>(s => s.GetLightweightJobTasks(guid));
-
-      IList<Guid> taskIds = new List<Guid>();
-      foreach (var task in jobTasks) {
-        taskIds.Add(task.Id);
-      }
-      TaskDownloader downloader = new TaskDownloader(taskIds);
-      downloader.StartAsync();
-      while (!downloader.IsFinished) {        
-        Thread.Sleep(500);
-
-        if (downloader.IsFaulted) {
-          throw downloader.Exception;
-        }
-      }
-      IDictionary<Guid, HiveTask> hiveTasks = downloader.Results;
-      IList<Model.Run> runs = new List<Model.Run>();
-      foreach (var keyTask in hiveTasks.Keys) {
-        var oht = hiveTasks[keyTask] as OptimizerHiveTask;
-        if (oht != null) {
-          foreach (var run in oht.ItemTask.Item.Runs) {
-            Model.Run taskRun = new Model.Run();
-            taskRun.Id = taskRun.Name = run.Name;
-            IList<Parameter> resultValues = new List<Model.Parameter>();
-            foreach (var key in run.Results.Keys) {
-              var value = run.Results[key];              
-              Parameter result = MapHiveDataType(key, value);
-              resultValues.Add(result);
-            }
-            taskRun.Results = resultValues;
-            runs.Add(taskRun);
-          }
-        }
-      }
-      return runs;
-    }
-    private Parameter MapHiveDataType(string name, IItem item) {
-      Parameter result = new Parameter();
-      result.Type = ParameterType.String;
-      if (item is IStringConvertibleValue) {
-        var value = (item as IStringConvertibleValue).GetValue();
-        result.Value = new HeuristicLab.Services.Optimization.ControllerService.Model.StringValue() { Name = name, Value = value };
-      }
-      else if (item is IStringConvertibleValueTuple) {
-        var value1 = (item as IStringConvertibleValueTuple).Item1.GetValue();
-        var value2 = (item as IStringConvertibleValueTuple).Item2.GetValue();
-        result.Value = new HeuristicLab.Services.Optimization.ControllerService.Model.StringValue() { Name = name, Value = "{" + value1 + ", " + value2 + "}" };
-      }
-      else if (item is IStringConvertibleArray) {
-        StringBuilder sb = new StringBuilder();
-        var array = item as IStringConvertibleArray;
-        if (array.Length == 0) {
-          sb.Append("[ ]");
-        } else {
-          sb.Append("[");
-          for (int i=0; i < array.Length - 1; i++) {
-            sb.Append(array.GetValue(i)).Append(", ");          
-          }
-          sb.Append(array.GetValue(array.Length - 1));
-          sb.Append(" ]");
-        }
-        var value = sb.ToString();
-        result.Value = new HeuristicLab.Services.Optimization.ControllerService.Model.StringValue() { Name = name, Value = value };
-      }
-      else if (item is IStringConvertibleMatrix) {
-        StringBuilder sb = new StringBuilder();
-        var matrix = item as IStringConvertibleMatrix;
-        if (matrix.Rows == 0 || matrix.Columns == 0) {
-          sb.Append("[ ]");
-        }
-        else {
-          sb.Append("[ ");
-          for (int r = 0; r < matrix.Rows; r++) {
-            sb.Append("( ");
-            for (int c = 0; c < matrix.Columns - 1; c++) {
-              sb.Append(matrix.GetValue(r, c)).Append(", ");
-            }
-            sb.Append(matrix.GetValue(r, matrix.Columns - 1)).Append(r < matrix.Rows - 1 ? " ), " : " )");
-          }
-          sb.Append(" ]");
-        }
-        var value = sb.ToString();
-        result.Value = new HeuristicLab.Services.Optimization.ControllerService.Model.StringValue() { Name = name, Value = value };
-      }
-      else {
-        result.Value = new HeuristicLab.Services.Optimization.ControllerService.Model.StringValue() { Name = name, Value = "Cannot be displayed as string" };
-      }
-      return result;
-    }
-  }
-}
Index: branches/OaaS/HeuristicLab.Services.Optimization.Controller/Interfaces/DAL.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Controller/Interfaces/DAL.cs	(revision 8958)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Controller/Interfaces/DAL.cs	(revision 8958)
@@ -0,0 +1,30 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace HeuristicLab.Services.Optimization.ControllerService.Interfaces {
+  public class StringEntry {
+    public string Key { get; set; }
+    public string Text { get; set; }    
+  };
+
+  public interface IScenarioDao {
+    bool Add(ScenarioEntity entity);
+    bool DeleteByName(string scenarioName);
+    ScenarioEntity FindByName(string scenarioName);
+    IEnumerable<ScenarioEntity> GetAllEntities();
+  }
+
+  public interface IBlobDao {
+    bool Add(StringEntry entry);
+    bool DeleteByKey(string entryKey);
+    StringEntry FindByKey(string entryKey);
+  }
+
+  public interface IDataAccessLayer {
+    IScenarioDao CreateScenarioDao();
+    IBlobDao CreateBlobDao();
+  }
+}
+
Index: branches/OaaS/HeuristicLab.Services.Optimization.Controller/Interfaces/IControllerService.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Controller/Interfaces/IControllerService.cs	(revision 8956)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Controller/Interfaces/IControllerService.cs	(revision 8958)
@@ -12,4 +12,7 @@
     [OperationContract]
     IEnumerable<OptimizationScenario> GetOptimizationScenarios();
+
+    [OperationContract]
+    IEnumerable<string> GetOptimizationScenarioNames();
 
     [OperationContract]
@@ -30,4 +33,10 @@
     [OperationContract]
     IList<Model.Run> GetJobResults(User user, string id);
+
+    [OperationContract]
+    bool AddHiveScenario(User user, string scenarioXml, string scenarioMapper);
+
+    [OperationContract]
+    bool DeleteHiveScenario(User user, string scenarioName);
   }
 }
Index: branches/OaaS/HeuristicLab.Services.Optimization.Controller/Interfaces/IScenarioManager.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Controller/Interfaces/IScenarioManager.cs	(revision 8956)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Controller/Interfaces/IScenarioManager.cs	(revision 8958)
@@ -12,4 +12,6 @@
     void DeleteJob(User user, string id);
     IList<Model.Run> GetJobResults(User user, string id);
+    bool AddScenario(User user, string scenarioName, string scenarioXml, string scenarioMapper);
+    bool DeleteScenario(User user, string scenarioName);
   }
 }
Index: branches/OaaS/HeuristicLab.Services.Optimization.Controller/PlaceholderControllerService.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Controller/PlaceholderControllerService.cs	(revision 8956)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Controller/PlaceholderControllerService.cs	(revision 8958)
@@ -62,7 +62,8 @@
 
     public Model.OptimizationScenario GetOptimizationScenarioByName(string name) {
-      if (scenarios[0].Name == name)
-        return scenarios[0];
-      return null;
+      var scen = (from e in scenarios
+                  where e.Name == name
+                  select e).FirstOrDefault();      
+      return scen;
     }
 
@@ -89,4 +90,30 @@
       return hiveManager.GetJobResults(user, id);
     }
+
+
+    public bool AddHiveScenario(User user, string scenarioXml, string scenarioMapper) {
+      var scenario = parser.ParseScenarioFromXml(scenarioXml);
+      if (scenario == null) {
+        return false;
+      }      
+      var added = hiveManager.AddScenario(user, scenario.Name, scenarioXml, scenarioMapper);
+      if (added) 
+        scenarios.Add(scenario);
+      return added;
+    }
+
+    public bool DeleteHiveScenario(User user, string scenarioName) {
+      var scen = GetOptimizationScenarioByName(scenarioName);
+      if (scen != null) {
+        scenarios.Remove(scen);
+        return hiveManager.DeleteScenario(user, scenarioName);
+      }
+      return false;
+    }
+
+    public IEnumerable<string> GetOptimizationScenarioNames() {
+      return (from e in scenarios
+              select e.Name).AsEnumerable();      
+    }
   }
 }
Index: branches/OaaS/HeuristicLab.Services.Optimization.Controller/ScenarioParser.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Controller/ScenarioParser.cs	(revision 8956)
+++ 	(revision )
@@ -1,229 +1,0 @@
-﻿using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.IO;
-using System.Xml;
-using System.Globalization;
-using System.Xml.Linq;
-
-namespace HeuristicLab.Services.Optimization.ControllerService {
-  public class ScenarioParser {
-    private static IList<Model.OptimizationScenario> scenarios;
-    private static object lockable = new object();
-
-    public IList<Model.OptimizationScenario> Scenarios {
-      get {
-        if (scenarios == null) {
-          lock (lockable) {
-            if (scenarios == null) {
-              ParseScenarios();
-            }
-          }
-        }
-        return scenarios;
-      }
-    }
-    
-    public Model.OptimizationScenario GetByName(string name) {
-      foreach (var scen in Scenarios) {
-        if (scen.Name == name) {
-          return scen;
-        }
-      }
-      return null;
-    }
-
-    // http://www.sascha-dittmann.de/post/Webseitenpfade-einer-Windows-Azure-Web-Rolle-bestimmen.aspx
-    private static IEnumerable<string> WebSiteDirectories {
-      get {
-        var roleRootDir = Environment.GetEnvironmentVariable("RdRoleRoot");
-        if (roleRootDir == null)
-          return Enumerable.Empty<string>();
-        XNamespace roleModelNs =
-          "http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition";
-        var roleModelDoc = XDocument.Load(Path.Combine(roleRootDir, "RoleModel.xml"));
-        if (roleModelDoc.Root == null)
-          return Enumerable.Empty<string>();
-
-        var sites = roleModelDoc.Root.Element(roleModelNs + "Sites");
-        if (sites == null)
-          return Enumerable.Empty<string>();
-
-        var siteElements = sites.Elements(roleModelNs + "Site");
-
-        return
-          from siteElement in siteElements
-          where siteElement.Attribute("name") != null
-                && siteElement.Attribute("name").Value == "Web"
-                && siteElement.Attribute("physicalDirectory") != null
-          select Path.Combine(roleRootDir,
-                 siteElement.Attribute("physicalDirectory").Value);
-      }
-    }
-
-    private void ParseScenarios() {
-      var scens = new List<Model.OptimizationScenario>();
-      string path;
-      if (WebSiteDirectories.Count() != 0) {
-        path = WebSiteDirectories.FirstOrDefault() + @"\Mappings";
-      } else {
-        path = AppDomain.CurrentDomain.BaseDirectory + @"\Mappings";
-      }
-        
-      foreach (var file in Directory.EnumerateFiles(path, "*.xml")) {
-        var scenario = ParseScenario(file);
-        if (scenario != null)
-          scens.Add(scenario);
-      }
-
-      scenarios = scens;
-    }
-
-    private Model.OptimizationScenario ParseScenario(string filename) {
-      // Set the validation settings.
-      XmlReaderSettings settings = new XmlReaderSettings();
-      settings.ValidationType = ValidationType.Schema;
-      settings.Schemas.Add("urn:scenario-schema", AppDomain.CurrentDomain.BaseDirectory + @"\Mappings\scenario.xsd");
-      bool isErrorPresent = false;
-      settings.ValidationEventHandler += (sender, args) => {
-        Console.WriteLine(args.Message);
-        isErrorPresent = true;
-      };
-      Model.OptimizationScenario scenario = null;
-      using (var reader = XmlReader.Create(filename, settings)) {
-        while (!isErrorPresent && reader.Read()) {
-          if (reader.Name == "scenario" && reader.NodeType == XmlNodeType.Element) {
-            scenario = new Model.OptimizationScenario();
-            scenario.ProblemType = reader.GetAttribute("mapper");
-            scenario.ProblemType = reader.GetAttribute("algorithmType");
-            scenario.ProblemType = reader.GetAttribute("problemType");
-          }
-          else if (reader.Name == "name") {
-            scenario.Name = reader.ReadElementContentAsString();            
-          }
-          else if (reader.Name == "problemParameters") {
-            IList<Model.Parameter> problemParameters = ParseParameters(reader);
-            foreach (var param in problemParameters)
-              scenario.InputParameters.Items.Add(param);
-          }
-          else if (reader.Name == "algorithmParameters") {
-            IList<Model.Parameter> algoParameters = ParseParameters(reader);
-            foreach (var param in algoParameters)
-              scenario.AlgorithmParameters.Items.Add(param);
-          }
-        }
-      }
-      if (isErrorPresent)
-        return null;
-      return scenario;
-    }
-
-    struct ValueEntry {
-      public double v1;
-      public double v2;
-    };
-
-    private void ParseDecimalMatrix(Model.DecimalMatrix matrix, XmlReader reader) {      
-      IList<ValueEntry> ventries = new List<ValueEntry>();
-      while (reader.Read()) {        
-        if (reader.Name == "param")
-          break;
-        if (reader.Name == "value") {
-          var val1 = Convert.ToDouble(reader.GetAttribute("v1"), CultureInfo.InvariantCulture.NumberFormat);
-          var val2 = Convert.ToDouble(reader.GetAttribute("v2"), CultureInfo.InvariantCulture.NumberFormat);
-          ventries.Add(new ValueEntry() { v1 = val1, v2 = val2 });          
-        }
-      }
-      double[][] mat = new double[ventries.Count][];
-      int i=0;
-      foreach (var entry in ventries) {
-        mat[i] = new double[2];
-        mat[i][0] = entry.v1;
-        mat[i][1] = entry.v2;
-        i++;
-      }
-      matrix.Value = mat;
-    }
-
-    private IList<Model.Parameter> ParseParameters(XmlReader reader) {
-      IList<Model.Parameter> parameters = new List<Model.Parameter>();
-      while (reader.Read()) {
-        if (reader.Name.EndsWith("Parameters"))
-          break;
-        // parse parameter
-        if (reader.Depth == 2 && reader.Name == "param" && reader.NodeType == XmlNodeType.Element) {
-          var param = new Model.Parameter();
-          var typeAtt = reader.GetAttribute("type");
-          param.Type = (Model.ParameterType)Enum.Parse(typeof(Model.ParameterType), typeAtt);
-          switch (param.Type) {
-            case Model.ParameterType.Boolean:
-              param.Value = new Model.BoolValue() { Name = reader.GetAttribute("name"), Value = Convert.ToBoolean(reader.GetAttribute("value")) };
-              break;
-            case Model.ParameterType.Integer:
-            case Model.ParameterType.Percent:
-            case Model.ParameterType.Decimal:
-              //TODO: Check which comma char is being used; enhance to use any
-              param.Value = new Model.DecimalValue() { Name = reader.GetAttribute("name"), Value = Convert.ToDouble(reader.GetAttribute("value"), CultureInfo.InvariantCulture.NumberFormat) };
-              break;            
-            case Model.ParameterType.DecimalMatrix:
-              var decMatrix = new Model.DecimalMatrix() { Name = reader.GetAttribute("name") };
-              ParseDecimalMatrix(decMatrix, reader);
-              param.Value = decMatrix;
-              break;
-            case Model.ParameterType.DecimalVector:
-              var decVec = new Model.DecimalVector() { Name = reader.GetAttribute("name") };
-              ParseDecimalVector(decVec, reader);
-              param.Value = decVec;
-              break;
-            case Model.ParameterType.Type:
-              var type = new Model.TypeValue() { Name = reader.GetAttribute("name") };
-              ParseType(type, reader);
-              param.Value = type;
-              break;
-            case Model.ParameterType.String:
-              param.Value = new Model.StringValue() { Name = reader.GetAttribute("name"), Value = reader.GetAttribute("value") };
-              break;
-            default:
-              Console.WriteLine("Unhandled model type: " + param.Type);
-              break;
-          }
-          parameters.Add(param);
-        }
-      }
-      return parameters;
-    }
-
-    private void ParseType(Model.TypeValue type, XmlReader reader) {
-      var choices = new List<string>();
-      string selected = null;
-      while (reader.Read()) {
-        if (reader.Name == "param")
-          break;
-        if (reader.Name == "choice") {
-          var choice = reader.GetAttribute("name");
-          if (reader.HasAttributes && Convert.ToBoolean(reader.GetAttribute("selected"))) {            
-            selected = choice;
-          }
-          choices.Add(choice);
-        }
-      }
-      type.Options = choices.ToArray();
-      type.Value = selected;
-    }
-
-    private void ParseDecimalVector(Model.DecimalVector decVec, XmlReader reader) {
-      var entries = new List<double>();
-      //IList<ValueEntry> ventries = new List<ValueEntry>();
-      while (reader.Read()) {
-        if (reader.Name == "param")
-          break;
-        if (reader.Name == "value") {
-          var val1 = Convert.ToDouble(reader.GetAttribute("v1"), CultureInfo.InvariantCulture.NumberFormat);
-          entries.Add(val1);
-        }
-      }
-      decVec.Value = entries.ToArray();      
-    }
-  }
-}
Index: branches/OaaS/HeuristicLab.Services.Optimization.Web/Controllers/AdminController.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Web/Controllers/AdminController.cs	(revision 8958)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Web/Controllers/AdminController.cs	(revision 8958)
@@ -0,0 +1,88 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using System.Web.Mvc;
+using HeuristicLab.Services.Optimization.Web.Models;
+using System.IO;
+using System.Text;
+using System.Xml;
+using HeuristicLab.Services.Optimization.ControllerService;
+using System.ServiceModel;
+using System.ServiceModel.Description;
+using System.Web.Security;
+using HeuristicLab.Services.Optimization.ControllerService.Model;
+
+namespace HeuristicLab.Services.Optimization.Web.Controllers
+{
+    [Authorize(Roles = "Web User")]
+    public class AdminController : Controller
+    {
+      public delegate T ControllerServiceDelegate<T>(IControllerService service);
+      public delegate void ControllerServiceDelegate(IControllerService service);
+
+      public T withControllerService<T>(ControllerServiceDelegate<T> del) {
+        using (var cf = new ChannelFactory<IControllerService>(OptimizationController.DEFAULT_CONTROLLER_ENDPOINT)) {
+          var credentialBehaviour = cf.Endpoint.Behaviors.Find<ClientCredentials>();
+          credentialBehaviour.UserName.UserName = Membership.GetUser().UserName;
+          credentialBehaviour.UserName.Password = Session["pw"] as string;
+          var controllerProxy = cf.CreateChannel();
+          return del(controllerProxy);
+        }
+      }
+
+      public void withControllerService(ControllerServiceDelegate del) {
+        using (var cf = new ChannelFactory<IControllerService>(OptimizationController.DEFAULT_CONTROLLER_ENDPOINT)) {
+          var credentialBehaviour = cf.Endpoint.Behaviors.Find<ClientCredentials>();
+          credentialBehaviour.UserName.UserName = Membership.GetUser().UserName;
+          credentialBehaviour.UserName.Password = Session["pw"] as string;
+          var controllerProxy = cf.CreateChannel();
+          del(controllerProxy);
+        }
+      }
+        //
+        // GET: /Admin/
+        [HttpGet]
+        public ActionResult Index()
+        {
+          var names = withControllerService<IEnumerable<string>>((service) => {            
+            User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string };
+            return service.GetOptimizationScenarioNames();
+          });
+          return View(names);
+        }
+
+        [HttpPost]
+        public ActionResult AddScenario(UploadScenario newSecnario) {
+          StreamReader reader = new StreamReader(newSecnario.ScenarioMapper.InputStream);
+          string scenarioMapper = reader.ReadToEnd();
+
+          XmlDocument doc = new XmlDocument();
+          doc.Load(newSecnario.ScenarioXml.InputStream);
+          string scenarioXml;
+          using (var stringWriter = new StringWriter())
+          using (var xmlTextWriter = XmlWriter.Create(stringWriter)) {
+            doc.WriteTo(xmlTextWriter);
+            xmlTextWriter.Flush();
+            scenarioXml = stringWriter.GetStringBuilder().ToString();
+          }
+
+          var ok = withControllerService<bool>((service) => {
+            OptimizationModel model = new OptimizationModel();
+            User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string };
+            return service.AddHiveScenario(u, scenarioXml, scenarioMapper);                        
+          });
+
+          return RedirectToAction("Index");
+        }
+
+        public ActionResult DeleteScenario(string id) {
+          withControllerService<bool>((service) => {            
+            User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string };
+            return service.DeleteHiveScenario(u, id);
+          });
+          return RedirectToAction("Index");
+        }
+
+    }
+}
Index: branches/OaaS/HeuristicLab.Services.Optimization.Web/Controllers/HomeController.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Web/Controllers/HomeController.cs	(revision 8956)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Web/Controllers/HomeController.cs	(revision 8958)
@@ -7,8 +7,6 @@
 namespace HeuristicLab.Services.Optimization.Web.Controllers {
   public class HomeController : Controller {
-    public ActionResult Index() {
-      ViewBag.Message = "Welcome to ASP.NET MVC!";
-
-      return View();
+    public ActionResult Index() {      
+      return RedirectToAction("Index", "Optimization");      
     }
 
Index: branches/OaaS/HeuristicLab.Services.Optimization.Web/HeuristicLab.Services.Optimization.Web.csproj
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Web/HeuristicLab.Services.Optimization.Web.csproj	(revision 8956)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Web/HeuristicLab.Services.Optimization.Web.csproj	(revision 8958)
@@ -97,4 +97,5 @@
   <ItemGroup>
     <Compile Include="Controllers\AccountController.cs" />
+    <Compile Include="Controllers\AdminController.cs" />
     <Compile Include="Controllers\HomeController.cs" />
     <Compile Include="Controllers\OptimizationController.cs" />
@@ -103,4 +104,5 @@
     </Compile>
     <Compile Include="Models\AccountModels.cs" />
+    <Compile Include="Models\AdminModels.cs" />
     <Compile Include="Models\OptimizationModels.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
@@ -257,4 +259,5 @@
       <SubType>Designer</SubType>
     </None>
+    <Content Include="Views\Admin\Index.cshtml" />
   </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
Index: branches/OaaS/HeuristicLab.Services.Optimization.Web/Mappings/tsp.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Web/Mappings/tsp.cs	(revision 8958)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Web/Mappings/tsp.cs	(revision 8958)
@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Data;
+using HeuristicLab.Services.Optimization.ControllerService.Model; 
+using HeuristicLab.Optimization;
+using HeuristicLab.Services.Optimization.ControllerService;
+using HeuristicLab.Algorithms.GeneticAlgorithm;
+using HeuristicLab.Problems.TravelingSalesman;
+public class TSPScenarioMapper : IScenarioMapper {
+  public void MapScenario(OptimizationScenario scenario, IAlgorithm algorithm) {
+    Console.WriteLine("Mapping scenario!");
+    var ga = algorithm as GeneticAlgorithm;
+    var problem = algorithm.Problem as TravelingSalesmanProblem;
+                  
+    problem.BestKnownQuality = HLMapper.ConvertToDoubleValue(scenario.InputParameters.FindByName("BestKnownQuality"));
+    problem.BestKnownSolution = HLMapper.ConvertToPermutation(scenario.InputParameters.FindByName("BestKnownSolution"));
+    problem.Coordinates = HLMapper.ConvertToDoubleMatrix(scenario.InputParameters.FindByName("Coordinates"));
+    var evalParam = HLMapper.GetStringValue(scenario.InputParameters.FindByName("EvaluatorParameter"));
+    if (evalParam == "HeuristicLab.Problems.TravelingSalesman.TSPRoundedEuclideanPathEvaluator") {
+      problem.EvaluatorParameter.Value = new TSPRoundedEuclideanPathEvaluator();
+    }
+    else if (evalParam == "HeuristicLab.Problems.TravelingSalesman.TSPGeoPathEvaluator") {
+      problem.EvaluatorParameter.Value = new TSPGeoPathEvaluator();
+    }
+    else {
+      problem.EvaluatorParameter.Value = new TSPEuclideanPathEvaluator();
+    }
+    problem.UseDistanceMatrix = HLMapper.ConvertToBoolValue(scenario.InputParameters.FindByName("UseDistanceMatrix"));
+    Console.WriteLine("Mapping algorithm...");
+    ga.Mutator = HLMapper.FindInItemSet<HeuristicLab.Optimization.IManipulator>(ga.MutatorParameter.ValidValues, scenario.AlgorithmParameters.FindByName("Mutator"));
+    ga.CrossoverParameter.Value = HLMapper.FindOperator<HeuristicLab.Optimization.ICrossover>(problem, scenario.AlgorithmParameters.FindByName("CrossoverParameter"));
+    ga.Elites = HLMapper.ConvertToIntValue(scenario.AlgorithmParameters.FindByName("Elites"));
+    ga.MaximumGenerations = HLMapper.ConvertToIntValue(scenario.AlgorithmParameters.FindByName("MaximumGenerations"));
+    ga.MutationProbability = HLMapper.ConvertToPercentValue(scenario.AlgorithmParameters.FindByName("MutationProbability"));                
+    ga.PopulationSize = HLMapper.ConvertToIntValue(scenario.AlgorithmParameters.FindByName("PopulationSize"));
+    ga.Seed = HLMapper.ConvertToIntValue(scenario.AlgorithmParameters.FindByName("Seed"));
+    ga.Selector = HLMapper.FindInItemSet<HeuristicLab.Optimization.ISelector>(ga.SelectorParameter.ValidValues, scenario.AlgorithmParameters.FindByName("Selector"));
+    ga.SetSeedRandomly = HLMapper.ConvertToBoolValue(scenario.AlgorithmParameters.FindByName("SetSeedRandomly"));
+  }
+}
Index: branches/OaaS/HeuristicLab.Services.Optimization.Web/Mappings/tsp.xml
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Web/Mappings/tsp.xml	(revision 8956)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Web/Mappings/tsp.xml	(revision 8958)
@@ -11,8 +11,11 @@
       <value v1="40"/>
       <value v1="38"/>
+      <value v1="60"/>
     </param>
     <param type="DecimalMatrix" name="Coordinates">
       <value v1="334.5909" v2="161.7809"/>
       <value v1="503.5909" v2="172.7809"/>
+      <value v1="400.5909" v2="300.7809"/>
+      <value v1="700.5909" v2="700.7809"/>
     </param>
     <param type="Type" name="EvaluatorParameter">
Index: branches/OaaS/HeuristicLab.Services.Optimization.Web/Models/AdminModels.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Web/Models/AdminModels.cs	(revision 8958)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Web/Models/AdminModels.cs	(revision 8958)
@@ -0,0 +1,26 @@
+﻿using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Globalization;
+using System.Web.Mvc;
+using System.Web.Security;
+using System.Web;
+
+namespace HeuristicLab.Services.Optimization.Web.Models {
+  public class UploadScenario {
+    private HttpPostedFileBase scenarioMapper;
+
+    public HttpPostedFileBase ScenarioMapper {
+      get { return scenarioMapper; }
+      set { scenarioMapper = value; }
+    }
+
+    private HttpPostedFileBase scenarioXml;
+
+    public HttpPostedFileBase ScenarioXml {
+      get { return scenarioXml; }
+      set { scenarioXml = value; }
+    }
+
+  }
+}
Index: branches/OaaS/HeuristicLab.Services.Optimization.Web/Views/Admin/Index.cshtml
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Web/Views/Admin/Index.cshtml	(revision 8958)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Web/Views/Admin/Index.cshtml	(revision 8958)
@@ -0,0 +1,42 @@
+﻿@model IEnumerable<string>
+
+@{
+    ViewBag.Title = "Index.cshtml";
+}
+
+<h2>Add scenarios</h2>
+
+@using (Html.BeginForm("AddScenario", "Admin", FormMethod.Post, new {enctype = "multipart/form-data"})) {
+  <fieldset>    
+    <label for="scenarioMapper">Scenario Mapper</label>
+    <input type="file" name="scenarioMapper" id="scenarioMapper" />
+    <label for="scenarioMapper">Scenario XML</label>
+    <input type="file" name="scenarioXml" id="scenarioXml" />
+    <input type="submit" value="Upload scenario" />
+  </fieldset>
+}
+
+<h2>Manage scenarios:</h2>
+@using (Html.BeginForm("DeleteScenario", "Admin", FormMethod.Post)) {    
+<table>
+      <thead>
+        <tr>
+          <td>Name</td>
+          <td>Delete</td>          
+        </tr>
+      </thead>
+      <tbody>
+      @foreach (var scen in Model) {
+        <tr>
+          <td>@scen</td>
+          <td>
+             <input type="hidden" value="@scen" name="id" />
+             <input type="submit" value="Delete" />       
+          </td>          
+       </tr>
+      }
+      </tbody>
+    </table>
+}
+
+
Index: branches/OaaS/HeuristicLab.Services.Optimization.Web/Views/Shared/_Layout.cshtml
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Web/Views/Shared/_Layout.cshtml	(revision 8956)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Web/Views/Shared/_Layout.cshtml	(revision 8958)
@@ -19,4 +19,5 @@
             <nav>
                 <ul id="menu">
+                    <li>@Html.ActionLink("Admin", "Index", "Admin")</li>
                     <li>@Html.ActionLink("Home", "Index", "Home")</li>
                     <li>@Html.ActionLink("About", "About", "Home")</li>
Index: branches/OaaS/HeuristicLab.Services.Optimization.Web/WebRole.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Web/WebRole.cs	(revision 8956)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Web/WebRole.cs	(revision 8958)
@@ -7,8 +7,25 @@
 
 namespace HeuristicLab.Services.Optimization.Web {
+  public static class Constants {
+    public const string DiagnosticsConnectionString = "Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString";
+  }
+
   public class WebRole : RoleEntryPoint {
     public override bool OnStart() {
       // For information on handling configuration changes
-      // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
+      // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.      
+      try {
+        if (!String.IsNullOrEmpty(RoleEnvironment.GetConfigurationSettingValue(Constants.DiagnosticsConnectionString))) {
+          DiagnosticMonitorConfiguration dmc = DiagnosticMonitor.GetDefaultInitialConfiguration();
+          dmc.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);
+          dmc.Logs.ScheduledTransferLogLevelFilter = LogLevel.Verbose;
+          DiagnosticMonitor.Start(Constants.DiagnosticsConnectionString, dmc);
+        }
+      }
+      catch (RoleEnvironmentException ex) {
+        // diagnostics connection string not in configuration
+        // -> diagnostics disabled
+        // nothing more to do
+      }
 
       return base.OnStart();
