Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/31/09 01:33:37 (16 years ago)
Author:
svonolfe
Message:

Added transaction management (#527)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/JobResultsAdapter.cs

    r1449 r1468  
    66using HeuristicLab.Hive.Contracts.BusinessObjects;
    77using HeuristicLab.DataAccess.ADOHelper;
     8using HeuristicLab.Hive.Server.ADODataAccess.dsHiveServerTableAdapters;
     9using System.Data.Common;
     10using System.Data.SqlClient;
    811
    912namespace HeuristicLab.Hive.Server.ADODataAccess {
     13  class JobResultsAdapterWrapper :
     14    DataAdapterWrapperBase<dsHiveServerTableAdapters.JobResultTableAdapter,
     15                    JobResult,
     16                    dsHiveServer.JobResultRow> {   
     17    public override void UpdateRow(dsHiveServer.JobResultRow row) {
     18      TransactionalAdapter.Update(row);
     19    }
     20
     21    public override dsHiveServer.JobResultRow InsertNewRow(JobResult obj) {
     22      dsHiveServer.JobResultDataTable data =
     23        new dsHiveServer.JobResultDataTable();
     24
     25      dsHiveServer.JobResultRow row = data.NewJobResultRow();
     26      row.JobResultId = obj.Id;
     27      data.AddJobResultRow(row);
     28
     29      return row;
     30    }
     31
     32    public override IEnumerable<dsHiveServer.JobResultRow> FindById(Guid id) {
     33      return TransactionalAdapter.GetDataById(id);
     34    }
     35
     36    public override IEnumerable<dsHiveServer.JobResultRow> FindAll() {
     37      return TransactionalAdapter.GetData();
     38    }
     39
     40    protected override void SetConnection(DbConnection connection) {
     41      adapter.Connection = connection as SqlConnection;
     42    }
     43
     44    protected override void SetTransaction(DbTransaction transaction) {
     45      adapter.Transaction = transaction as SqlTransaction;
     46    }
     47  }
     48
    1049  class JobResultsAdapter:
    1150    DataAdapterBase<dsHiveServerTableAdapters.JobResultTableAdapter,
     
    1958      get {
    2059        if (clientAdapter == null)
    21           clientAdapter = ServiceLocator.GetClientAdapter();
     60          clientAdapter =
     61            this.Session.GetDataAdapter<ClientInfo, IClientAdapter>();
    2262
    2363        return clientAdapter;
     
    3070      get {
    3171        if (jobAdapter == null)
    32           jobAdapter = ServiceLocator.GetJobAdapter();
     72          jobAdapter =
     73            this.Session.GetDataAdapter<Job, IJobAdapter>();
    3374
    3475        return jobAdapter;
     
    3677    }
    3778    #endregion
     79
     80    public JobResultsAdapter(): base(new JobResultsAdapterWrapper()) {
     81    }
    3882
    3983    #region Overrides
     
    117161        return null;
    118162    }
    119 
    120     protected override void UpdateRow(dsHiveServer.JobResultRow row) {
    121       Adapter.Update(row);
    122     }
    123 
    124     protected override dsHiveServer.JobResultRow InsertNewRow(JobResult obj) {
    125       dsHiveServer.JobResultDataTable data =
    126         new dsHiveServer.JobResultDataTable();
    127 
    128       dsHiveServer.JobResultRow row = data.NewJobResultRow();
    129       row.JobResultId = obj.Id;
    130       data.AddJobResultRow(row);
    131 
    132       return row;
    133     }
    134 
    135     protected override IEnumerable<dsHiveServer.JobResultRow> FindById(Guid id) {
    136       return Adapter.GetDataById(id);
    137     }
    138 
    139     protected override IEnumerable<dsHiveServer.JobResultRow> FindAll() {
    140       return Adapter.GetData();
    141     }
    142163    #endregion
    143164
    144165    #region IJobResultsAdapter Members
    145     public override void Update(JobResult result) {
     166    protected override void doUpdate(JobResult result) {
    146167      if (result != null) {
    147168        ClientAdapter.Update(result.Client);
    148169        JobAdapter.Update(result.Job);
    149170
    150         base.Update(result);
     171        base.doUpdate(result);
    151172      }
    152173    }
Note: See TracChangeset for help on using the changeset viewer.