Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/13/10 01:21:32 (14 years ago)
Author:
swagner
Message:

Worked on OKB data model and services (#1174).

Location:
trunk/sources/HeuristicLab.Services.OKB/3.3
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Services.OKB/3.3/AdminService.cs

    r4279 r4381  
    2424using System.ServiceModel;
    2525using HeuristicLab.Services.OKB.DataAccess;
    26 using log4net;
    2726
    2827namespace HeuristicLab.Services.OKB {
    29 
    3028  /// <summary>
    3129  /// Implementation of <see cref="IAdminService"/>
    3230  /// </summary>
    33   [ServiceBehavior(
    34     InstanceContextMode = InstanceContextMode.PerSession,
    35     IncludeExceptionDetailInFaults = true)]
     31  [ServiceBehavior(IncludeExceptionDetailInFaults = true)]
    3632  public class AdminService : IAdminService {
    37 
    38     private static ILog logger = LogManager.GetLogger(typeof(AdminService));
    39 
    40     private OKBDataContext GetDataContext() {
    41       return new OKBDataContext();
    42     }
    43 
    4433    /// <summary>
    4534    /// Gets all available platforms.
    4635    /// </summary>
    4736    /// <returns>A list of <see cref="Platform"/>s.</returns>
    48     public Platform[] GetPlatformNames() {
    49       OKBDataContext okb = GetDataContext();
    50       return okb.Platforms.ToArray();
     37    public Platform[] GetPlatforms() {
     38      using (OKBDataContext okb = new OKBDataContext()) {
     39        return okb.Platforms.ToArray();
     40      }
    5141    }
    5242
     
    5444    /// Gets the complete algorithm object graph up to the following entities:
    5545    /// <list type="bullet">
    56     ///     <item>Parameter</item>
    57     ///     <item>Algorithm_Paramters.Parameter.DataType</item>
    58     ///     <item>Algorithm_Results.Result.DataType</item>
    59     ///   </list>
     46    ///   <item>Parameter</item>
     47    ///   <item>Algorithm_Paramters.Parameter.DataType</item>
     48    ///   <item>Algorithm_Results.Result.DataType</item>
     49    /// </list>
    6050    /// </summary>
    6151    /// <param name="id">The algorithm id.</param>
    6252    /// <returns>An <see cref="Algorithm"/></returns>
    6353    public Algorithm GetCompleteAlgorithm(int id) {
    64       OKBDataContext okb = GetDataContext();
    65       var dlo = new DataLoadOptions();
    66       dlo.LoadWith<Algorithm>(a => a.Platform);
    67       dlo.LoadWith<Algorithm>(a => a.Algorithm_Parameters);
    68       dlo.LoadWith<Algorithm>(a => a.Algorithm_Results);
    69       dlo.LoadWith<Algorithm_Parameter>(ap => ap.Parameter);
    70       dlo.LoadWith<Algorithm_Result>(ar => ar.Result);
    71       dlo.LoadWith<Parameter>(p => p.DataType);
    72       dlo.LoadWith<Result>(r => r.DataType);
    73       okb.LoadOptions = dlo;
    74       return okb.Algorithms.Single(a => a.Id == id);
     54      using (OKBDataContext okb = new OKBDataContext()) {
     55        var dlo = new DataLoadOptions();
     56        dlo.LoadWith<Algorithm>(a => a.AlgorithmClass);
     57        dlo.LoadWith<Algorithm>(a => a.Platform);
     58        dlo.LoadWith<Algorithm>(a => a.AlgorithmUsers);
     59        dlo.LoadWith<AlgorithmUser>(u => u.User);
     60        okb.LoadOptions = dlo;
     61        return okb.Algorithms.Single(a => a.Id == id);
     62      }
    7563    }
    7664
     
    7866    /// Gets the complete problem object graph up to the following entities:
    7967    /// <list type="bullet">
    80     ///     <item>Platform</item>
    81     ///     <item>SolutionRepresentation</item>
    82     ///     <item>Problem_Parameters.Parameter</item>
    83     ///     <item>IntProblemCharacteristicValues.ProblemCharacteristic.DataType</item>
    84     ///     <item>FloatProblemCharacteristicValues.ProblemCharacteristic.DataType</item>
    85     ///     <item>CharProblemCharacteristicValues.ProblemCharacteristic.DataType</item>
    86     ///   </list>
     68    ///   <item>Platform</item>
     69    ///   <item>SolutionRepresentation</item>
     70    ///   <item>Problem_Parameters.Parameter</item>
     71    ///   <item>IntProblemCharacteristicValues.ProblemCharacteristic.DataType</item>
     72    ///   <item>FloatProblemCharacteristicValues.ProblemCharacteristic.DataType</item>
     73    ///   <item>CharProblemCharacteristicValues.ProblemCharacteristic.DataType</item>
     74    /// </list>
    8775    /// </summary>
    8876    /// <param name="id">The problem id.</param>
    8977    /// <returns>A <see cref="Problem"/></returns>
    9078    public Problem GetCompleteProblem(int id) {
    91       OKBDataContext okb = GetDataContext();
    92       var dlo = new DataLoadOptions();
    93       dlo.LoadWith<Problem>(p => p.Platform);
    94       dlo.LoadWith<Problem>(p => p.SolutionRepresentation);
    95       dlo.LoadWith<Problem>(p => p.Problem_Parameters);
    96       dlo.LoadWith<Problem>(p => p.IntProblemCharacteristicValues);
    97       dlo.LoadWith<Problem>(p => p.FloatProblemCharacteristicValues);
    98       dlo.LoadWith<Problem>(p => p.CharProblemCharacteristicValues);
    99       dlo.LoadWith<Problem_Parameter>(ap => ap.Parameter);
    100       dlo.LoadWith<IntProblemCharacteristicValue>(ipcv => ipcv.ProblemCharacteristic);
    101       dlo.LoadWith<FloatProblemCharacteristicValue>(fpcv => fpcv.ProblemCharacteristic);
    102       dlo.LoadWith<CharProblemCharacteristicValue>(cpcv => cpcv.ProblemCharacteristic);
    103       dlo.LoadWith<Parameter>(p => p.DataType);
    104       dlo.LoadWith<ProblemCharacteristic>(pc => pc.DataType);
    105       okb.LoadOptions = dlo;
    106       return okb.Problems.Single(p => p.Id == id);
     79      using (OKBDataContext okb = new OKBDataContext()) {
     80        var dlo = new DataLoadOptions();
     81        dlo.LoadWith<Problem>(p => p.ProblemClass);
     82        dlo.LoadWith<Problem>(p => p.SolutionRepresentation);
     83        dlo.LoadWith<Problem>(p => p.Platform);
     84        dlo.LoadWith<Problem>(p => p.ProblemUsers);
     85        dlo.LoadWith<ProblemUser>(u => u.User);
     86        dlo.LoadWith<Problem>(p => p.ProblemCharacteristicIntValues);
     87        dlo.LoadWith<Problem>(p => p.ProblemCharacteristicFloatValues);
     88        dlo.LoadWith<Problem>(p => p.ProblemCharacteristicStringValues);
     89        dlo.LoadWith<ProblemCharacteristicIntValue>(ipcv => ipcv.ProblemCharacteristic);
     90        dlo.LoadWith<ProblemCharacteristicFloatValue>(fpcv => fpcv.ProblemCharacteristic);
     91        dlo.LoadWith<ProblemCharacteristicStringValue>(cpcv => cpcv.ProblemCharacteristic);
     92        dlo.LoadWith<ProblemCharacteristic>(pc => pc.DataType);
     93        okb.LoadOptions = dlo;
     94        return okb.Problems.Single(p => p.Id == id);
     95      }
    10796    }
    10897
     
    11099    /// Updates the algorithm object graph including the following properties and linked entitites:
    111100    /// <list type="bullet">
    112     ///     <item>Name</item>
    113     ///     <item>Description</item>
    114     ///     <item>AlgorithmClassId</item>
    115     ///     <item>PlatformId</item>
    116     ///     <item>Algorithm_Parameters</item>
    117     ///     <item>Algorithm_Results</item>
    118     ///   </list>
    119     ///   <remarks>
     101    ///   <item>Name</item>
     102    ///   <item>Description</item>
     103    ///   <item>AlgorithmClassId</item>
     104    ///   <item>PlatformId</item>
     105    ///   <item>Algorithm_Parameters</item>
     106    ///   <item>Algorithm_Results</item>
     107    /// </list>
     108    /// <remarks>
    120109    /// New <see cref="Parameter"/>s or <see cref="Result"/>s will not be
    121110    /// created but have to be pre-existing.
     
    124113    /// <param name="algorithm">The algorithm.</param>
    125114    public void UpdateCompleteAlgorithm(Algorithm algorithm) {
    126       OKBDataContext okb = GetDataContext();
    127       Algorithm original = okb.Algorithms.Single(a => a.Id == algorithm.Id);
     115      using (OKBDataContext okb = new OKBDataContext()) {
     116        Algorithm original = okb.Algorithms.Single(a => a.Id == algorithm.Id);
     117        UpdateAlgorithmData(algorithm, original, okb);
     118        okb.SubmitChanges();
     119      }
     120    }
     121
     122    /// <summary>
     123    /// Updates the problem object graph including the following properties and linked entities:
     124    /// <list type="bullet">
     125    ///   <item>Name</item>
     126    ///   <item>Description</item>
     127    ///   <item>ProblemClassId</item>
     128    ///   <item>PlatformId</item>
     129    ///   <item>SolutionRepresentationId</item>
     130    ///   <item>IntProblemCharacteristicValues.Value</item>
     131    ///   <item>FloatProblemCharacteristicValues.Value</item>
     132    ///   <item>CharProblemCharacteristicValues.Value</item>
     133    ///   <item>Problem_Parameters</item>
     134    /// </list>
     135    /// <remarks>
     136    /// New <see cref="ProblemCharacteristic"/>s or <see cref="Parameter"/>s will
     137    /// not be created but have to be pre-existing.
     138    /// </remarks>
     139    /// </summary>
     140    /// <param name="problem">The problem.</param>
     141    public void UpdateCompleteProblem(Problem problem) {
     142      using (OKBDataContext okb = new OKBDataContext()) {
     143        Problem originalProblem = okb.Problems.Single(p => p.Id == problem.Id);
     144        UpdateProblemData(problem, originalProblem, okb);
     145        UpdateProblemCharacteristics(problem, originalProblem, okb);
     146        okb.SubmitChanges();
     147      }
     148    }
     149
     150    private static void UpdateAlgorithmData(Algorithm algorithm, Algorithm original, OKBDataContext okb) {
    128151      original.Name = algorithm.Name;
    129152      original.Description = algorithm.Description;
    130153      original.AlgorithmClassId = algorithm.AlgorithmClassId;
    131154      original.PlatformId = algorithm.PlatformId;
    132       okb.Algorithm_Parameters.DeleteAllOnSubmit(original.Algorithm_Parameters);
    133       foreach (var a_p in algorithm.Algorithm_Parameters)
    134         original.Algorithm_Parameters.Add(new Algorithm_Parameter() {
     155      okb.AlgorithmUsers.DeleteAllOnSubmit(original.AlgorithmUsers);
     156      original.AlgorithmUsers.Clear();
     157      foreach (var u in algorithm.AlgorithmUsers) {
     158        original.AlgorithmUsers.Add(new AlgorithmUser() {
    135159          AlgorithmId = original.Id,
    136           ParameterId = a_p.ParameterId,
    137         });
    138       okb.Algorithm_Results.DeleteAllOnSubmit(original.Algorithm_Results);
    139       foreach (var a_r in algorithm.Algorithm_Results)
    140         original.Algorithm_Results.Add(new Algorithm_Result() {
    141           AlgorithmId = original.Id,
    142           ResultId = a_r.ResultId,
    143         });
    144       logger.Info("Updating algorithm implementation for " + original.Name);
    145       okb.SubmitChanges();
    146     }
    147 
    148     /// <summary>
    149     /// Updates the problem object graph including the following properties and linked entities:
    150     /// <list type="bullet">
    151     ///     <item>Name</item>
    152     ///     <item>Description</item>
    153     ///     <item>ProblemClassId</item>
    154     ///     <item>PlatformId</item>
    155     ///     <item>SolutionRepresentationId</item>
    156     ///     <item>IntProblemCharacteristicValues.Value</item>
    157     ///     <item>FloatProblemCharacteristicValues.Value</item>
    158     ///     <item>CharProblemCharacteristicValues.Value</item>
    159     ///     <item>Problem_Parameters</item>
    160     ///   </list>
    161     ///   <remarks>
    162     /// New <see cref="ProblemCharacteristic"/>s or <see cref="Parameter"/>s will
    163     /// not be created but have to be pre-existing.
    164     /// </remarks>
    165     /// </summary>
    166     /// <param name="problem">The problem.</param>
    167     public void UpdateCompleteProblem(Problem problem) {
    168       OKBDataContext okb = GetDataContext();
    169       Problem originalProblem = okb.Problems.Single(p => p.Id == problem.Id);
    170       UpdateProblemMasterInfo(problem, originalProblem);
    171       UpdateProblemCharacteristics(problem, okb, originalProblem);
    172       UpdateProblemParameters(problem, okb, originalProblem);
    173       logger.Info("Updating problem " + originalProblem.Name);
    174       okb.SubmitChanges();
    175     }
    176 
    177     private static void UpdateProblemParameters(Problem problem, OKBDataContext okb, Problem originalProblem) {
    178       okb.Problem_Parameters.DeleteAllOnSubmit(originalProblem.Problem_Parameters);
    179       originalProblem.Problem_Parameters.Clear();
    180       foreach (var p_p in problem.Problem_Parameters) {
    181         originalProblem.Problem_Parameters.Add(new Problem_Parameter() {
    182           ProblemId = originalProblem.Id,
    183           ParameterId = p_p.ParameterId,
    184         });
    185       }
    186     }
    187 
    188     private static void UpdateProblemCharacteristics(Problem problem, OKBDataContext okb, Problem originalProblem) {
    189       okb.IntProblemCharacteristicValues.DeleteAllOnSubmit(originalProblem.IntProblemCharacteristicValues);
    190       okb.FloatProblemCharacteristicValues.DeleteAllOnSubmit(originalProblem.FloatProblemCharacteristicValues);
    191       okb.CharProblemCharacteristicValues.DeleteAllOnSubmit(originalProblem.CharProblemCharacteristicValues);
    192       originalProblem.IntProblemCharacteristicValues.Clear();
    193       originalProblem.FloatProblemCharacteristicValues.Clear();
    194       originalProblem.CharProblemCharacteristicValues.Clear();
    195       foreach (var ipc in problem.IntProblemCharacteristicValues) {
    196         originalProblem.IntProblemCharacteristicValues.Add(new IntProblemCharacteristicValue() {
    197           ProblemId = originalProblem.Id,
     160          UserId = u.UserId
     161        });
     162      }
     163    }
     164
     165    private static void UpdateProblemData(Problem problem, Problem original, OKBDataContext okb) {
     166      original.Name = problem.Name;
     167      original.Description = problem.Description;
     168      original.ProblemClassId = problem.ProblemClassId;
     169      original.SolutionRepresentationId = problem.SolutionRepresentationId;
     170      original.PlatformId = problem.PlatformId;
     171      okb.ProblemUsers.DeleteAllOnSubmit(original.ProblemUsers);
     172      original.ProblemUsers.Clear();
     173      foreach (var u in problem.ProblemUsers) {
     174        original.ProblemUsers.Add(new ProblemUser() {
     175          ProblemId = original.Id,
     176          UserId = u.UserId
     177        });
     178      }
     179    }
     180    private static void UpdateProblemCharacteristics(Problem problem, Problem original, OKBDataContext okb) {
     181      okb.ProblemCharacteristicIntValues.DeleteAllOnSubmit(original.ProblemCharacteristicIntValues);
     182      okb.ProblemCharacteristicFloatValues.DeleteAllOnSubmit(original.ProblemCharacteristicFloatValues);
     183      okb.ProblemCharacteristicStringValues.DeleteAllOnSubmit(original.ProblemCharacteristicStringValues);
     184      original.ProblemCharacteristicIntValues.Clear();
     185      original.ProblemCharacteristicFloatValues.Clear();
     186      original.ProblemCharacteristicStringValues.Clear();
     187      foreach (var ipc in problem.ProblemCharacteristicIntValues) {
     188        original.ProblemCharacteristicIntValues.Add(new ProblemCharacteristicIntValue() {
     189          ProblemId = original.Id,
    198190          ProblemCharacteristicId = ipc.ProblemCharacteristicId,
    199191          Value = ipc.Value,
    200192        });
    201193      }
    202       foreach (var fpc in problem.FloatProblemCharacteristicValues) {
    203         originalProblem.FloatProblemCharacteristicValues.Add(new FloatProblemCharacteristicValue() {
    204           ProblemId = originalProblem.Id,
     194      foreach (var fpc in problem.ProblemCharacteristicFloatValues) {
     195        original.ProblemCharacteristicFloatValues.Add(new ProblemCharacteristicFloatValue() {
     196          ProblemId = original.Id,
    205197          ProblemCharacteristicId = fpc.ProblemCharacteristicId,
    206198          Value = fpc.Value,
    207199        });
    208200      }
    209       foreach (var cpc in problem.CharProblemCharacteristicValues) {
    210         originalProblem.CharProblemCharacteristicValues.Add(new CharProblemCharacteristicValue() {
    211           ProblemId = originalProblem.Id,
     201      foreach (var cpc in problem.ProblemCharacteristicStringValues) {
     202        original.ProblemCharacteristicStringValues.Add(new ProblemCharacteristicStringValue() {
     203          ProblemId = original.Id,
    212204          ProblemCharacteristicId = cpc.ProblemCharacteristicId,
    213205          Value = cpc.Value,
     
    215207      }
    216208    }
    217 
    218     private static void UpdateProblemMasterInfo(Problem problem, Problem originalProblem) {
    219       originalProblem.Name = problem.Name;
    220       originalProblem.Description = problem.Description;
    221       originalProblem.ProblemClassId = problem.ProblemClassId;
    222       originalProblem.PlatformId = problem.PlatformId;
    223       originalProblem.SolutionRepresentationId = problem.SolutionRepresentationId;
    224     }
    225209  }
    226210}
  • trunk/sources/HeuristicLab.Services.OKB/3.3/DataService.cs

    r4298 r4381  
    2626using System.ServiceModel;
    2727using HeuristicLab.Services.OKB.DataAccess;
    28 using log4net;
    2928
    3029namespace HeuristicLab.Services.OKB {
    31 
    3230  /// <summary>
    3331  /// Implementation of the <see cref="IDataService"/>.
    3432  /// </summary>
    35   [ServiceBehavior(
    36     InstanceContextMode = InstanceContextMode.PerSession,
    37     IncludeExceptionDetailInFaults = true,
    38     ConcurrencyMode = ConcurrencyMode.Multiple)]
     33  [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession, IncludeExceptionDetailInFaults = true)]
    3934  class DataService : IDisposable, IDataService {
    40 
    4135    private enum Mode { Request, Submit, None };
    4236
    4337    private Mode mode = Mode.None;
    44 
    4538    private EntityType type;
    4639    private int id = -1;
    4740    private MemoryStream dataStream;
    4841
    49     private Guid sessionID;
    50     private static ILog logger = LogManager.GetLogger(typeof(DataService));
    51 
    52     private void Log(string message, params object[] args) {
    53       using (log4net.ThreadContext.Stacks["NDC"].Push(sessionID.ToString())) {
    54         logger.Info(String.Format(message, args));
    55       }
    56     }
    57 
    58     /// <summary>
    59     /// Initializes a new instance of the <see cref="DataService"/> class.
    60     /// </summary>
    61     public DataService() {
    62       sessionID = Guid.NewGuid();
    63       Log("Instantiating new service");
    64     }
    65 
    6642    private void EnsureInit() {
    6743      if (mode != Mode.None)
    68         throw new FaultException(String.Format(
    69           "Cannot service new request while processing another {0}-Operation", mode));
     44        throw new FaultException(String.Format("Cannot service new request while processing another {0}-Operation.", mode));
    7045    }
    7146
    7247    private byte[] GetData(EntityType type, int id) {
    73       Log("loading data", type, id);
    7448      using (OKBDataContext okb = new OKBDataContext()) {
    7549        switch (type) {
     
    8458            }
    8559            return algorithm.AlgorithmData.Data.ToArray();
    86             break;
    8760          case EntityType.Problem:
    8861            Problem problem = okb.Problems.Single(p => p.Id == id);
     
    9568            }
    9669            return problem.ProblemData.Data.ToArray();
    97             break;
    9870          default:
    99             throw new FaultException("Unsupported EntityType");
     71            throw new FaultException("Unsupported EntityType.");
    10072        }
    10173      }
     
    10375
    10476    private void SetData(EntityType type, int id, byte[] data) {
    105       Log("saving data", type, id, data.Length);
    106       OKBDataContext okb = new OKBDataContext();
    107       switch (type) {
    108         case EntityType.Algorithm:
    109           Algorithm algorithm = okb.Algorithms.Single(a => a.Id == id);
    110           if (algorithm.AlgorithmData == null)
    111             algorithm.AlgorithmData = new AlgorithmData() {
    112               AlgorithmId = algorithm.Id,
    113               Data = new Binary(new byte[0])
    114             };
    115           algorithm.AlgorithmData.Data = new Binary(data);
    116           okb.SubmitChanges();
    117           break;
    118         case EntityType.Problem:
    119           Problem problem = okb.Problems.Single(p => p.Id == id);
    120           if (problem.ProblemData == null)
    121             problem.ProblemData = new ProblemData() {
    122               ProblemId = problem.Id,
    123               Data = new Binary(new byte[0])
    124             };
    125           problem.ProblemData.Data = new Binary(data);
    126           okb.SubmitChanges();
    127           break;
    128         default:
    129           throw new FaultException("Unsupported EntityType");
     77      using (OKBDataContext okb = new OKBDataContext()) {
     78        switch (type) {
     79          case EntityType.Algorithm:
     80            Algorithm algorithm = okb.Algorithms.Single(a => a.Id == id);
     81            if (algorithm.AlgorithmData == null)
     82              algorithm.AlgorithmData = new AlgorithmData() {
     83                AlgorithmId = algorithm.Id,
     84                Data = new Binary(new byte[0])
     85              };
     86            algorithm.AlgorithmData.Data = new Binary(data);
     87            okb.SubmitChanges();
     88            break;
     89          case EntityType.Problem:
     90            Problem problem = okb.Problems.Single(p => p.Id == id);
     91            if (problem.ProblemData == null)
     92              problem.ProblemData = new ProblemData() {
     93                ProblemId = problem.Id,
     94                Data = new Binary(new byte[0])
     95              };
     96            problem.ProblemData.Data = new Binary(data);
     97            okb.SubmitChanges();
     98            break;
     99          default:
     100            throw new FaultException("Unsupported EntityType.");
     101        }
    130102      }
    131       okb.Dispose();
    132103    }
    133104
    134105    #region IDataService Members
    135 
    136106    /// <summary>
    137107    /// Request the specified <see cref="Algorithm"/> or <see cref="Problem"/>.
     
    141111    /// <returns>The size of the data blob.</returns>
    142112    public int Request(EntityType type, int id) {
    143       Log("requesting data", type, id);
    144113      EnsureInit();
    145114      dataStream = new MemoryStream(GetData(type, id));
     
    155124    public byte[] GetNextChunk(int size) {
    156125      if (dataStream == null || mode != Mode.Request)
    157         throw new FaultException("No data has been prepared, call Request first");
     126        throw new FaultException("No data has been prepared, call Request first.");
    158127      byte[] chunk = new byte[Math.Min(size, dataStream.Length - dataStream.Position)];
    159128      dataStream.Read(chunk, 0, chunk.Length);
     
    167136    /// <param name="id">The entity id.</param>
    168137    public void Submit(EntityType type, int id) {
    169       Log("Submitting", type, id);
    170138      EnsureInit();
    171139      GetData(type, id);
     
    189157    /// </summary>
    190158    public void TransferDone() {
    191       Log("commiting transfer");
    192159      if (mode == Mode.Submit)
    193160        SetData(type, id, dataStream.ToArray());
     
    201168      Dispose();
    202169    }
    203 
    204170    #endregion
    205171
    206172    #region IDisposable Members
    207 
    208173    /// <summary>
    209174    /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
    210175    /// </summary>
    211176    public void Dispose() {
    212       Log("disposing");
    213177      mode = Mode.None;
    214178      if (dataStream != null)
    215179        dataStream.Dispose();
    216180    }
    217 
    218181    #endregion
    219182  }
  • trunk/sources/HeuristicLab.Services.OKB/3.3/HeuristicLab.Services.OKB-3.3.csproj

    r4321 r4381  
    128128    <Compile Include="Interfaces\IDataService.cs" />
    129129    <Compile Include="Interfaces\IQueryService.cs" />
    130     <Compile Include="Interfaces\IRunnerService.cs" />
     130    <Compile Include="Interfaces\IRunnerService.cs">
     131      <SubType>Code</SubType>
     132    </Compile>
    131133    <Compile Include="Interfaces\ITableService.cs" />
    132134    <Compile Include="Properties\AssemblyInfo.cs" />
    133135    <Compile Include="QueryService.cs" />
    134     <Compile Include="RunnerService.cs" />
     136    <Compile Include="RunnerService.cs">
     137      <SubType>Code</SubType>
     138    </Compile>
    135139    <Compile Include="StarterKit.cs" />
    136140    <Compile Include="TableService.cs" />
  • trunk/sources/HeuristicLab.Services.OKB/3.3/Interfaces/IAdminService.cs

    r4279 r4381  
    2525
    2626namespace HeuristicLab.Services.OKB {
    27 
    2827  /// <summary>
    2928  /// Allows updating the implementation of algorithms and problems. All
     
    3837    /// <returns>A list of <see cref="Platform"/>s.</returns>
    3938    [OperationContract]
    40     Platform[] GetPlatformNames();
     39    Platform[] GetPlatforms();
    4140
    4241    /// <summary>
     
    109108    [OperationContract]
    110109    void UpdateCompleteProblem(Problem problem);
    111 
    112110  }
    113111}
  • trunk/sources/HeuristicLab.Services.OKB/3.3/Interfaces/IDataService.cs

    r4279 r4381  
    2424
    2525namespace HeuristicLab.Services.OKB {
    26 
    2726  /// <summary>
    2827  /// Choose between <see cref="Algorithm"/> or <see cref="Problem"/>.
     
    3029  public enum EntityType {
    3130    /// <summary>
    32     /// Selects <see cref="Algorithm"/> as entity type.
     31    /// Use <see cref="Algorithm"/> as entity type.
    3332    /// </summary>
    3433    Algorithm,
     
    9392    void AbortTransfer();
    9493  }
    95 
    9694}
  • trunk/sources/HeuristicLab.Services.OKB/3.3/Interfaces/IQueryService.cs

    r4279 r4381  
    2525
    2626namespace HeuristicLab.Services.OKB {
    27 
    2827  /// <summary>
    2928  /// Service interface for downloading selected information about <see cref="Experiment"/> <see cref="Run"/>s.
     
    3130  [ServiceContract(SessionMode = SessionMode.Required, ProtectionLevel = ProtectionLevel.EncryptAndSign)]
    3231  public interface IQueryService {
    33 
    3432    /// <summary>
    3533    /// Gets a list of all possible attribute selectors.
  • trunk/sources/HeuristicLab.Services.OKB/3.3/Interfaces/IRunnerService.cs

    r4313 r4381  
    3131  [ServiceContract(SessionMode = SessionMode.Required, ProtectionLevel = ProtectionLevel.EncryptAndSign)]
    3232  public interface IRunnerService {
    33 
    3433    /// <summary>
    3534    /// Logs the current user in. In case the user or client
     
    8685    /// <param name="project">The project.</param>
    8786    [OperationContract(IsInitiating = false)]
    88     void AddRun(Algorithm algorithm, Problem problem, Project project);
     87    void AddRun(Algorithm algorithm, Problem problem);
    8988
    9089    /// <summary>
     
    103102    void Logout();
    104103  }
    105 
    106104}
  • trunk/sources/HeuristicLab.Services.OKB/3.3/Interfaces/ITableService.cs

    r4279 r4381  
    2525
    2626namespace HeuristicLab.Services.OKB {
    27 
    2827  /// <summary>
    2928  /// Service interface for downloading and uploading data tables.
     
    7574    void DeleteTableRows(int[] ids, string tableName);
    7675  }
    77 
    7876}
  • trunk/sources/HeuristicLab.Services.OKB/3.3/QueryService.cs

    r4279 r4381  
    2727using HeuristicLab.Services.OKB.AttributeSelection;
    2828using HeuristicLab.Services.OKB.DataAccess;
    29 using log4net;
    3029
    3130namespace HeuristicLab.Services.OKB {
    32 
    3331  /// <summary>
    3432  /// Implementation of the <see cref="IQueryService"/>.
     
    3634  [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession, IncludeExceptionDetailInFaults = true)]
    3735  public class QueryService : IQueryService, IDisposable {
    38 
    39     private Guid sessionID;
    40     private static ILog logger = LogManager.GetLogger(typeof(QueryService));
    41 
    42     private void Log(string message, params object[] args) {
    43       using (log4net.ThreadContext.Stacks["NDC"].Push(sessionID.ToString())) {
    44         logger.Info(String.Format(message, args));
    45       }
    46     }
    47 
    48     /// <summary>
    49     /// Initializes a new instance of the <see cref="QueryService"/> class.
    50     /// </summary>
    51     public QueryService() {
    52       sessionID = Guid.NewGuid();
    53       Log("Instantiating new service");
    54     }
    55 
    56     private OKBDataContext GetDataContext() {
    57       return new OKBDataContext();
    58     }
    59 
    6036    /// <summary>
    6137    /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
     
    7652    /// </returns>
    7753    public AttributeSelector[] GetAllAttributeSelectors() {
    78       Log("retrieving all attribute specifiers");
    79       try {
    80         OKBDataContext okb = GetDataContext();
     54      using (OKBDataContext okb = new OKBDataContext()) {
    8155        return RunAttributeSelector.GetAllAttributeSelectors(okb).Select(s => new AttributeSelector(s)).ToArray();
    82       }
    83       catch (Exception x) {
    84         Log("exception caught: " + x.ToString());
    85         throw;
    8656      }
    8757    }
     
    9565    /// </returns>
    9666    public DataTable PrepareQuery(AttributeSelector[] selectors) {
    97       okb = GetDataContext();
    98       Log("validating new query");
    99       if (selectors.Length == 0)
    100         throw new FaultException("No columns selected");
    101       IEnumerable<RunAttributeSelector> checkedSelectors =
    102         selectors.Select(s => new RunAttributeSelector(new OKBDataContext(okb.Connection.ConnectionString), s)).ToList();
    103       Log("preparing query:\n  {0}", string.Join("\n  ", checkedSelectors.Select(s => s.ToString()).ToArray()));
    104       dataSetBuilder = new DataSetBuilder(okb, checkedSelectors);
    105       dataEnumerator = dataSetBuilder.GetEnumerator();
    106       return dataSetBuilder.Runs;
     67      using (OKBDataContext okb = new OKBDataContext()) {
     68        if (selectors.Length == 0)
     69          throw new FaultException("No columns selected");
     70        IEnumerable<RunAttributeSelector> checkedSelectors =
     71          selectors.Select(s => new RunAttributeSelector(new OKBDataContext(okb.Connection.ConnectionString), s)).ToList();
     72        dataSetBuilder = new DataSetBuilder(okb, checkedSelectors);
     73        dataEnumerator = dataSetBuilder.GetEnumerator();
     74        return dataSetBuilder.Runs;
     75      }
    10776    }
    10877
     
    137106    /// </summary>
    138107    public void Terminate() {
    139       Log("Terminating session");
    140108      dataSetBuilder = null;
    141109      if (dataEnumerator != null) {
    142         Log("disposing data enumerate");
    143110        dataEnumerator.Dispose();
    144111        dataEnumerator = null;
    145112      }
    146113      if (okb != null) {
    147         Log("disposing data context");
    148114        okb.Dispose();
    149115        okb = null;
    150116      }
    151117    }
    152 
    153118  }
    154119}
  • trunk/sources/HeuristicLab.Services.OKB/3.3/RunnerService.cs

    r4321 r4381  
    2727using System.Web.Security;
    2828using HeuristicLab.Services.OKB.DataAccess;
    29 using log4net;
    3029
    3130namespace HeuristicLab.Services.OKB {
    32 
    3331  /// <summary>
    3432  /// Implementation of the <see cref="IRunnerService"/>.
    3533  /// </summary>
    36   [ServiceBehavior(
    37     InstanceContextMode = InstanceContextMode.PerSession)]
     34  [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]
    3835  public class RunnerService : IRunnerService, IDisposable {
    39 
    40     private Guid sessionID;
    41     private static ILog logger = LogManager.GetLogger(typeof(RunnerService));
    42 
    43     private void Log(string message, params object[] args) {
    44       using (log4net.ThreadContext.Stacks["NDC"].Push(sessionID.ToString())) {
    45         logger.Info(String.Format(message, args));
    46       }
    47     }
    48 
    49     /// <summary>
    50     /// Initializes a new instance of the <see cref="RunnerService"/> class.
    51     /// </summary>
    52     public RunnerService() {
    53       sessionID = Guid.NewGuid();
    54       Log("Instantiating new service");
    55     }
    56 
    5736    /// <summary>
    5837    /// Obtain a "starter kit" of information, containing:
     
    6443    /// </summary>
    6544    public StarterKit GetStarterKit(string platformName) {
    66       Log("distributing starter kit");
    6745      Platform platform;
    6846      using (OKBDataContext okb = new OKBDataContext()) {
     
    8664        var StarterKit = new StarterKit() {
    8765          AlgorithmClasses = okb.AlgorithmClasses.ToList(),
    88           ProblemClasses = okb.ProblemClasses.ToList(),
    89           Projects = okb.Projects.ToList()
     66          ProblemClasses = okb.ProblemClasses.ToList()
    9067        };
    9168        return StarterKit;
     
    10077    /// </summary>
    10178    public ExperimentKit PrepareExperiment(Algorithm algorithm, Problem problem) {
    102       Log("preparing experiment: {0}@{1}", algorithm.Name, problem.Name);
    10379      OKBDataContext okb = new OKBDataContext();
    10480      try {
    10581        DataLoadOptions dlo = new DataLoadOptions();
    10682        dlo.LoadWith<Problem>(p => p.SolutionRepresentation);
    107         dlo.LoadWith<Parameter>(p => p.DataType);
     83        dlo.LoadWith<AlgorithmParameter>(p => p.DataType);
     84        dlo.LoadWith<ProblemParameter>(p => p.DataType);
    10885        dlo.LoadWith<Result>(r => r.DataType);
    109         dlo.LoadWith<Algorithm_Parameter>(ap => ap.Parameter);
    110         dlo.LoadWith<Problem_Parameter>(pp => pp.Parameter);
    111         dlo.LoadWith<Algorithm_Result>(ar => ar.Result);
    11286        okb.LoadOptions = dlo;
    11387        algorithm = okb.Algorithms.Single(a => a.Id == algorithm.Id);
    11488        problem = okb.Problems.Single(p => p.Id == problem.Id);
    115         algorithm.Algorithm_Parameters.Load();
    116         algorithm.Algorithm_Results.Load();
    117         problem.IntProblemCharacteristicValues.Load();
    118         problem.FloatProblemCharacteristicValues.Load();
    119         problem.CharProblemCharacteristicValues.Load();
    120         problem.Problem_Parameters.Load();
     89        algorithm.AlgorithmParameters.Load();
     90        algorithm.Results.Load();
     91        problem.ProblemCharacteristicIntValues.Load();
     92        problem.ProblemCharacteristicFloatValues.Load();
     93        problem.ProblemCharacteristicStringValues.Load();
     94        problem.ProblemParameters.Load();
    12195        return new ExperimentKit() {
    12296          Algorithm = algorithm,
     
    12599      }
    126100      catch (Exception x) {
    127         Log("exception caught: " + x.ToString());
    128101        throw new FaultException("Excaption caught: " + x.ToString());
    129102      }
     
    141114    /// <param name="problem">The problem.</param>
    142115    /// <param name="project">The project.</param>
    143     public void AddRun(Algorithm algorithm, Problem problem, Project project) {
    144       Log("adding run for {0}@{1}({2})[{3}, {4}]",
    145         algorithm.Name, problem.Name, project.Name, currentUser.Name, currentClient.Name);
     116    public void AddRun(Algorithm algorithm, Problem problem) {
    146117      try {
    147118        using (OKBDataContext okb = new OKBDataContext()) {
    148           Experiment experiment = GetOrCreateExperiment(algorithm, problem, project, currentUser, okb);
     119          Experiment experiment = GetOrCreateExperiment(algorithm, problem, currentUser, okb);
    149120          Run run = new Run() {
    150121            Experiment = experiment,
     
    159130      }
    160131      catch (Exception x) {
    161         Log(x.ToString());
    162132        throw new FaultException("Could not add run: " + x.ToString());
    163133      }
    164134    }
    165135
    166     private Experiment GetOrCreateExperiment(Algorithm algorithm, Problem problem,
    167         Project project, User user, OKBDataContext okb) {
     136    private Experiment GetOrCreateExperiment(Algorithm algorithm, Problem problem, User user, OKBDataContext okb) {
    168137      MatchResults(algorithm.Results, okb);
    169138      EnsureParametersExist(algorithm.Parameters, okb);
    170       var experimentQuery = CreateExperimentQuery(algorithm, problem, project, okb);
     139      var experimentQuery = CreateExperimentQuery(algorithm, problem, okb);
    171140      if (experimentQuery.Count() > 0) {
    172         if (experimentQuery.Count() > 1)
    173           Log("Warning: duplicate experiment found");
    174         Log("reusing existing experiment");
    175141        Experiment experiment = experimentQuery.First();
    176142        return experiment;
    177143      } else {
    178         Log("creating new experiment");
    179144        Experiment experiment = new Experiment() {
    180145          AlgorithmId = algorithm.Id,
    181146          ProblemId = problem.Id,
    182           ProjectId = project.Id,
    183147          ParameterValues = algorithm.ParameterValues
    184148        };
     
    191155      foreach (var result in results.Where(r => r.Name != null)) {
    192156        result.Id = okb.Results.Single(r => r.Name == result.Name).Id;
    193         Log("mapping named result {0} -> Id {1}", result.Name, result.Id);
    194157        var value = result.ResultValue;
    195158        if (value != null) {
     
    205168        DataType dataType = GetOrCreateDataType(okb, param.DataType.ClrName);
    206169        param.DataType = new DataType() { Id = dataType.Id };
    207         Log("mapping datatype {0} to id {1}", dataType.ClrName, dataType.Id);
    208170      }
    209171      okb.SubmitChanges();
     
    211173      var newParams = namedParams.Except(okb.Parameters, new NameComprarer());
    212174      foreach (var p in newParams) {
    213         Log("creating new parameter {0} ({2}:{1})", p.Name, p.DataType.ClrName, p.DataType.Id);
    214175        okb.Parameters.InsertOnSubmit(new Parameter() {
    215176          Name = p.Name,
     
    220181      foreach (var np in namedParams) {
    221182        np.Id = okb.Parameters.Single(p => p.Name == np.Name).Id;
    222         Log("mapping named parameter {0} -> Id {1}", np.Name, np.Id);
    223183        var value = np.ParameterValue;
    224184        if (value != null) {
     
    231191            DataType dataType = GetOrCreateDataType(okb, opVal.DataType.ClrName);
    232192            newVal.DataType = new DataType() { Id = dataType.Id };
    233             Log("mapping operator parameter datatype {0} to id {1}", dataType.ClrName, dataType.Id);
    234193          }
    235194        }
     
    240199      DataType dataType = okb.DataTypes.SingleOrDefault(dt => dt.ClrName == clrName);
    241200      if (dataType == null) {
    242         Log("creating new datatype for ", clrName);
    243201        dataType = new DataType() {
    244202          ClrName = clrName,
     
    251209    }
    252210
    253     private IQueryable<Experiment> CreateExperimentQuery(Algorithm algorithm, Problem problem, Project project,
    254         OKBDataContext okb) {
     211    private IQueryable<Experiment> CreateExperimentQuery(Algorithm algorithm, Problem problem, OKBDataContext okb) {
    255212      var experimentQuery =
    256213        from x in okb.Experiments
    257214        where x.Algorithm == algorithm
    258215        where x.Problem == problem
    259         where x.ProjectId == project.Id
    260216        select x;
    261217      foreach (IntParameterValue ipv in algorithm.IntParameterValues) {
     
    279235            p.ParameterId == opv.ParameterId && p.DataTypeId == opv.DataTypeId));
    280236      }
    281       Log("experiment query: ", experimentQuery.Expression.ToString());
    282237      return experimentQuery;
    283238    }
     
    310265      MembershipUser user = Membership.GetUser();
    311266
    312       Log("Authenticating {0}@{1}", user.UserName, clientname);
    313267      if (user == null ||
    314268          string.IsNullOrEmpty(clientname) ||
    315269          ServiceSecurityContext.Current.IsAnonymous) {
    316         Log("rejecting anonymous login");
    317270        return false;
    318271      }
     
    330283          okb.SubmitChanges();
    331284        }
    332         Log("  user = {0}, client = {1}", currentUser, currentClient);
    333285        return true;
    334286      }
     
    339291    /// </summary>
    340292    public void Logout() {
    341       Log("Logging out");
    342293      currentUser = null;
    343294      currentClient = null;
     
    348299    /// </summary>
    349300    public void Dispose() {
    350       Log("Closing session...");
    351301      Logout();
    352302    }
     
    383333      return obj.Name.GetHashCode();
    384334    }
    385 
    386335  }
    387336}
  • trunk/sources/HeuristicLab.Services.OKB/3.3/StarterKit.cs

    r4279 r4381  
    5050    [DataMember]
    5151    public IEnumerable<ProblemClass> ProblemClasses { get; set; }
    52 
    53     /// <summary>
    54     /// Gets a list of all available projects.
    55     /// </summary>
    56     /// <value>The projects.</value>
    57     [DataMember]
    58     public IEnumerable<Project> Projects { get; set; }
    5952  }
    6053
  • trunk/sources/HeuristicLab.Services.OKB/3.3/TableService.cs

    r4313 r4381  
    3131using HeuristicLab.Services.OKB.AttributeSelection;
    3232using HeuristicLab.Services.OKB.DataAccess;
    33 using log4net;
    3433
    3534namespace HeuristicLab.Services.OKB {
     
    3837  /// Implementation of the <see cref="ITableService"/>.
    3938  /// </summary>
    40   [ServiceBehavior(
    41     InstanceContextMode = InstanceContextMode.PerSession,
    42     IncludeExceptionDetailInFaults = true)]
     39  [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession, IncludeExceptionDetailInFaults = true)]
    4340  public class TableService : ITableService, IDisposable {
    44 
    45     private static ILog logger = LogManager.GetLogger(typeof(TableService));
    46 
    47     private OKBDataContext GetDataContext() {
    48       return new OKBDataContext();
    49     }
    50 
    5141    private static List<Type> SupportedTypes = new List<Type>() {
    5242      typeof(int),
     43      typeof(long),
    5344      typeof(double),
    5445      typeof(string),
     
    5748    };
    5849
     50    private DataTable tableTemplate;
     51    private IEnumerable<PropertyInfo> properties;
     52    private IEnumerator rowEnumerator;
     53
    5954    #region ITableService Members
    60 
    6155    /// <summary>
    6256    /// Updates the data table.
     
    6559    /// <param name="tableName">Name of the table.</param>
    6660    public void UpdateDataTable(DataTable updatedRows, string tableName) {
    67       logger.Info("updating table: " + tableName);
    6861      Type tableType = Assembly.GetAssembly(typeof(Run)).GetType("HeuristicLab.Services.OKB.DataAccess." + tableName, true);
    6962      var properties = from p in tableType.GetProperties()
    7063                       where SupportedTypes.Contains(p.PropertyType)
    7164                       select p;
    72       OKBDataContext okb = GetDataContext();
    73       ITable table = okb.GetTable(tableType);
    74       foreach (DataRow row in updatedRows.Rows) {
    75         if (row["Id"] == DBNull.Value)
    76           table.InsertOnSubmit(CreateEntity(tableType, properties, row));
    77       }
    78       var updated = updatedRows.Rows.Cast<DataRow>().Where(row => row["Id"] != DBNull.Value).OrderBy(row => row["Id"]);
    79       var entities = DataSetBuilder.GetEntities(okb, tableType, updated.Select(u => (int)u["Id"]));
    80       var updateEnum = updated.GetEnumerator();
    81       var entityEnum = entities.GetEnumerator();
    82       while (updateEnum.MoveNext() && entityEnum.MoveNext()) {
    83         bool idChecked = false;
    84         foreach (var property in properties) {
    85           Console.WriteLine("{0}.{1} = '{2}' -> '{3}'",
    86             tableName, property.Name,
    87             property.GetGetMethod().Invoke(entityEnum.Current, new object[0]),
    88             updateEnum.Current[property.Name]);
    89           if (property.Name == "Id") {
    90             int entityId = (int)property.GetGetMethod().Invoke(entityEnum.Current, new object[0]);
    91             int updateId = (int)updateEnum.Current["Id"];
    92             Debug.Assert(entityId == updateId);
    93             idChecked = true;
     65      using (OKBDataContext okb = new OKBDataContext()) {
     66        ITable table = okb.GetTable(tableType);
     67        foreach (DataRow row in updatedRows.Rows) {
     68          if (row["Id"] == DBNull.Value)
     69            table.InsertOnSubmit(CreateEntity(tableType, properties, row));
     70        }
     71        var updated = updatedRows.Rows.Cast<DataRow>().Where(row => row["Id"] != DBNull.Value).OrderBy(row => row["Id"]);
     72        var entities = DataSetBuilder.GetEntities(okb, tableType, updated.Select(u => (int)u["Id"]));
     73        var updateEnum = updated.GetEnumerator();
     74        var entityEnum = entities.GetEnumerator();
     75        while (updateEnum.MoveNext() && entityEnum.MoveNext()) {
     76          bool idChecked = false;
     77          foreach (var property in properties) {
     78            Console.WriteLine("{0}.{1} = '{2}' -> '{3}'",
     79              tableName, property.Name,
     80              property.GetGetMethod().Invoke(entityEnum.Current, new object[0]),
     81              updateEnum.Current[property.Name]);
     82            if (property.Name == "Id") {
     83              int entityId = (int)property.GetGetMethod().Invoke(entityEnum.Current, new object[0]);
     84              int updateId = (int)updateEnum.Current["Id"];
     85              Debug.Assert(entityId == updateId);
     86              idChecked = true;
     87            }
     88            object newValue = updateEnum.Current[property.Name];
     89            if (newValue != DBNull.Value)
     90              property.GetSetMethod().Invoke(entityEnum.Current, new object[] { newValue });
    9491          }
    95           object newValue = updateEnum.Current[property.Name];
    96           if (newValue != DBNull.Value)
    97             property.GetSetMethod().Invoke(entityEnum.Current, new object[] { newValue });
    98         }
    99         Debug.Assert(idChecked);
    100       }
    101       okb.SubmitChanges();
     92          Debug.Assert(idChecked);
     93        }
     94        okb.SubmitChanges();
     95      }
    10296    }
    10397
    10498    private object CreateEntity(Type tableType, IEnumerable<PropertyInfo> properties, DataRow row) {
    10599      object instance = Activator.CreateInstance(tableType);
    106       logger.Info("Creating new instance of " + tableType.Name);
    107100      bool empty = true;
    108101      foreach (var property in properties) {
     
    125118    /// <param name="tableName">Name of the table.</param>
    126119    public void DeleteTableRows(int[] ids, string tableName) {
    127       logger.Info("delete rows from table: " + tableName);
    128120      Type tableType = Assembly.GetAssembly(typeof(Run)).GetType("HeuristicLab.Services.OKB.DataAccess" + tableName, true);
    129       OKBDataContext okb = GetDataContext();
    130       ITable table = okb.GetTable(tableType);
    131       table.DeleteAllOnSubmit(DataSetBuilder.GetEntities(okb, tableType, ids));
    132       okb.SubmitChanges();
    133     }
    134 
    135     private DataTable tableTemplate;
    136     private IEnumerable<PropertyInfo> properties;
    137     private IEnumerator rowEnumerator;
     121      using (OKBDataContext okb = new OKBDataContext()) {
     122        ITable table = okb.GetTable(tableType);
     123        table.DeleteAllOnSubmit(DataSetBuilder.GetEntities(okb, tableType, ids));
     124        okb.SubmitChanges();
     125      }
     126    }
    138127
    139128    /// <summary>
     
    147136    /// </returns>
    148137    public DataTable PrepareDataTable(string tableName, out int count) {
    149       logger.Info("preparing data table: " + tableName);
    150138      Type tableType = Assembly.GetAssembly(typeof(Run)).GetType("HeuristicLab.Services.OKB.DataAccess." + tableName, true);
    151139      properties = from p in tableType.GetProperties()
     
    163151        tableTemplate.Columns.Add(column);
    164152      }
    165       OKBDataContext okb = GetDataContext();
    166       ITable table = okb.GetTable(tableType);
    167       rowEnumerator = table.GetEnumerator();
    168       count = DataSetBuilder.CountEntities(GetDataContext(), tableType);
    169       return tableTemplate;
     153      using (OKBDataContext okb = new OKBDataContext()) {
     154        ITable table = okb.GetTable(tableType);
     155        rowEnumerator = table.GetEnumerator();
     156        count = DataSetBuilder.CountEntities(new OKBDataContext(), tableType);
     157        return tableTemplate;
     158      }
    170159    }
    171160
     
    198187      Dispose();
    199188    }
    200 
    201189    #endregion
    202190
    203191    #region IDisposable Members
    204 
    205192    /// <summary>
    206193    /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
     
    210197      properties = null;
    211198    }
    212 
    213199    #endregion
    214200  }
Note: See TracChangeset for help on using the changeset viewer.