[1580] | 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;
|
---|
[2117] | 9 | using System.IO;
|
---|
| 10 | using System.Data.SqlTypes;
|
---|
| 11 | using System.Data;
|
---|
[1580] | 12 |
|
---|
| 13 | namespace 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 | }
|
---|