Index: branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Status/3.3/WebApi/DataController.cs
===================================================================
--- branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Status/3.3/WebApi/DataController.cs	(revision 12477)
+++ branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Status/3.3/WebApi/DataController.cs	(revision 12515)
@@ -27,9 +27,13 @@
 using HeuristicLab.Services.Hive;
 using HeuristicLab.Services.Hive.DataAccess;
-using DAL = HeuristicLab.Services.Hive.DataAccess;
-using DTO = HeuristicLab.Services.WebApp.Status.WebApi.DataTransfer;
+using HeuristicLab.Services.Hive.DataAccess.Interfaces;
+using DA = HeuristicLab.Services.Hive.DataAccess;
+using DT = HeuristicLab.Services.WebApp.Status.WebApi.DataTransfer;
 
 namespace HeuristicLab.Services.WebApp.Status.WebApi {
   public class DataController : ApiController {
+    private IPersistenceManager PersistenceManager {
+      get { return ServiceLocator.Instance.PersistenceManager; }
+    }
 
     // start temporary quickfix
@@ -53,8 +57,8 @@
     }
 
-    public IEnumerable<DTO.TaskStatus> GetTaskStatus(HiveDataContext db) {
+    public IEnumerable<DT.TaskStatus> GetTaskStatus(HiveDataContext db) {
       var query = db.ExecuteQuery<UserTaskStatus>(SQL_USER_TASK_STATUS).ToList();
-      return query.Select(uts => new DTO.TaskStatus {
-        User = new DTO.User {
+      return query.Select(uts => new DT.TaskStatus {
+        User = new DT.User {
           Id = uts.UserId.ToString(),
           Name = ServiceLocator.Instance.UserManager.GetUserById(uts.UserId).UserName
@@ -66,7 +70,21 @@
     // end temporary quickfix
 
-    public DTO.Status GetStatus() {
+    public DT.Status GetStatus() {
+      DT.TimeStatus timeStatus = null;
+      using (var pm = PersistenceManager) {
+
+        // TODO:
+        //          new DT.TimeStatus {
+        //  AvgCalculatingTime = 0,
+        //  AvgWaitingTime = 0,
+        //  MaxCalculatingTime = 0,
+        //  MinCalculatingTime = 0,
+        //  TotalCpuTime = 0,
+        //  BeginDate = DateTime.Now
+        //}
+      }
+
       using (var db = new HiveDataContext()) {
-        var onlineSlaves = (from slave in db.Resources.OfType<DAL.Slave>()
+        var onlineSlaves = (from slave in db.Resources.OfType<DA.Slave>()
                             where slave.SlaveState == SlaveState.Calculating || slave.SlaveState == SlaveState.Idle
                             select slave).ToList();
@@ -76,12 +94,12 @@
         int freeCalculatingMemory = calculatingSlaves.Any() ? (int)calculatingSlaves.Sum(s => s.FreeMemory) / 1024 : 0;
 
-        return new DTO.Status {
-          CoreStatus = new DTO.CoreStatus {
+        return new DT.Status {
+          CoreStatus = new DT.CoreStatus {
             TotalCores = onlineSlaves.Sum(s => s.Cores ?? 0),
             FreeCores = onlineSlaves.Sum(s => s.FreeCores ?? 0), // temporary for old chart data
             ActiveCores = activeSlaves.Sum(s => s.Cores ?? 0),
-            CalculatingCores = calculatingSlaves.Sum(s => s.Cores ?? 0)
+            CalculatingCores = calculatingSlaves.Sum(s => s.Cores ?? 0) - calculatingSlaves.Sum(s => s.FreeCores ?? 0)
           },
-          CpuUtilizationStatus = new DTO.CpuUtilizationStatus {
+          CpuUtilizationStatus = new DT.CpuUtilizationStatus {
             TotalCpuUtilization = onlineSlaves.Any()
                                   ? Math.Round(onlineSlaves.Average(s => s.CpuUtilization), 2)
@@ -94,5 +112,5 @@
                                         : 0.0
           },
-          MemoryStatus = new DTO.MemoryStatus {
+          MemoryStatus = new DT.MemoryStatus {
             TotalMemory = onlineSlaves.Any() ? (int)onlineSlaves.Sum(s => s.Memory) / 1024 : 0,
             FreeMemory = onlineSlaves.Any() ? (int)onlineSlaves.Sum(s => s.FreeMemory) / 1024 : 0,
@@ -100,7 +118,8 @@
             UsedMemory = calculatingMemory - freeCalculatingMemory
           },
+          TimeStatus = timeStatus,
           TasksStatus = GetTaskStatus(db),
-          SlavesStatus = onlineSlaves.Select(x => new DTO.SlaveStatus {
-            Slave = new DTO.Slave {
+          SlavesStatus = onlineSlaves.Select(x => new DT.SlaveStatus {
+            Slave = new DT.Slave {
               Id = x.ResourceId.ToString(),
               Name = x.Name
@@ -119,5 +138,5 @@
     }
 
-    public IEnumerable<DTO.Status> GetStatusHistory(DateTime start, DateTime end) {
+    public IEnumerable<DT.Status> GetStatusHistory(DateTime start, DateTime end) {
       TimeSpan ts = end - start;
       int increment = 1;
@@ -135,8 +154,8 @@
                                       .OrderBy(s => s.Timestamp)
                                       .ToList();
-        var status = new DTO.Status {
-          CoreStatus = new DTO.CoreStatus(),
-          CpuUtilizationStatus = new DTO.CpuUtilizationStatus(),
-          MemoryStatus = new DTO.MemoryStatus()
+        var status = new DT.Status {
+          CoreStatus = new DT.CoreStatus(),
+          CpuUtilizationStatus = new DT.CpuUtilizationStatus(),
+          MemoryStatus = new DT.MemoryStatus()
         };
         int freeCores = 0;
@@ -165,8 +184,8 @@
             status.MemoryStatus.UsedMemory = status.MemoryStatus.TotalMemory - freeMemory;
             yield return status;
-            status = new DTO.Status {
-              CoreStatus = new DTO.CoreStatus(),
-              CpuUtilizationStatus = new DTO.CpuUtilizationStatus(),
-              MemoryStatus = new DTO.MemoryStatus()
+            status = new DT.Status {
+              CoreStatus = new DT.CoreStatus(),
+              CpuUtilizationStatus = new DT.CpuUtilizationStatus(),
+              MemoryStatus = new DT.MemoryStatus()
             };
             freeCores = 0;
