1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using HeuristicLab.DataAccess.ADOHelper;
|
---|
6 | using System.Data.SqlClient;
|
---|
7 | using HeuristicLab.Hive.Contracts.BusinessObjects;
|
---|
8 | using System.Data.Common;
|
---|
9 | using System.IO;
|
---|
10 |
|
---|
11 | namespace HeuristicLab.Hive.Server.ADODataAccess.TableAdapterWrapper {
|
---|
12 | class JobResultsAdapterWrapper :
|
---|
13 | TableAdapterWrapperBase<dsHiveServerTableAdapters.JobResultTableAdapter,
|
---|
14 | JobResult,
|
---|
15 | dsHiveServer.JobResultRow> {
|
---|
16 | public override void UpdateRow(dsHiveServer.JobResultRow row) {
|
---|
17 | TransactionalAdapter.Update(row);
|
---|
18 | }
|
---|
19 |
|
---|
20 | public override dsHiveServer.JobResultRow InsertNewRow(JobResult obj) {
|
---|
21 | dsHiveServer.JobResultDataTable data =
|
---|
22 | new dsHiveServer.JobResultDataTable();
|
---|
23 |
|
---|
24 | dsHiveServer.JobResultRow row = data.NewJobResultRow();
|
---|
25 | row.JobResultId = obj.Id;
|
---|
26 | data.AddJobResultRow(row);
|
---|
27 |
|
---|
28 | return row;
|
---|
29 | }
|
---|
30 |
|
---|
31 | public override IEnumerable<dsHiveServer.JobResultRow> FindById(Guid id) {
|
---|
32 | return TransactionalAdapter.GetDataById(id);
|
---|
33 | }
|
---|
34 |
|
---|
35 | public override IEnumerable<dsHiveServer.JobResultRow> FindAll() {
|
---|
36 | return TransactionalAdapter.GetData();
|
---|
37 | }
|
---|
38 |
|
---|
39 | public Stream GetSerializedJobResultStream(Guid jobResultId,
|
---|
40 | bool useExistingConnection) {
|
---|
41 | SqlConnection connection = null;
|
---|
42 | SqlTransaction transaction = null;
|
---|
43 |
|
---|
44 | if (useExistingConnection) {
|
---|
45 | connection =
|
---|
46 | base.Session.Connection as SqlConnection;
|
---|
47 |
|
---|
48 | transaction =
|
---|
49 | adapter.Transaction;
|
---|
50 | } else {
|
---|
51 | connection =
|
---|
52 | ((SessionFactory)
|
---|
53 | (base.Session.Factory)).CreateConnection()
|
---|
54 | as SqlConnection;
|
---|
55 | }
|
---|
56 |
|
---|
57 | VarBinarySource source =
|
---|
58 | new VarBinarySource(
|
---|
59 | connection, transaction,
|
---|
60 | "JobResult", "JobResult", "JobResultId", jobResultId);
|
---|
61 |
|
---|
62 | return new VarBinaryStream(source);
|
---|
63 | }
|
---|
64 |
|
---|
65 | protected override void SetConnection(DbConnection connection) {
|
---|
66 | adapter.Connection = connection as SqlConnection;
|
---|
67 | }
|
---|
68 |
|
---|
69 | protected override void SetTransaction(DbTransaction transaction) {
|
---|
70 | adapter.Transaction = transaction as SqlTransaction;
|
---|
71 | }
|
---|
72 | }
|
---|
73 | }
|
---|