Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/3.2/TableAdapterWrapper/JobAdapterWrapper.cs @ 3199

Last change on this file since 3199 was 3011, checked in by kgrading, 15 years ago

changed the complete DAL to LINQ 2 SQL (with the exception of the job streaming), did a lot of refactoring, Introduced DTOs (that are named DTOs for better understanding), added the spring.NET Interceptor, reintroduced transactions and cleaned up the whole JobResult thing and updated a part of the config merger (#830)

File size: 2.2 KB
RevLine 
[1580]1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using HeuristicLab.DataAccess.ADOHelper;
6using System.Data.SqlClient;
7using HeuristicLab.Hive.Contracts.BusinessObjects;
8using System.Data.Common;
[2117]9using System.IO;
10using System.Data.SqlTypes;
11using System.Data;
[1580]12
13namespace HeuristicLab.Hive.Server.ADODataAccess.TableAdapterWrapper {
14  class JobAdapterWrapper :
15    TableAdapterWrapperBase<dsHiveServerTableAdapters.JobTableAdapter,
[3011]16                      JobDto,
[1580]17                      dsHiveServer.JobRow> {
18    public override void UpdateRow(dsHiveServer.JobRow row) {
19      TransactionalAdapter.Update(row);
20    }
21
22    public override dsHiveServer.JobRow
[3011]23      InsertNewRow(JobDto job) {
[1580]24      dsHiveServer.JobDataTable data =
25        new dsHiveServer.JobDataTable();
26
27      dsHiveServer.JobRow row = data.NewJobRow();
28      row.JobId = job.Id;
29      data.AddJobRow(row);
30
31      return row;
32    }
33
34    public override IEnumerable<dsHiveServer.JobRow>
35      FindById(Guid id) {
36      return TransactionalAdapter.GetDataById(id);
37    }
38
39    public override IEnumerable<dsHiveServer.JobRow>
40      FindAll() {
41      return TransactionalAdapter.GetData();
42    }
43
[2117]44    public Stream GetSerializedJobStream(Guid jobId,
45      bool useExistingConnection) {
46      SqlConnection connection = null;
47      SqlTransaction transaction = null;
[2083]48
[2117]49      if (useExistingConnection) {
50        connection =
51          base.Session.Connection as SqlConnection;
52
53        transaction =
54          adapter.Transaction;
55      } else {
56        connection =
57         ((SessionFactory)
58           (base.Session.Factory)).CreateConnection()
59           as SqlConnection;
60      }
61
62      VarBinarySource source =
63        new VarBinarySource(
64          connection, transaction,
65          "Job", "SerializedJob", "JobId", jobId);
66
67      return new VarBinaryStream(source);
[2083]68    }
69
[1580]70    protected override void SetConnection(DbConnection connection) {
71      adapter.Connection = connection as SqlConnection;
72    }
73
74    protected override void SetTransaction(DbTransaction transaction) {
75      adapter.Transaction = transaction as SqlTransaction;
76    }
77  }
78}
Note: See TracBrowser for help on using the repository browser.