Free cookie consent management tool by TermsFeed Policy Generator

Changeset 925


Ignore:
Timestamp:
12/07/08 18:03:51 (15 years ago)
Author:
svonolfe
Message:

Added caching, thread safety to DataAccess layer (#372)

Location:
trunk/sources
Files:
5 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Hive.Contracts/HeuristicLab.Hive.Contracts.csproj

    r902 r925  
    44    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    55    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    6     <ProductVersion>9.0.30729</ProductVersion>
     6    <ProductVersion>9.0.21022</ProductVersion>
    77    <SchemaVersion>2.0</SchemaVersion>
    88    <ProjectGuid>{134F93D7-E7C8-4ECD-9923-7F63259A60D8}</ProjectGuid>
     
    8787    <Compile Include="Interfaces\IClientManager.cs" />
    8888    <Compile Include="Interfaces\IJobManager.cs" />
     89    <Compile Include="Interfaces\ILifecycleManager.cs" />
    8990    <Compile Include="Interfaces\IServerConsoleFacade.cs" />
    9091    <Compile Include="Interfaces\IUserRoleManager.cs" />
  • trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/ClientAdapter.cs

    r899 r925  
    2626using HeuristicLab.Hive.Server.Core.InternalInterfaces.DataAccess;
    2727using HeuristicLab.Hive.Contracts.BusinessObjects;
     28using System.Linq.Expressions;
     29using System.Runtime.CompilerServices;
    2830
    2931namespace HeuristicLab.Hive.Server.ADODataAccess {
    30   class ClientAdapter: IClientAdapter {
     32  class ClientAdapter: DataAdapterBase, IClientAdapter {
    3133    private dsHiveServerTableAdapters.ClientTableAdapter adapter =
    3234        new dsHiveServerTableAdapters.ClientTableAdapter();
    3335
    34     private ResourceAdapter resAdapter =
    35       new ResourceAdapter();
     36    private dsHiveServer.ClientDataTable data =
     37      new dsHiveServer.ClientDataTable();
     38
     39    private IResourceAdapter resAdapter =
     40      ServiceLocator.GetResourceAdapter();
     41
     42    public ClientAdapter() {
     43      adapter.Fill(data);
     44    }
     45
     46    protected override void Update() {
     47      this.adapter.Update(this.data);
     48    }
    3649   
    37     #region IClientAdapter Members
    3850    private ClientInfo Convert(dsHiveServer.ClientRow row,
    3951      ClientInfo client) {
     
    4153        /*Parent - resource*/
    4254        client.ResourceId = row.ResourceId;
    43         resAdapter.FillResource(client);
     55        resAdapter.GetResourceById(client);
    4456
    4557        /*ClientInfo*/
     
    8294      dsHiveServer.ClientRow row) {
    8395      if (client != null && row != null) {     
    84         row.ResourceId = client.ResourceId;
    8596        row.GUID = client.ClientId;
    8697        row.CPUSpeed = client.CpuSpeedPerCore;
     
    100111    }
    101112
     113    #region IClientAdapter Members
     114    [MethodImpl(MethodImplOptions.Synchronized)]
    102115    public void UpdateClient(ClientInfo client) {
    103116      if (client != null) {
    104117        resAdapter.UpdateResource(client);
    105118
    106         dsHiveServer.ClientDataTable data =
    107           adapter.GetDataById(client.ClientId);
     119        dsHiveServer.ClientRow row =
     120          data.FindByResourceId(client.ResourceId);
    108121
    109         dsHiveServer.ClientRow row;
    110         if (data.Count == 0) {
     122        if (row == null) {
    111123          row = data.NewClientRow();
    112124          row.ResourceId = client.ResourceId;
    113125          data.AddClientRow(row);
    114         } else {
    115           row = data[0];
    116         }
     126        }
    117127
    118128        Convert(client, row);
    119 
    120         adapter.Update(data);
    121129      }
    122130    }
     
    124132    public ClientInfo GetClientById(Guid clientId) {
    125133      ClientInfo client = new ClientInfo();
    126      
    127       dsHiveServer.ClientDataTable data =
    128           adapter.GetDataById(clientId);
    129       if (data.Count == 1) {
    130         dsHiveServer.ClientRow row =
    131           data[0];
     134
     135      dsHiveServer.ClientRow row =
     136        data.Single<dsHiveServer.ClientRow>(
     137          r => !r.IsGUIDNull() && r.GUID == clientId);
     138
     139      if (row != null) {
    132140        Convert(row, client);
    133141
     
    142150        new List<ClientInfo>();
    143151
    144       dsHiveServer.ClientDataTable data =
    145           adapter.GetData();
    146 
    147152      foreach (dsHiveServer.ClientRow row in data) {
    148153        ClientInfo client = new ClientInfo();
     
    154159    }
    155160
     161    [MethodImpl(MethodImplOptions.Synchronized)]
    156162    public bool DeleteClient(ClientInfo client) {
    157       //referential integrity will delete the client object
    158       return resAdapter.DeleteResource(client);
     163      if (client != null) {
     164        dsHiveServer.ClientRow row =
     165          data.Single<dsHiveServer.ClientRow>(
     166            r => r.GUID == client.ClientId);
     167
     168        if (row != null) {
     169          data.RemoveClientRow(row);
     170
     171          return resAdapter.DeleteResource(client);
     172        }
     173      }
     174
     175      return false;
    159176    }
    160177
  • trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/HeuristicLab.Hive.Server.ADODataAccess.csproj

    r910 r925  
    44    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    55    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    6     <ProductVersion>9.0.30729</ProductVersion>
     6    <ProductVersion>9.0.21022</ProductVersion>
    77    <SchemaVersion>2.0</SchemaVersion>
    88    <ProjectGuid>{715A9134-B6E4-4CB9-8A5A-E6601497565A}</ProjectGuid>
     
    6666    <Compile Include="ClientAdapter.cs" />
    6767    <Compile Include="ClientGroupAdapter.cs" />
     68    <Compile Include="DataAdapterBase.cs" />
    6869    <Compile Include="dsHiveServer.cs">
    6970      <DependentUpon>dsHiveServer.xsd</DependentUpon>
     
    8485    </Compile>
    8586    <Compile Include="ResourceAdapter.cs" />
     87    <Compile Include="TransactionManager.cs" />
    8688    <Compile Include="UserAdapter.cs" />
    8789    <Compile Include="UserGroupAdapter.cs" />
  • trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/PermissionOwnerAdapter.cs

    r905 r925  
    2727using HeuristicLab.Hive.Server.Core.InternalInterfaces.DataAccess;
    2828using HeuristicLab.Hive.Contracts.BusinessObjects;
     29using System.Runtime.CompilerServices;
    2930
    3031namespace HeuristicLab.Hive.Server.ADODataAccess {
    31   class PermissionOwnerAdapter: IPermissionOwner {
    32     #region IPermissionOwner Members
     32  class PermissionOwnerAdapter: DataAdapterBase, IPermissionOwnerAdapter {
    3333    private dsHiveServerTableAdapters.PermissionOwnerTableAdapter adapter =
    3434     new dsHiveServerTableAdapters.PermissionOwnerTableAdapter();
    3535
    36     private PermissionOwner Convert(dsHiveServer.PermissionOwnerRow row,
     36    private dsHiveServer.PermissionOwnerDataTable data =
     37      new dsHiveServer.PermissionOwnerDataTable();
     38
     39    public PermissionOwnerAdapter() {
     40      adapter.Fill(data);
     41    }
     42
     43    protected override void Update() {
     44      this.adapter.Update(this.data);
     45    }
     46
     47    private PermissionOwner Convert(dsHiveServer.PermissionOwnerRow row,
    3748      PermissionOwner permOwner) {
    3849      if (row != null && permOwner != null) {
     
    5263      dsHiveServer.PermissionOwnerRow row) {
    5364      if (row != null && permOwner != null) {
    54         row.PermissionOwnerId = permOwner.PermissionOwnerId;
    5565        row.Name = permOwner.Name;
    5666
     
    5969        return null;
    6070    }
    61 
     71   
     72    #region IPermissionOwner Members
     73    [MethodImpl(MethodImplOptions.Synchronized)]
    6274    public void UpdatePermissionOwner(PermissionOwner permOwner) {
    6375      if (permOwner != null) {
    64         dsHiveServer.PermissionOwnerDataTable data =
    65           adapter.GetDataById(permOwner.PermissionOwnerId);
    66 
    67         dsHiveServer.PermissionOwnerRow row;
    68         if (data.Count == 0) {
     76        dsHiveServer.PermissionOwnerRow row =
     77          data.FindByPermissionOwnerId(permOwner.PermissionOwnerId);
     78       
     79        if (row == null) {
    6980          row = data.NewPermissionOwnerRow();
    7081          data.AddPermissionOwnerRow(row);
    71         } else {
    72           row = data[0];
     82
     83          //write row to db to get primary key
     84          adapter.Update(row);
    7385        }
    7486
    75         row.Name = permOwner.Name;
    76 
    77         adapter.Update(data);
    78 
     87        Convert(permOwner, row);
    7988        permOwner.PermissionOwnerId = row.PermissionOwnerId;
    8089      }
    8190    }
    8291
    83     internal bool FillPermissionOwner(PermissionOwner permOwner) {
     92    public bool GetPermissionOwnerById(PermissionOwner permOwner) {
    8493      if (permOwner != null) {
    85         dsHiveServer.PermissionOwnerDataTable data =
    86           adapter.GetDataById(permOwner.PermissionOwnerId);
    87         if (data.Count == 1) {
    8894          dsHiveServer.PermissionOwnerRow row =
    89             data[0];
     95            data.FindByPermissionOwnerId(permOwner.PermissionOwnerId);
     96
     97        if(row != null) {
    9098          Convert(row, permOwner);
    9199
     
    101109      permOwner.PermissionOwnerId = permOwnerId;
    102110
    103       if (FillPermissionOwner(permOwner))
     111      if (GetPermissionOwnerById(permOwner))
    104112        return permOwner;
    105113      else
     
    107115    }
    108116
     117    public PermissionOwner GetPermissionOwnerByName(String name) {
     118      PermissionOwner permOwner = new PermissionOwner();
     119
     120      dsHiveServer.PermissionOwnerRow row =
     121        data.Single<dsHiveServer.PermissionOwnerRow>(
     122          r => !r.IsNameNull() && r.Name == name);
     123
     124      if (row != null) {
     125        Convert(row, permOwner);
     126
     127        return permOwner;
     128      } else {
     129        return null;
     130      }
     131    }
     132
    109133    public ICollection<PermissionOwner> GetAllPermissionOwners() {
    110134      ICollection<PermissionOwner> allPermissionOwners =
    111135        new List<PermissionOwner>();
    112 
    113       dsHiveServer.PermissionOwnerDataTable data =
    114           adapter.GetData();
    115136
    116137      foreach (dsHiveServer.PermissionOwnerRow row in data) {
     
    123144    }
    124145
     146    [MethodImpl(MethodImplOptions.Synchronized)]
    125147    public bool DeletePermissionOwner(PermissionOwner permOwner) {
    126148      if (permOwner != null) {
    127         dsHiveServer.PermissionOwnerDataTable data =
    128            adapter.GetDataById(permOwner.PermissionOwnerId);
     149          dsHiveServer.PermissionOwnerRow row =
     150            data.FindByPermissionOwnerId(permOwner.PermissionOwnerId);
    129151
    130         if (data.Count == 1) {
    131           dsHiveServer.PermissionOwnerRow row = data[0];
     152          if(row != null) {
     153            data.RemovePermissionOwnerRow(row);
    132154
    133           row.Delete();
    134           return adapter.Update(data) > 0;
     155            return true;
     156          }
    135157        }
    136       }
    137158
    138159      return false;
  • trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/ResourceAdapter.cs

    r899 r925  
    2626using HeuristicLab.Hive.Server.Core.InternalInterfaces.DataAccess;
    2727using HeuristicLab.Hive.Contracts.BusinessObjects;
     28using System.Runtime.CompilerServices;
    2829
    2930namespace HeuristicLab.Hive.Server.ADODataAccess {
    30   class ResourceAdapter: IResourceAdapter {
    31     #region IResourceAdapter Members
     31  class ResourceAdapter: DataAdapterBase, IResourceAdapter {
    3232    private dsHiveServerTableAdapters.ResourceTableAdapter adapter =
    33       new dsHiveServerTableAdapters.ResourceTableAdapter();
     33        new dsHiveServerTableAdapters.ResourceTableAdapter();
    3434
    35     private Resource Convert(dsHiveServer.ResourceRow row,
     35    private dsHiveServer.ResourceDataTable data =
     36        new dsHiveServer.ResourceDataTable();
     37
     38    public ResourceAdapter() {
     39      adapter.Fill(data);
     40    }
     41
     42    protected override void Update() {
     43      this.adapter.Update(this.data);
     44    }
     45
     46    private Resource Convert(dsHiveServer.ResourceRow row,
    3647      Resource resource) {
    3748      if (row != null && resource != null) {
     
    4354
    4455        return resource;
    45       } else 
     56      } else
    4657        return null;
    4758    }
     
    5768    }
    5869
     70    #region IResourceAdapter Members
     71    [MethodImpl(MethodImplOptions.Synchronized)]
    5972    public void UpdateResource(Resource resource) {
    6073      if (resource != null) {
    61         dsHiveServer.ResourceDataTable data =
    62           adapter.GetDataById(resource.ResourceId);
     74        dsHiveServer.ResourceRow row =
     75          data.FindByResourceId(resource.ResourceId);
    6376
    64         dsHiveServer.ResourceRow row;
    65         if (data.Count == 0) {
     77        if (row == null) {
    6678          row = data.NewResourceRow();
    6779          data.AddResourceRow(row);
    68         } else {
    69           row = data[0];
    70         }
     80
     81          //write row to db to get primary key
     82          adapter.Update(row);
     83        }
    7184
    7285        Convert(resource, row);
    73 
    74         adapter.Update(data);
    75 
    7686        resource.ResourceId = row.ResourceId;
    7787      }
    7888    }
    7989
    80     internal bool FillResource(Resource resource) {
     90    public bool GetResourceById(Resource resource) {
    8191      if (resource != null) {
    82         dsHiveServer.ResourceDataTable data =
    83           adapter.GetDataById(resource.ResourceId);
    84         if (data.Count == 1) {
    85           dsHiveServer.ResourceRow row =
    86             data[0];
     92        dsHiveServer.ResourceRow row =
     93          data.FindByResourceId(resource.ResourceId);
     94        if (row != null) {
    8795          Convert(row, resource);
    8896
     
    98106      resource.ResourceId = resourceId;
    99107
    100       if(FillResource(resource))
     108      if(GetResourceById(resource))
    101109        return resource;
    102110      else
     
    105113
    106114    public ICollection<Resource> GetAllResources() {
    107       ICollection<Resource> allResources =
     115      IList<Resource> allResources =
    108116        new List<Resource>();
    109 
    110       dsHiveServer.ResourceDataTable data =
    111           adapter.GetData();
    112 
     117     
    113118      foreach (dsHiveServer.ResourceRow row in data) {
    114119        Resource resource = new Resource();
     
    120125    }
    121126
     127    [MethodImpl(MethodImplOptions.Synchronized)]
    122128    public bool DeleteResource(Resource resource) {
    123129      if(resource != null) {
     130        dsHiveServer.ResourceRow row =
     131          data.FindByResourceId(resource.ResourceId);
    124132
    125         dsHiveServer.ResourceDataTable data =
    126            adapter.GetDataById(resource.ResourceId);
     133        if (row != null) {
     134          data.RemoveResourceRow(row);
    127135
    128         if (data.Count == 1) {
    129           dsHiveServer.ResourceRow row = data[0];
    130 
    131           row.Delete();
    132           return adapter.Update(data) > 0;
     136          return true;
    133137        }
    134138      }
  • trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/UserAdapter.cs

    r905 r925  
    2727using HeuristicLab.Hive.Server.Core.InternalInterfaces.DataAccess;
    2828using HeuristicLab.Hive.Contracts.BusinessObjects;
     29using System.Runtime.CompilerServices;
    2930
    3031namespace HeuristicLab.Hive.Server.ADODataAccess {
    31   class UserAdapter: IUserAdapter {
     32  class UserAdapter : DataAdapterBase, IUserAdapter {
    3233    private dsHiveServerTableAdapters.HiveUserTableAdapter adapter =
    3334        new dsHiveServerTableAdapters.HiveUserTableAdapter();
    3435
    35     private PermissionOwnerAdapter permOwnerAdapter =
    36       new PermissionOwnerAdapter();
     36    private dsHiveServer.HiveUserDataTable data =
     37        new dsHiveServer.HiveUserDataTable();
     38
     39    private IPermissionOwnerAdapter permOwnerAdapter =
     40       ServiceLocator.GetPermissionOwnerAdapter();
     41
     42    public UserAdapter() {
     43      adapter.Fill(data);
     44    }
     45
     46    protected override void Update() {
     47      this.adapter.Update(this.data);
     48    }
    3749
    3850    private User Convert(dsHiveServer.HiveUserRow row,
     
    4153        /*Parent - PermissionOwner*/
    4254        user.PermissionOwnerId = row.PermissionOwnerId;
    43         permOwnerAdapter.FillPermissionOwner(user);
     55        permOwnerAdapter.GetPermissionOwnerById(user);
    4456
    4557        /*User*/
     
    5769      dsHiveServer.HiveUserRow row) {
    5870      if (user != null && row != null) {
    59         row.PermissionOwnerId = user.PermissionOwnerId;
    6071        row.Password = user.Password;
    6172
     
    6778    #region IUserAdapter Members
    6879
     80    [MethodImpl(MethodImplOptions.Synchronized)]
    6981    public void UpdateUser(User user) {
    7082      if (user != null) {
    7183        permOwnerAdapter.UpdatePermissionOwner(user);
    7284
    73         dsHiveServer.HiveUserDataTable data =
    74           adapter.GetDataById(user.PermissionOwnerId);
    75 
    76         dsHiveServer.HiveUserRow row;
    77         if (data.Count == 0) {
     85        dsHiveServer.HiveUserRow row =
     86          data.FindByPermissionOwnerId(user.PermissionOwnerId);
     87        if (row == null) {
    7888          row = data.NewHiveUserRow();
    7989          row.PermissionOwnerId = user.PermissionOwnerId;
    8090          data.AddHiveUserRow(row);
    81         } else {
    82           row = data[0];
    83         }
     91        }
    8492
    8593        Convert(user, row);
    86 
    87         adapter.Update(data);
    8894      }
    8995    }
     
    9298      User user = new User();
    9399
    94       dsHiveServer.HiveUserDataTable data =
    95           adapter.GetDataById(userId);
    96       if (data.Count == 1) {
    97         dsHiveServer.HiveUserRow row =
    98           data[0];
     100      dsHiveServer.HiveUserRow row =
     101          data.FindByPermissionOwnerId(userId);
     102
     103      if(row != null) {
    99104        Convert(row, user);
    100105
     
    108113      User user = new User();
    109114
    110       dsHiveServer.HiveUserDataTable data =
    111           adapter.GetDataByName(name);
    112       if (data.Count == 1) {
     115      PermissionOwner permOwner =
     116        permOwnerAdapter.GetPermissionOwnerByName(name);
     117
     118      if (permOwner != null) {
    113119        dsHiveServer.HiveUserRow row =
    114           data[0];
    115         Convert(row, user);
     120          data.FindByPermissionOwnerId(permOwner.PermissionOwnerId);
    116121
    117         return user;
    118       } else {
    119         return null;
     122        if (row != null) {
     123          Convert(row, user);
     124
     125          return user;
     126        }
    120127      }
     128
     129      return null;
    121130    }
    122131
     
    124133      ICollection<User> allUsers =
    125134        new List<User>();
    126 
    127       dsHiveServer.HiveUserDataTable data =
    128           adapter.GetData();
    129135
    130136      foreach (dsHiveServer.HiveUserRow row in data) {
     
    137143    }
    138144
     145    [MethodImpl(MethodImplOptions.Synchronized)]
    139146    public bool DeleteUser(User user) {
    140       //referential integrity will delete the client object
    141       return permOwnerAdapter.DeletePermissionOwner(user);
     147      if (user != null) {
     148        dsHiveServer.HiveUserRow row =
     149          data.FindByPermissionOwnerId(user.PermissionOwnerId);
     150
     151        if (row != null) {
     152          data.RemoveHiveUserRow(row);
     153
     154          return permOwnerAdapter.DeletePermissionOwner(user);
     155        }
     156      }
     157
     158      return false;
    142159    }
    143160
  • trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/dsHiveServer.Designer.cs

    r905 r925  
    22// <auto-generated>
    33//     This code was generated by a tool.
    4 //     Runtime Version:2.0.50727.3053
     4//     Runtime Version:2.0.50727.1433
    55//
    66//     Changes to this file may cause incorrect behavior and will be lost if
     
    36283628            }
    36293629            set {
     3630                if (((this._resourceTableAdapter != null)
     3631                            && (this.TableAdapterInstanceCount == 1))) {
     3632                    this._resourceTableAdapter = value;
     3633                    return;
     3634                }
     3635                if (((value != null)
     3636                            && (this.MatchTableAdapterConnection(value.Connection) == false))) {
     3637                    throw new global::System.ArgumentException("All TableAdapters managed by a TableAdapterManager must use the same connection s" +
     3638                            "tring.");
     3639                }
    36303640                this._resourceTableAdapter = value;
    36313641            }
     
    36413651            }
    36423652            set {
     3653                if (((this._clientTableAdapter != null)
     3654                            && (this.TableAdapterInstanceCount == 1))) {
     3655                    this._clientTableAdapter = value;
     3656                    return;
     3657                }
     3658                if (((value != null)
     3659                            && (this.MatchTableAdapterConnection(value.Connection) == false))) {
     3660                    throw new global::System.ArgumentException("All TableAdapters managed by a TableAdapterManager must use the same connection s" +
     3661                            "tring.");
     3662                }
    36433663                this._clientTableAdapter = value;
    36443664            }
     
    36543674            }
    36553675            set {
     3676                if (((this._hiveUserTableAdapter != null)
     3677                            && (this.TableAdapterInstanceCount == 1))) {
     3678                    this._hiveUserTableAdapter = value;
     3679                    return;
     3680                }
     3681                if (((value != null)
     3682                            && (this.MatchTableAdapterConnection(value.Connection) == false))) {
     3683                    throw new global::System.ArgumentException("All TableAdapters managed by a TableAdapterManager must use the same connection s" +
     3684                            "tring.");
     3685                }
    36563686                this._hiveUserTableAdapter = value;
    36573687            }
     
    36673697            }
    36683698            set {
     3699                if (((this._permissionOwnerTableAdapter != null)
     3700                            && (this.TableAdapterInstanceCount == 1))) {
     3701                    this._permissionOwnerTableAdapter = value;
     3702                    return;
     3703                }
     3704                if (((value != null)
     3705                            && (this.MatchTableAdapterConnection(value.Connection) == false))) {
     3706                    throw new global::System.ArgumentException("All TableAdapters managed by a TableAdapterManager must use the same connection s" +
     3707                            "tring.");
     3708                }
    36693709                this._permissionOwnerTableAdapter = value;
    36703710            }
     
    38933933                return 0;
    38943934            }
    3895             if (((this._resourceTableAdapter != null)
    3896                         && (this.MatchTableAdapterConnection(this._resourceTableAdapter.Connection) == false))) {
    3897                 throw new global::System.ArgumentException("All TableAdapters managed by a TableAdapterManager must use the same connection s" +
    3898                         "tring.");
    3899             }
    3900             if (((this._clientTableAdapter != null)
    3901                         && (this.MatchTableAdapterConnection(this._clientTableAdapter.Connection) == false))) {
    3902                 throw new global::System.ArgumentException("All TableAdapters managed by a TableAdapterManager must use the same connection s" +
    3903                         "tring.");
    3904             }
    3905             if (((this._hiveUserTableAdapter != null)
    3906                         && (this.MatchTableAdapterConnection(this._hiveUserTableAdapter.Connection) == false))) {
    3907                 throw new global::System.ArgumentException("All TableAdapters managed by a TableAdapterManager must use the same connection s" +
    3908                         "tring.");
    3909             }
    3910             if (((this._permissionOwnerTableAdapter != null)
    3911                         && (this.MatchTableAdapterConnection(this._permissionOwnerTableAdapter.Connection) == false))) {
    3912                 throw new global::System.ArgumentException("All TableAdapters managed by a TableAdapterManager must use the same connection s" +
    3913                         "tring.");
    3914             }
    39153935            global::System.Data.IDbConnection workConnection = this.Connection;
    39163936            if ((workConnection == null)) {
     
    39193939            }
    39203940            bool workConnOpened = false;
    3921             if (((workConnection.State & global::System.Data.ConnectionState.Broken)
    3922                         == global::System.Data.ConnectionState.Broken)) {
    3923                 workConnection.Close();
    3924             }
    3925             if ((workConnection.State == global::System.Data.ConnectionState.Closed)) {
     3941            if (((workConnection.State & global::System.Data.ConnectionState.Closed)
     3942                        == global::System.Data.ConnectionState.Closed)) {
    39263943                workConnection.Open();
    39273944                workConnOpened = true;
  • trunk/sources/HeuristicLab.Hive.Server.Core/DbTestApp.cs

    r905 r925  
    105105      TestClientAdapter();
    106106      TestUserAdapter();
     107
     108      ITransactionManager transactionManager =
     109        ServiceLocator.GetTransactionManager();
     110
     111      transactionManager.UpdateDB();
    107112    }
    108113  }
  • trunk/sources/HeuristicLab.Hive.Server.Core/HeuristicLab.Hive.Server.Core.csproj

    r913 r925  
    44    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    55    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    6     <ProductVersion>9.0.30729</ProductVersion>
     6    <ProductVersion>9.0.21022</ProductVersion>
    77    <SchemaVersion>2.0</SchemaVersion>
    88    <ProjectGuid>{898B31CF-81DC-453B-AEB3-BDF83197A7EE}</ProjectGuid>
     
    7575    <Compile Include="InternalInterfaces\DataAccess\IPermissionOwnerAdapter.cs" />
    7676    <Compile Include="InternalInterfaces\DataAccess\IResourceAdapter.cs" />
     77    <Compile Include="InternalInterfaces\DataAccess\ITransactionManager.cs" />
    7778    <Compile Include="InternalInterfaces\DataAccess\IUserAdapter.cs" />
    7879    <Compile Include="InternalInterfaces\DataAccess\IUserGroupAdapter.cs" />
    7980    <Compile Include="JobManager.cs" />
     81    <Compile Include="LifecycleManager.cs" />
    8082    <Compile Include="Properties\AssemblyInfo.cs" />
    8183    <Compile Include="ServerConsoleFacade.cs" />
  • trunk/sources/HeuristicLab.Hive.Server.Core/InternalInterfaces/DataAccess/IPermissionOwnerAdapter.cs

    r905 r925  
    3030  /// The permission owner database adapter
    3131  /// </summary>
    32   public interface IPermissionOwner {
     32  public interface IPermissionOwnerAdapter {
    3333    /// <summary>
    3434    /// Save or update the permission owner
     
    3838
    3939    /// <summary>
     40    /// Gets the permission owner and updates the values of the object
     41    /// </summary>
     42    /// <param name="resource"></param>
     43    /// <returns></returns>
     44    bool GetPermissionOwnerById(PermissionOwner permOwner);
     45
     46    /// <summary>
    4047    /// Get the permission owner with the specified ID
    4148    /// </summary>
     
    4350    /// <returns></returns>
    4451    PermissionOwner GetPermissionOwnerById(long permOwnerId);
     52
     53    /// <summary>
     54    /// Get the permission owner with the specified name
     55    /// </summary>
     56    /// <param name="clientId"></param>
     57    /// <returns></returns>
     58    PermissionOwner GetPermissionOwnerByName(String name);
    4559
    4660    /// <summary>
  • trunk/sources/HeuristicLab.Hive.Server.Core/InternalInterfaces/DataAccess/IResourceAdapter.cs

    r845 r925  
    4545
    4646    /// <summary>
     47    /// Gets the resource and updates the values of the object
     48    /// </summary>
     49    /// <param name="resource"></param>
     50    /// <returns></returns>
     51    bool GetResourceById(Resource resource);
     52
     53    /// <summary>
    4754    /// Get all resuorces
    4855    /// </summary>
  • trunk/sources/HeuristicLab.Hive.Server.Core/ServerConsoleFacade.cs

    r909 r925  
    9494    #endregion
    9595
    96 
    97     #region IServerConsoleFacade Members
    98 
    99     public Response Login(string userName, string password) {
    100       Response response = new Response();
    101       response.Success = true;
    102       return response;
    103     }
    104 
    105     #endregion
    10696  }
    10797}
  • trunk/sources/HeuristicLab.Hive.Server.Core/ServiceLocator.cs

    r910 r925  
    2222using HeuristicLab.Hive.Server.Core.InternalInterfaces.DataAccess;
    2323using HeuristicLab.PluginInfrastructure;
     24using System.Runtime.CompilerServices;
    2425
    2526/// <summary>
    2627/// The service locator for the server core
    2728/// </summary>
    28 class ServiceLocator {
     29public class ServiceLocator {
    2930  private static DiscoveryService discoveryService =
    3031    new DiscoveryService();
     32
     33  private static ITransactionManager transManager = null;
    3134
    3235  private static IClientAdapter clientAdapter = null;
     
    3437  private static IClientGroupAdapter clientGroupAdapter = null;
    3538
     39  private static IResourceAdapter resourceAdapter = null;
     40
    3641  private static IUserAdapter userAdapter = null;
    3742
    3843  private static IUserGroupAdapter userGroupAdapter = null;
    39  
     44
     45  private static IPermissionOwnerAdapter permOwnerAdapter = null;
     46
     47  /// <summary>
     48  /// Gets the db transaction manager
     49  /// </summary>
     50  /// <returns></returns>
     51  [MethodImpl(MethodImplOptions.Synchronized)]
     52  public static ITransactionManager GetTransactionManager() {
     53    if (transManager == null) {
     54      transManager = discoveryService.GetInstances<ITransactionManager>()[0];
     55    }
     56
     57    return transManager;
     58  }
     59
    4060  /// <summary>
    4161  /// Gets the client database adapter
    4262  /// </summary>
    4363  /// <returns></returns>
    44   internal static IClientAdapter GetClientAdapter() {
     64  [MethodImpl(MethodImplOptions.Synchronized)]
     65  public static IClientAdapter GetClientAdapter() {
    4566    if (clientAdapter == null) {
    4667      clientAdapter = discoveryService.GetInstances<IClientAdapter>()[0];
     
    5475  /// </summary>
    5576  /// <returns></returns>
    56   internal static IClientGroupAdapter GetClientGroupAdapter() {
     77  [MethodImpl(MethodImplOptions.Synchronized)]
     78  public static IClientGroupAdapter GetClientGroupAdapter() {
    5779    if (clientGroupAdapter == null) {
    5880      clientGroupAdapter = discoveryService.GetInstances<IClientGroupAdapter>()[0];
     
    6385
    6486  /// <summary>
     87  /// Gets the resource database adapter
     88  /// </summary>
     89  /// <returns></returns>
     90  [MethodImpl(MethodImplOptions.Synchronized)]
     91  public static IResourceAdapter GetResourceAdapter() {
     92    if (resourceAdapter == null) {
     93      resourceAdapter = discoveryService.GetInstances<IResourceAdapter>()[0];
     94    }
     95
     96    return resourceAdapter;
     97  }
     98
     99  /// <summary>
    65100  /// Gets the user database adapter
    66101  /// </summary>
    67102  /// <returns></returns>
    68   internal static IUserAdapter GetUserAdapter() {
     103  [MethodImpl(MethodImplOptions.Synchronized)]
     104  public static IUserAdapter GetUserAdapter() {
    69105    if (userAdapter == null) {
    70106      userAdapter = discoveryService.GetInstances<IUserAdapter>()[0];
     
    78114  /// </summary>
    79115  /// <returns></returns>
    80   internal static IUserGroupAdapter GetUserGroupAdapter() {
     116  [MethodImpl(MethodImplOptions.Synchronized)]
     117  public static IUserGroupAdapter GetUserGroupAdapter() {
    81118    if (userGroupAdapter == null) {
    82119      userGroupAdapter = discoveryService.GetInstances<IUserGroupAdapter>()[0];
     
    85122    return userGroupAdapter;
    86123  }
     124
     125  /// <summary>
     126  /// Gets the permission owner database adapter
     127  /// </summary>
     128  /// <returns></returns>
     129  [MethodImpl(MethodImplOptions.Synchronized)]
     130  public static IPermissionOwnerAdapter GetPermissionOwnerAdapter() {
     131    if (permOwnerAdapter == null) {
     132      permOwnerAdapter = discoveryService.GetInstances<IPermissionOwnerAdapter>()[0];
     133    }
     134
     135    return permOwnerAdapter;
     136  }
    87137}
  • trunk/sources/HeuristicLab.Hive.Server/HiveServerApplication.cs

    r805 r925  
    8888      if (serverConsoleInstances.Length > 0) {
    8989        ServiceHost serviceHost =
    90                 new ServiceHost(serverConsoleInstances[0].GetType(),
     90            new ServiceHost(serverConsoleInstances[0].GetType(),
    9191                  uriTcp);
    9292
     
    139139        StartServerConsoleFacade(uriTcp);
    140140
    141       Form mainForm = new MainForm(clientCommunicator.BaseAddresses[0],
    142         serverConsoleFacade.BaseAddresses[0]);
     141      ILifecycleManager[] lifecycleManagers =
     142         discService.GetInstances<ILifecycleManager>();
    143143
    144       Application.Run(mainForm);
     144      if (lifecycleManagers.Length > 0) {
     145        ILifecycleManager lifecycleManager =
     146          lifecycleManagers[0];
     147
     148        lifecycleManager.Init();
     149
     150        Form mainForm = new MainForm(clientCommunicator.BaseAddresses[0],
     151            serverConsoleFacade.BaseAddresses[0]);
     152
     153         Application.Run(mainForm);
     154
     155         lifecycleManager.Shtudown();
     156      }
    145157
    146158      clientCommunicator.Close();
    147159      serverConsoleFacade.Close();
     160
     161     
    148162    }
    149163  }
Note: See TracChangeset for help on using the changeset viewer.