- Timestamp:
- 04/05/11 15:37:04 (14 years ago)
- Location:
- branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/HiveDao.cs
r5786 r5955 232 232 public DT.HiveExperiment GetHiveExperiment(Guid id) { 233 233 using (var db = CreateContext()) { 234 return Convert.ToDto(db.HiveExperiments.SingleOrDefault(x => x.HiveExperimentId == id)); 235 } 234 return AddStatsToExperiment(db, Convert.ToDto(db.HiveExperiments.SingleOrDefault(x => x.HiveExperimentId == id))); 235 } 236 } 237 238 private DT.HiveExperiment AddStatsToExperiment(HiveDataContext db, DT.HiveExperiment exp) { 239 var jobs = new List<Job>(); 240 CollectChildJobs(db, exp.RootJobId, jobs); 241 exp.JobCount = jobs.Count; 242 exp.CalculatingCount = jobs.Count(j => j.State == JobState.Calculating); 243 exp.FinishedCount = jobs.Count(j => j.State == JobState.Finished); 244 return exp; 236 245 } 237 246 238 247 public IEnumerable<DT.HiveExperiment> GetHiveExperiments(Expression<Func<HiveExperiment, bool>> predicate) { 239 248 using (var db = CreateContext()) { 240 return db.HiveExperiments.Where(predicate).Select(x => Convert.ToDto(x)).ToArray();249 return db.HiveExperiments.Where(predicate).Select(x => AddStatsToExperiment(db, Convert.ToDto(x))).ToArray(); 241 250 } 242 251 } … … 640 649 } 641 650 #endregion 651 652 #region Helpers 653 private void CollectChildJobs(HiveDataContext db, Guid parentJobId, List<Job> collection) { 654 var jobs = db.Jobs.Where(j => j.ParentJobId == parentJobId); 655 foreach (var job in jobs) { 656 collection.Add(job); 657 if (job.IsParentJob) 658 CollectChildJobs(db, job.JobId, collection); 659 } 660 } 661 #endregion 642 662 } 643 663 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/Tools/prepareHiveDatabase.sql
r5511 r5955 47 47 ON UPDATE CASCADE 48 48 ON DELETE CASCADE 49 GO 50 ALTER TABLE [dbo].[StateLog] DROP CONSTRAINT [Resource_StateLog] 51 ALTER TABLE [dbo].[StateLog] WITH CHECK ADD CONSTRAINT [Resource_StateLog] FOREIGN KEY([SlaveId]) 52 REFERENCES [dbo].[Resource] ([ResourceId]) 53 ON UPDATE CASCADE 54 ON DELETE SET NULL 49 55 GO 50 56
Note: See TracChangeset
for help on using the changeset viewer.