Changeset 948


Ignore:
Timestamp:
12/10/08 15:03:00 (12 years ago)
Author:
svonolfe
Message:

Refactored DAL (#372)

Location:
trunk/sources
Files:
1 added
1 deleted
10 edited

Legend:

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

    r934 r948  
    8989    <Compile Include="Interfaces\ILifecycleManager.cs" />
    9090    <Compile Include="Interfaces\IServerConsoleFacade.cs" />
     91    <Compile Include="Interfaces\ITransactionManager.cs" />
    9192    <Compile Include="Interfaces\IUserRoleManager.cs" />
    9293    <Compile Include="JobBase.cs" />
  • trunk/sources/HeuristicLab.Hive.Contracts/Interfaces/ILifecycleManager.cs

    r925 r948  
    3636
    3737    /// <summary>
     38    /// Gets the transaction manager
     39    /// </summary>
     40    /// <returns></returns>
     41    ITransactionManager GetTransactionManager();
     42
     43    /// <summary>
    3844    /// Shuts the application down
    3945    /// </summary>
    40     void Shtudown();
     46    void Shutdown();
    4147  }
    4248}
  • trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/ClientAdapter.cs

    r936 r948  
    3737      new dsHiveServer.ClientDataTable();
    3838
    39     private IResourceAdapter resAdapter =
    40       ServiceLocator.GetResourceAdapter();
     39    private IResourceAdapter resAdapter = null;
     40
     41    private IResourceAdapter ResAdapter {
     42      get {
     43        if (resAdapter == null)
     44          resAdapter = ServiceLocator.GetResourceAdapter();
     45
     46        return resAdapter;
     47      }
     48    }
    4149
    4250    public ClientAdapter() {
     
    5361        /*Parent - resource*/
    5462        client.ResourceId = row.ResourceId;
    55         resAdapter.GetResourceById(client);
     63        ResAdapter.GetResourceById(client);
    5664
    5765        /*ClientInfo*/
     
    115123    public void UpdateClient(ClientInfo client) {
    116124      if (client != null) {
    117         resAdapter.UpdateResource(client);
     125        ResAdapter.UpdateResource(client);
    118126
    119127        dsHiveServer.ClientRow row =
     
    179187          data.RemoveClientRow(row);
    180188
    181           return resAdapter.DeleteResource(client);
     189          return ResAdapter.DeleteResource(client);
    182190        }
    183191      }
  • trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/TransactionManager.cs

    r925 r948  
    2626using HeuristicLab.Hive.Server.Core.InternalInterfaces.DataAccess;
    2727using System.Timers;
     28using HeuristicLab.Hive.Contracts.Interfaces;
    2829
    2930namespace HeuristicLab.Hive.Server.ADODataAccess {
  • trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/UserAdapter.cs

    r939 r948  
    3737        new dsHiveServer.HiveUserDataTable();
    3838
    39     private IPermissionOwnerAdapter permOwnerAdapter =
    40        ServiceLocator.GetPermissionOwnerAdapter();
     39    private IPermissionOwnerAdapter permOwnerAdapter = null;
     40
     41    private IPermissionOwnerAdapter PermOwnerAdapter {
     42      get {
     43        if (permOwnerAdapter == null)
     44          permOwnerAdapter = ServiceLocator.GetPermissionOwnerAdapter();
     45
     46        return permOwnerAdapter;
     47      }
     48    }
    4149
    4250    private IUserGroupAdapter userGroupAdapter = null;
     51
     52    private IUserGroupAdapter UserGroupAdapter {
     53      get {
     54        if(userGroupAdapter == null) {
     55          userGroupAdapter = ServiceLocator.GetUserGroupAdapter();
     56        }
     57
     58        return userGroupAdapter;
     59      }
     60    }
    4361
    4462    public UserAdapter() {
     
    5573        /*Parent - PermissionOwner*/
    5674        user.PermissionOwnerId = row.PermissionOwnerId;
    57         permOwnerAdapter.GetPermissionOwnerById(user);
     75        PermOwnerAdapter.GetPermissionOwnerById(user);
    5876
    5977        /*User*/
     
    83101    public void UpdateUser(User user) {
    84102      if (user != null) {
    85         permOwnerAdapter.UpdatePermissionOwner(user);
     103        PermOwnerAdapter.UpdatePermissionOwner(user);
    86104
    87105        dsHiveServer.HiveUserRow row =
     
    116134
    117135      PermissionOwner permOwner =
    118         permOwnerAdapter.GetPermissionOwnerByName(name);
     136        PermOwnerAdapter.GetPermissionOwnerByName(name);
    119137
    120138      if (permOwner != null) {
     
    152170
    153171        if (row != null) {
    154           if (userGroupAdapter == null)
    155             userGroupAdapter =
    156               ServiceLocator.GetUserGroupAdapter();
    157 
    158172          ICollection<UserGroup> userGroups =
    159             userGroupAdapter.MemberOf(user);
     173            UserGroupAdapter.MemberOf(user);
    160174
    161175          foreach (UserGroup group in userGroups) {
    162176            group.Members.Remove(user);
    163             userGroupAdapter.UpdateUserGroup(group);
     177            UserGroupAdapter.UpdateUserGroup(group);
    164178          }
    165179
    166180          data.RemoveHiveUserRow(row);
    167181
    168           return permOwnerAdapter.DeletePermissionOwner(user);
     182          return PermOwnerAdapter.DeletePermissionOwner(user);
    169183        }
    170184      }
  • trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/UserGroupAdapter.cs

    r939 r948  
    4444      new dsHiveServer.PermissionOwner_UserGroupDataTable();
    4545
    46     private IPermissionOwnerAdapter permOwnerAdapter =
    47       ServiceLocator.GetPermissionOwnerAdapter();
    48 
    49     private IUserAdapter userAdapter =
    50       ServiceLocator.GetUserAdapter();
     46    private IPermissionOwnerAdapter permOwnerAdapter = null;
     47
     48    private IPermissionOwnerAdapter PermOwnerAdapter {
     49      get {
     50        if (permOwnerAdapter == null)
     51          permOwnerAdapter = ServiceLocator.GetPermissionOwnerAdapter();
     52
     53        return permOwnerAdapter;
     54      }
     55    }
     56
     57    private IUserAdapter userAdapter = null;
     58
     59    private IUserAdapter UserAdapter {
     60      get {
     61        if (userAdapter == null)
     62          userAdapter = ServiceLocator.GetUserAdapter();
     63
     64        return userAdapter;
     65      }
     66    }
    5167
    5268    public UserGroupAdapter() {
     
    6581        /*Parent - Permission Owner*/
    6682        userGroup.PermissionOwnerId = row.PermissionOwnerId;
    67         permOwnerAdapter.GetPermissionOwnerById(userGroup);
     83        PermOwnerAdapter.GetPermissionOwnerById(userGroup);
    6884
    6985        //first check for created references
     
    88104          if (permOwner == null) {
    89105            PermissionOwner permissionOwner =
    90               userAdapter.GetUserById(permOwnerUserGroupRow.PermissionOwnerId);
     106              UserAdapter.GetUserById(permOwnerUserGroupRow.PermissionOwnerId);
    91107
    92108            if (permissionOwner == null) {
     
    133149          //first update the member to make sure it exists in the DB
    134150          if (permOwner is User) {
    135             userAdapter.UpdateUser(permOwner as User);
     151            UserAdapter.UpdateUser(permOwner as User);
    136152          } else if (permOwner is UserGroup) {
    137153            UpdateUserGroup(permOwner as UserGroup);
     
    201217    public void UpdateUserGroup(UserGroup group) {
    202218      if (group != null) {
    203         permOwnerAdapter.UpdatePermissionOwner(group);
     219        PermOwnerAdapter.UpdatePermissionOwner(group);
    204220
    205221        dsHiveServer.UserGroupRow row =
     
    292308         
    293309          data.RemoveUserGroupRow(row);
    294           return permOwnerAdapter.DeletePermissionOwner(group);
     310          return PermOwnerAdapter.DeletePermissionOwner(group);
    295311        }
    296312      }
  • trunk/sources/HeuristicLab.Hive.Server.Core/HeuristicLab.Hive.Server.Core.csproj

    r934 r948  
    7575    <Compile Include="InternalInterfaces\DataAccess\IPermissionOwnerAdapter.cs" />
    7676    <Compile Include="InternalInterfaces\DataAccess\IResourceAdapter.cs" />
    77     <Compile Include="InternalInterfaces\DataAccess\ITransactionManager.cs" />
    7877    <Compile Include="InternalInterfaces\DataAccess\IUserAdapter.cs" />
    7978    <Compile Include="InternalInterfaces\DataAccess\IUserGroupAdapter.cs" />
  • trunk/sources/HeuristicLab.Hive.Server.Core/LifecycleManager.cs

    r925 r948  
    2525using System.Text;
    2626using HeuristicLab.Hive.Contracts.Interfaces;
     27using HeuristicLab.Hive.Server.Core.InternalInterfaces.DataAccess;
    2728
    2829namespace HeuristicLab.Hive.Server.Core {
     
    3435    }
    3536
    36     public void Shtudown() {
     37    public ITransactionManager GetTransactionManager() {
     38      return ServiceLocator.GetTransactionManager();
     39    }
     40
     41    public void Shutdown() {
    3742      ServiceLocator.GetTransactionManager().UpdateDB();
    3843    }
  • trunk/sources/HeuristicLab.Hive.Server.Core/ServiceLocator.cs

    r925 r948  
    2323using HeuristicLab.PluginInfrastructure;
    2424using System.Runtime.CompilerServices;
     25using HeuristicLab.Hive.Contracts.Interfaces;
    2526
    2627/// <summary>
  • trunk/sources/HeuristicLab.Hive.Server/HiveServerApplication.cs

    r925 r948  
    147147
    148148        lifecycleManager.Init();
     149        //sync with db every 5 minutes
     150        lifecycleManager.GetTransactionManager().EnableAutoUpdate(
     151          new TimeSpan(0, 5, 0));
    149152
    150153        Form mainForm = new MainForm(clientCommunicator.BaseAddresses[0],
     
    153156         Application.Run(mainForm);
    154157
    155          lifecycleManager.Shtudown();
     158         lifecycleManager.Shutdown();
    156159      }
    157160
Note: See TracChangeset for help on using the changeset viewer.