Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9035


Ignore:
Timestamp:
12/12/12 12:12:19 (12 years ago)
Author:
ascheibe
Message:

#1994 removed duplicate code

Location:
trunk/sources/HeuristicLab.Services.Hive/3.3
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Services.Hive/3.3/HiveDao.cs

    r9033 r9035  
    4949    }
    5050
    51     public IEnumerable<DT.LightweightTask> GetLightweightTasksForJob(Guid jobId) {
    52       List<DT.LightweightTask> tasks = new List<DT.LightweightTask>();
    53 
    54       using (var db = CreateContext()) {
    55         var tasksQuery = from task in db.Tasks
    56                          where task.JobId == jobId
    57                          select new { task.TaskId, task.ExecutionTimeMs, task.ParentTaskId, task.StateLogs, task.State, task.Command };
    58 
    59         var taskDatasQuery = from task in db.Tasks
    60                              where task.JobId == jobId && task.JobData != null
    61                              select new { task.TaskId, task.JobData.LastUpdate };
    62 
    63         foreach (var task in tasksQuery) {
    64           DT.LightweightTask t = new DT.LightweightTask();
    65           t.Id = task.TaskId;
    66           t.ExecutionTime = TimeSpan.FromMilliseconds(task.ExecutionTimeMs);
    67           t.ParentTaskId = task.ParentTaskId;
    68           t.StateLog = task.StateLogs == null ? new List<DT.StateLog>() : task.StateLogs.Select(x => DataTransfer.Convert.ToDto(x)).OrderBy(x => x.DateTime).ToList();
    69           t.State = DataTransfer.Convert.ToDto(task.State);
    70           t.Command = DataTransfer.Convert.ToDto(task.Command);
    71           t.LastTaskDataUpdate = taskDatasQuery.Where(x => x.TaskId == task.TaskId).Count() > 0 ? taskDatasQuery.Select(x => x.LastUpdate).First() : DateTime.MinValue;
    72           tasks.Add(t);
    73         }
    74       }
    75       return tasks;
    76     }
    77 
    7851    public IEnumerable<DT.LightweightTask> GetLightweightTasks(Expression<Func<Task, bool>> predicate) {
    7952      List<DT.LightweightTask> tasks = new List<DT.LightweightTask>();
  • trunk/sources/HeuristicLab.Services.Hive/3.3/HiveService.cs

    r9022 r9035  
    128128
    129129      return trans.UseTransaction(() => {
    130         return dao.GetLightweightTasksForJob(jobId).ToArray();
     130        return dao.GetLightweightTasks(task => task.JobId == jobId).ToArray();
    131131      }, false, false);
    132132    }
  • trunk/sources/HeuristicLab.Services.Hive/3.3/Interfaces/IHiveDao.cs

    r9033 r9035  
    3131    DT.Task GetTask(Guid id);
    3232    IEnumerable<DT.Task> GetTasks(Expression<Func<Task, bool>> predicate);
    33     IEnumerable<DT.LightweightTask> GetLightweightTasksForJob(Guid jobId);
    3433    IEnumerable<DT.LightweightTask> GetLightweightTasks(Expression<Func<Task, bool>> predicate);
    3534    Guid AddTask(DT.Task dto);
Note: See TracChangeset for help on using the changeset viewer.