Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.LINQDataAccess/3.3/SlaveConfigDao.cs @ 4267

Last change on this file since 4267 was 4267, checked in by cneumuel, 14 years ago

renamed all database entities from "Client" to "Slave" (#1157)
made slave-heartbeats synchronous, also they send HBs when timetable disallows them to calculate. they will appear on the server as Idle bis IsAllowedToCalculate will be false (#1159)

File size: 2.1 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using HeuristicLab.Hive.Contracts.BusinessObjects;
6using HeuristicLab.Hive.Server.DataAccess;
7
8namespace HeuristicLab.Hive.Server.LINQDataAccess {
9  public class SlaveConfigDao: BaseDao<SlaveConfigDto, SlaveConfig>, ISlaveConfigDao {
10
11    #region IGenericDao<SlaveConfigDto,SlaveConfig> Members
12
13    public SlaveConfigDto FindById(Guid id) {
14      return (from cc in Context.SlaveConfigs
15              where cc.SlaveConfigId.Equals(id)
16              select EntityToDto(cc, null)).SingleOrDefault();
17    }
18
19    public IEnumerable<SlaveConfigDto> FindAll() {
20      return (from cc in Context.SlaveConfigs             
21              select EntityToDto(cc, null)).ToList();
22    }
23
24    public SlaveConfigDto Insert(SlaveConfigDto bObj) {
25      SlaveConfig c = DtoToEntity(bObj, null);
26      Context.SlaveConfigs.InsertOnSubmit(c);
27      CommitChanges();
28      bObj.Id = c.SlaveConfigId;
29      return bObj; 
30    }
31
32    public void Delete(SlaveConfigDto bObj) {
33      Context.SlaveConfigs.DeleteOnSubmit(Context.SlaveConfigs.SingleOrDefault(c => c.SlaveConfigId.Equals(bObj.Id)));
34      CommitChanges();
35    }
36
37    public void Update(SlaveConfigDto bObj) {
38      SlaveConfig cc = Context.SlaveConfigs.SingleOrDefault(c => c.SlaveConfigId.Equals(bObj.Id));
39      DtoToEntity(bObj, cc);
40      CommitChanges();
41    }
42
43    #endregion
44
45    public override SlaveConfig DtoToEntity(SlaveConfigDto source, SlaveConfig target) {
46      if (source == null)
47        return null;
48      if (target == null)
49        target = new SlaveConfig();
50
51      target.SlaveConfigId = source.Id;
52      target.HeartBeatIntervall = source.HeartBeatIntervall;
53     
54      return target;
55    }
56
57    public override SlaveConfigDto EntityToDto(SlaveConfig source, SlaveConfigDto target) {
58      if (source == null)
59        return null;
60      if (target == null)
61        target = new SlaveConfigDto();
62
63      target.Id = source.SlaveConfigId;
64      target.HeartBeatIntervall = source.HeartBeatIntervall;
65
66      return target;
67
68    }
69  }
70}
Note: See TracBrowser for help on using the repository browser.