Index: branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/ClientController.cs
===================================================================
--- branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/ClientController.cs	(revision 12780)
+++ branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/ClientController.cs	(revision 12858)
@@ -38,111 +38,109 @@
 
     public DT.ClientDetails GetClientDetails(Guid id) {
-      using (var pm = PersistenceManager) {
-        var dimClientDao = pm.DimClientDao;
-        var factClientInfoDao = pm.FactClientInfoDao;
-        var factTaskDao = pm.FactTaskDao;
-        return pm.UseTransaction(() => {
-          var timeData = factClientInfoDao.GetByClientId(id)
-            .GroupBy(x => x.ClientId)
-            .Select(x => new {
-              TotalIdleTime = x.Sum(y => y.IdleTime),
-              TotalOfflineTime = x.Sum(y => y.OfflineTime),
-              TotalUnavailableTime = x.Sum(y => y.UnavailableTime)
-            }).FirstOrDefault();
-          var taskTimeData = factTaskDao.GetByClientId(id)
-            .GroupBy(x => x.LastClientId)
-            .Select(x => new {
-              TotalCalculatingTime = x.Sum(y => y.CalculatingTime),
-              TotalTransferringTime = x.Sum(y => y.TransferTime)
-            }).FirstOrDefault();
-          var startDate = factClientInfoDao.GetByClientId(id)
-            .Where(x => x.SlaveState == SlaveState.Offline)
+      var pm = PersistenceManager;
+      var dimClientDao = pm.DimClientDao;
+      var factClientInfoDao = pm.FactClientInfoDao;
+      var factTaskDao = pm.FactTaskDao;
+      return pm.UseTransaction(() => {
+        var timeData = factClientInfoDao.GetByClientId(id)
+          .GroupBy(x => x.ClientId)
+          .Select(x => new {
+            TotalIdleTime = x.Sum(y => y.IdleTime),
+            TotalOfflineTime = x.Sum(y => y.OfflineTime),
+            TotalUnavailableTime = x.Sum(y => y.UnavailableTime)
+          }).FirstOrDefault();
+        var taskTimeData = factTaskDao.GetByClientId(id)
+          .GroupBy(x => x.LastClientId)
+          .Select(x => new {
+            TotalCalculatingTime = x.Sum(y => y.CalculatingTime),
+            TotalTransferringTime = x.Sum(y => y.TransferTime)
+          }).FirstOrDefault();
+        var startDate = factClientInfoDao.GetByClientId(id)
+          .Where(x => x.SlaveState == SlaveState.Offline)
+          .OrderByDescending(x => x.Time)
+          .Select(x => x.Time).FirstOrDefault();
+        long upTime = 0;
+        if (startDate == default(DateTime)) {
+          startDate = factClientInfoDao.GetByClientId(id)
             .OrderByDescending(x => x.Time)
-            .Select(x => x.Time).FirstOrDefault();
-          long upTime = 0;
-          if (startDate == default(DateTime)) {
-            startDate = factClientInfoDao.GetByClientId(id)
-              .OrderByDescending(x => x.Time)
-              .Select(x => x.Time)
-              .FirstOrDefault();
-          }
-          if (startDate != default(DateTime)) {
-            upTime = (long)(DateTime.Now - startDate).TotalSeconds;
-          }
-          return (from client in dimClientDao.GetAll().Where(x => x.Id == id)
-                  join info in factClientInfoDao.GetAll()
-                    on client.Id equals info.ClientId into clientInfoJoin
-                  from clientInfo in clientInfoJoin.OrderByDescending(x => x.Time).Take(1)
-                  let offline = (client.ExpirationTime != null || clientInfo.SlaveState == SlaveState.Offline)
-                  select new DT.ClientDetails {
-                    Id = client.Id,
-                    Name = client.Name,
-                    TotalCores = clientInfo.NumTotalCores,
-                    UsedCores = offline ? 0 : clientInfo.NumUsedCores,
-                    TotalMemory = clientInfo.TotalMemory,
-                    UsedMemory = offline ? 0 : clientInfo.UsedMemory,
-                    CpuUtilization = offline ? 0 : clientInfo.CpuUtilization,
-                    State = offline ? SlaveState.Offline.ToString() : clientInfo.SlaveState.ToString(),
-                    LastUpdate = clientInfo.Time,
-                    GroupId = client.ResourceGroupId,
-                    GroupName = client.GroupName,
-                    UpTime = offline ? 0 : upTime,
-                    TotalUnavailableTime = timeData != null ? timeData.TotalUnavailableTime : 0,
-                    TotalCalculatingTime = taskTimeData != null ? taskTimeData.TotalCalculatingTime : 0,
-                    TotalIdleTime = timeData != null ? timeData.TotalIdleTime : 0,
-                    TotalOfflineTime = timeData != null ? timeData.TotalOfflineTime : 0,
-                    TotalTransferringTime = taskTimeData != null ? taskTimeData.TotalTransferringTime : 0,
-                    TasksStates = factTaskDao.GetByClientId(id)
-                                    .GroupBy(x => x.TaskState)
-                                    .Select(x => new DT.TaskStateCount {
-                                      State = x.Key.ToString(),
-                                      Count = x.Count()
-                                    }).ToList(),
-                    Users = factTaskDao.GetAll()
-                              .Where(x => x.LastClientId == id)
-                              .Select(x => new DT.User {
-                                Id = x.DimJob.UserId,
-                                Name = x.DimJob.UserName
-                              })
-                              .Distinct()
-                              .ToList()
-                  })
-                  .FirstOrDefault();
-        });
-      }
+            .Select(x => x.Time)
+            .FirstOrDefault();
+        }
+        if (startDate != default(DateTime)) {
+          upTime = (long)(DateTime.Now - startDate).TotalSeconds;
+        }
+        return (from client in dimClientDao.GetAll().Where(x => x.Id == id)
+                join info in factClientInfoDao.GetAll()
+                  on client.Id equals info.ClientId into clientInfoJoin
+                from clientInfo in clientInfoJoin.OrderByDescending(x => x.Time).Take(1)
+                let offline = (client.ExpirationTime != null || clientInfo.SlaveState == SlaveState.Offline)
+                select new DT.ClientDetails {
+                  Id = client.Id,
+                  Name = client.Name,
+                  TotalCores = clientInfo.NumTotalCores,
+                  UsedCores = offline ? 0 : clientInfo.NumUsedCores,
+                  TotalMemory = clientInfo.TotalMemory,
+                  UsedMemory = offline ? 0 : clientInfo.UsedMemory,
+                  CpuUtilization = offline ? 0 : clientInfo.CpuUtilization,
+                  State = offline ? SlaveState.Offline.ToString() : clientInfo.SlaveState.ToString(),
+                  LastUpdate = clientInfo.Time,
+                  GroupId = client.ResourceGroupId,
+                  GroupName = client.GroupName,
+                  UpTime = offline ? 0 : upTime,
+                  TotalUnavailableTime = timeData != null ? timeData.TotalUnavailableTime : 0,
+                  TotalCalculatingTime = taskTimeData != null ? taskTimeData.TotalCalculatingTime : 0,
+                  TotalIdleTime = timeData != null ? timeData.TotalIdleTime : 0,
+                  TotalOfflineTime = timeData != null ? timeData.TotalOfflineTime : 0,
+                  TotalTransferringTime = taskTimeData != null ? taskTimeData.TotalTransferringTime : 0,
+                  TasksStates = factTaskDao.GetByClientId(id)
+                                  .GroupBy(x => x.TaskState)
+                                  .Select(x => new DT.TaskStateCount {
+                                    State = x.Key.ToString(),
+                                    Count = x.Count()
+                                  }).ToList(),
+                  Users = factTaskDao.GetAll()
+                            .Where(x => x.LastClientId == id)
+                            .Select(x => new DT.User {
+                              Id = x.DimJob.UserId,
+                              Name = x.DimJob.UserName
+                            })
+                            .Distinct()
+                            .ToList()
+                })
+                .FirstOrDefault();
+      });
     }
 
     public DT.ClientPage GetClients(int page, int size, bool expired = false) {
-      using (var pm = PersistenceManager) {
-        var dimClientDao = pm.DimClientDao;
-        var factClientInfoDao = pm.FactClientInfoDao;
-        return pm.UseTransaction(() => {
-          var clients = expired ? dimClientDao.GetExpiredClients() : dimClientDao.GetActiveClients();
-          var query = (from client in clients
-                       join info in factClientInfoDao.GetAll()
-                         on client.Id equals info.ClientId into clientInfoJoin
-                       from clientInfo in clientInfoJoin.OrderByDescending(x => x.Time).Take(1)
-                       let offline = (expired || clientInfo.SlaveState == SlaveState.Offline)
-                       select new DT.Client {
-                         Id = client.Id,
-                         Name = client.Name,
-                         TotalCores = clientInfo.NumTotalCores,
-                         UsedCores = offline ? 0 : clientInfo.NumUsedCores,
-                         TotalMemory = clientInfo.TotalMemory,
-                         UsedMemory = offline ? 0 : clientInfo.UsedMemory,
-                         CpuUtilization = offline ? 0 : clientInfo.CpuUtilization,
-                         State = offline ? SlaveState.Offline.ToString() : clientInfo.SlaveState.ToString(),
-                         GroupId = client.ResourceGroupId,
-                         GroupName = client.GroupName,
-                         IsAllowedToCalculate = clientInfo.IsAllowedToCalculate
-                       });
-          return new DT.ClientPage {
-            TotalClients = query.Count(),
-            Clients = query.Skip((page - 1) * size)
-              .Take(size)
-              .ToList()
-          };
-        });
-      }
+      var pm = PersistenceManager;
+      var dimClientDao = pm.DimClientDao;
+      var factClientInfoDao = pm.FactClientInfoDao;
+      return pm.UseTransaction(() => {
+        var clients = expired ? dimClientDao.GetExpiredClients() : dimClientDao.GetActiveClients();
+        var query = (from client in clients
+                     join info in factClientInfoDao.GetAll()
+                       on client.Id equals info.ClientId into clientInfoJoin
+                     from clientInfo in clientInfoJoin.OrderByDescending(x => x.Time).Take(1)
+                     let offline = (expired || clientInfo.SlaveState == SlaveState.Offline)
+                     select new DT.Client {
+                       Id = client.Id,
+                       Name = client.Name,
+                       TotalCores = clientInfo.NumTotalCores,
+                       UsedCores = offline ? 0 : clientInfo.NumUsedCores,
+                       TotalMemory = clientInfo.TotalMemory,
+                       UsedMemory = offline ? 0 : clientInfo.UsedMemory,
+                       CpuUtilization = offline ? 0 : clientInfo.CpuUtilization,
+                       State = offline ? SlaveState.Offline.ToString() : clientInfo.SlaveState.ToString(),
+                       GroupId = client.ResourceGroupId,
+                       GroupName = client.GroupName,
+                       IsAllowedToCalculate = clientInfo.IsAllowedToCalculate
+                     });
+        return new DT.ClientPage {
+          TotalClients = query.Count(),
+          Clients = query.Skip((page - 1) * size)
+            .Take(size)
+            .ToList()
+        };
+      });
     }
 
@@ -155,80 +153,78 @@
         increment += 5;
       }
-      using (var pm = PersistenceManager) {
-        var factClientInfo = pm.FactClientInfoDao;
-        var clientInfos = factClientInfo.GetByClientId(id)
-          .Where(x => x.Time >= start && x.Time <= end)
-          .OrderBy(x => x.Time)
-          .ToList();
-        var clientStatus = new DT.ClientStatus {
-          CpuUtilization = 0,
-          TotalCores = 0,
-          UsedCores = 0,
-          TotalMemory = 0,
-          UsedMemory = 0
+      var pm = PersistenceManager;
+      var factClientInfo = pm.FactClientInfoDao;
+      var clientInfos = factClientInfo.GetByClientId(id)
+        .Where(x => x.Time >= start && x.Time <= end)
+        .OrderBy(x => x.Time)
+        .ToList();
+      var clientStatus = new DT.ClientStatus {
+        CpuUtilization = 0,
+        TotalCores = 0,
+        UsedCores = 0,
+        TotalMemory = 0,
+        UsedMemory = 0
+      };
+      int i = 1;
+      foreach (var clientInfo in clientInfos) {
+        clientStatus.CpuUtilization += clientInfo.CpuUtilization;
+        clientStatus.TotalCores += clientInfo.NumTotalCores;
+        clientStatus.UsedCores += clientInfo.NumUsedCores;
+        clientStatus.TotalMemory += clientInfo.TotalMemory;
+        clientStatus.UsedMemory += clientInfo.UsedMemory;
+        if (i >= increment) {
+          clientStatus.Timestamp = JavascriptUtils.ToTimestamp(clientInfo.Time);
+          clientStatus.CpuUtilization /= i;
+          clientStatus.TotalCores /= i;
+          clientStatus.UsedCores /= i;
+          clientStatus.TotalMemory /= i;
+          clientStatus.UsedMemory /= i;
+          yield return clientStatus;
+          clientStatus = new DT.ClientStatus {
+            CpuUtilization = 0,
+            TotalCores = 0,
+            UsedCores = 0,
+            TotalMemory = 0,
+            UsedMemory = 0
+          };
+          i = 1;
+        } else {
+          ++i;
+        }
+      }
+    }
+
+    public DT.ClientPage GetClientsByGroupId(Guid id, int page, int size, bool expired = false) {
+      var pm = PersistenceManager;
+      var dimClientDao = pm.DimClientDao;
+      var factClientInfoDao = pm.FactClientInfoDao;
+      return pm.UseTransaction(() => {
+        var clients = expired ? dimClientDao.GetExpiredClients() : dimClientDao.GetActiveClients();
+        clients = clients.Where(x => x.ResourceGroupId == id);
+        var query = (from client in clients
+                     join info in factClientInfoDao.GetAll()
+                       on client.Id equals info.ClientId into clientInfoJoin
+                     from clientInfo in clientInfoJoin.OrderByDescending(x => x.Time).Take(1)
+                     let offline = (expired || clientInfo.SlaveState == SlaveState.Offline)
+                     select new DT.Client {
+                       Id = client.Id,
+                       Name = client.Name,
+                       TotalCores = clientInfo.NumTotalCores,
+                       UsedCores = offline ? 0 : clientInfo.NumUsedCores,
+                       TotalMemory = clientInfo.TotalMemory,
+                       UsedMemory = offline ? 0 : clientInfo.UsedMemory,
+                       CpuUtilization = offline ? 0 : clientInfo.CpuUtilization,
+                       State = offline ? SlaveState.Offline.ToString() : clientInfo.SlaveState.ToString(),
+                       GroupId = client.ResourceGroupId,
+                       GroupName = client.GroupName,
+                       IsAllowedToCalculate = clientInfo.IsAllowedToCalculate
+                     });
+        return new DT.ClientPage {
+          TotalClients = query.Count(),
+          Clients = query.Skip((page - 1) * size)
+            .Take(size)
+            .ToList()
         };
-        int i = 1;
-        foreach (var clientInfo in clientInfos) {
-          clientStatus.CpuUtilization += clientInfo.CpuUtilization;
-          clientStatus.TotalCores += clientInfo.NumTotalCores;
-          clientStatus.UsedCores += clientInfo.NumUsedCores;
-          clientStatus.TotalMemory += clientInfo.TotalMemory;
-          clientStatus.UsedMemory += clientInfo.UsedMemory;
-          if (i >= increment) {
-            clientStatus.Timestamp = JavascriptUtils.ToTimestamp(clientInfo.Time);
-            clientStatus.CpuUtilization /= i;
-            clientStatus.TotalCores /= i;
-            clientStatus.UsedCores /= i;
-            clientStatus.TotalMemory /= i;
-            clientStatus.UsedMemory /= i;
-            yield return clientStatus;
-            clientStatus = new DT.ClientStatus {
-              CpuUtilization = 0,
-              TotalCores = 0,
-              UsedCores = 0,
-              TotalMemory = 0,
-              UsedMemory = 0
-            };
-            i = 1;
-          } else {
-            ++i;
-          }
-        }
-      }
-    }
-
-    public DT.ClientPage GetClientsByGroupId(Guid id, int page, int size, bool expired = false) {
-      using (var pm = PersistenceManager) {
-        var dimClientDao = pm.DimClientDao;
-        var factClientInfoDao = pm.FactClientInfoDao;
-        return pm.UseTransaction(() => {
-          var clients = expired ? dimClientDao.GetExpiredClients() : dimClientDao.GetActiveClients();
-          clients = clients.Where(x => x.ResourceGroupId == id);
-          var query = (from client in clients
-                       join info in factClientInfoDao.GetAll()
-                         on client.Id equals info.ClientId into clientInfoJoin
-                       from clientInfo in clientInfoJoin.OrderByDescending(x => x.Time).Take(1)
-                       let offline = (expired || clientInfo.SlaveState == SlaveState.Offline)
-                       select new DT.Client {
-                         Id = client.Id,
-                         Name = client.Name,
-                         TotalCores = clientInfo.NumTotalCores,
-                         UsedCores = offline ? 0 : clientInfo.NumUsedCores,
-                         TotalMemory = clientInfo.TotalMemory,
-                         UsedMemory = offline ? 0 : clientInfo.UsedMemory,
-                         CpuUtilization = offline ? 0 : clientInfo.CpuUtilization,
-                         State = offline ? SlaveState.Offline.ToString() : clientInfo.SlaveState.ToString(),
-                         GroupId = client.ResourceGroupId,
-                         GroupName = client.GroupName,
-                         IsAllowedToCalculate = clientInfo.IsAllowedToCalculate
-                       });
-          return new DT.ClientPage {
-            TotalClients = query.Count(),
-            Clients = query.Skip((page - 1) * size)
-              .Take(size)
-              .ToList()
-          };
-        });
-      }
+      });
     }
 
@@ -241,57 +237,56 @@
         increment += 5;
       }
-      using (var pm = PersistenceManager) {
-        var factClientInfo = pm.FactClientInfoDao;
-        var dimClientDao = pm.DimClientDao;
-        var clientInfos = factClientInfo.GetAll()
-          .Where(x => x.Time >= start && x.Time <= end)
-          .OrderBy(x => x.Time)
-          .Join(dimClientDao.GetAll(),
-            fact => fact.ClientId,
-            client => client.Id,
-            (fact, client) => new {
-              client.ResourceGroupId,
-              fact.Time,
-              fact.CpuUtilization,
-              fact.NumTotalCores,
-              fact.NumUsedCores,
-              fact.TotalMemory,
-              fact.UsedMemory
-            })
-          .Where(x => x.ResourceGroupId == id)
-          .ToList();
-        var clientStatus = new DT.ClientStatus {
-          CpuUtilization = 0,
-          TotalCores = 0,
-          UsedCores = 0,
-          TotalMemory = 0,
-          UsedMemory = 0
-        };
-        int i = 1;
-        foreach (var clientInfo in clientInfos) {
-          clientStatus.CpuUtilization += clientInfo.CpuUtilization;
-          clientStatus.TotalCores += clientInfo.NumTotalCores;
-          clientStatus.UsedCores += clientInfo.NumUsedCores;
-          clientStatus.TotalMemory += clientInfo.TotalMemory;
-          clientStatus.UsedMemory += clientInfo.UsedMemory;
-          if (i >= increment) {
-            clientStatus.Timestamp = JavascriptUtils.ToTimestamp(clientInfo.Time);
-            clientStatus.CpuUtilization /= i;
-            clientStatus.TotalCores /= i;
-            clientStatus.UsedCores /= i;
-            clientStatus.TotalMemory /= i;
-            clientStatus.UsedMemory /= i;
-            yield return clientStatus;
-            clientStatus = new DT.ClientStatus {
-              CpuUtilization = 0,
-              TotalCores = 0,
-              UsedCores = 0,
-              TotalMemory = 0,
-              UsedMemory = 0
-            };
-            i = 1;
-          } else {
-            ++i;
-          }
+      var pm = PersistenceManager;
+      var factClientInfo = pm.FactClientInfoDao;
+      var dimClientDao = pm.DimClientDao;
+      var clientInfos = factClientInfo.GetAll()
+        .Where(x => x.Time >= start && x.Time <= end)
+        .OrderBy(x => x.Time)
+        .Join(dimClientDao.GetAll(),
+          fact => fact.ClientId,
+          client => client.Id,
+          (fact, client) => new {
+            client.ResourceGroupId,
+            fact.Time,
+            fact.CpuUtilization,
+            fact.NumTotalCores,
+            fact.NumUsedCores,
+            fact.TotalMemory,
+            fact.UsedMemory
+          })
+        .Where(x => x.ResourceGroupId == id)
+        .ToList();
+      var clientStatus = new DT.ClientStatus {
+        CpuUtilization = 0,
+        TotalCores = 0,
+        UsedCores = 0,
+        TotalMemory = 0,
+        UsedMemory = 0
+      };
+      int i = 1;
+      foreach (var clientInfo in clientInfos) {
+        clientStatus.CpuUtilization += clientInfo.CpuUtilization;
+        clientStatus.TotalCores += clientInfo.NumTotalCores;
+        clientStatus.UsedCores += clientInfo.NumUsedCores;
+        clientStatus.TotalMemory += clientInfo.TotalMemory;
+        clientStatus.UsedMemory += clientInfo.UsedMemory;
+        if (i >= increment) {
+          clientStatus.Timestamp = JavascriptUtils.ToTimestamp(clientInfo.Time);
+          clientStatus.CpuUtilization /= i;
+          clientStatus.TotalCores /= i;
+          clientStatus.UsedCores /= i;
+          clientStatus.TotalMemory /= i;
+          clientStatus.UsedMemory /= i;
+          yield return clientStatus;
+          clientStatus = new DT.ClientStatus {
+            CpuUtilization = 0,
+            TotalCores = 0,
+            UsedCores = 0,
+            TotalMemory = 0,
+            UsedMemory = 0
+          };
+          i = 1;
+        } else {
+          ++i;
         }
       }
Index: branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/ExceptionController.cs
===================================================================
--- branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/ExceptionController.cs	(revision 12780)
+++ branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/ExceptionController.cs	(revision 12858)
@@ -35,34 +35,33 @@
 
     public DT.ExceptionPage GetExceptions(int page, int size) {
-      using (var pm = PersistenceManager) {
-        var dimClientDao = pm.DimClientDao;
-        var dimJobDao = pm.DimJobDao;
-        var factTaskDao = pm.FactTaskDao;
-        var tasks = factTaskDao.GetTasksWithException();
-        return pm.UseTransaction(() => new DT.ExceptionPage {
-          TotalExceptions = tasks.Count(),
-          Exceptions = (from factTask in tasks
-                        join dimJob in dimJobDao.GetAll() on factTask.JobId equals dimJob.JobId
-                        join dimClient in dimClientDao.GetAll() on factTask.LastClientId equals
-                          dimClient.Id into taskClientJoin
-                        from a in taskClientJoin.DefaultIfEmpty()
-                        let endTime = factTask.EndTime ?? DateTime.Now
-                        select new DT.Exception {
-                          TaskId = factTask.TaskId,
-                          JobId = factTask.JobId,
-                          JobName = dimJob.JobName,
-                          UserId = dimJob.UserId,
-                          UserName = dimJob.UserName,
-                          ClientId = factTask.LastClientId ?? default(Guid),
-                          ClientName = a != null ? a.Name : string.Empty,
-                          Date = endTime,
-                          Details = factTask.Exception
-                        })
-                        .OrderByDescending(x => x.Date)
-                        .Skip((page - 1) * size)
-                        .Take(size)
-                        .ToList()
-        });
-      }
+      var pm = PersistenceManager;
+      var dimClientDao = pm.DimClientDao;
+      var dimJobDao = pm.DimJobDao;
+      var factTaskDao = pm.FactTaskDao;
+      var tasks = factTaskDao.GetTasksWithException();
+      return pm.UseTransaction(() => new DT.ExceptionPage {
+        TotalExceptions = tasks.Count(),
+        Exceptions = (from factTask in tasks
+                      join dimJob in dimJobDao.GetAll() on factTask.JobId equals dimJob.JobId
+                      join dimClient in dimClientDao.GetAll() on factTask.LastClientId equals
+                        dimClient.Id into taskClientJoin
+                      from a in taskClientJoin.DefaultIfEmpty()
+                      let endTime = factTask.EndTime ?? DateTime.Now
+                      select new DT.Exception {
+                        TaskId = factTask.TaskId,
+                        JobId = factTask.JobId,
+                        JobName = dimJob.JobName,
+                        UserId = dimJob.UserId,
+                        UserName = dimJob.UserName,
+                        ClientId = factTask.LastClientId ?? default(Guid),
+                        ClientName = a != null ? a.Name : string.Empty,
+                        Date = endTime,
+                        Details = factTask.Exception
+                      })
+                      .OrderByDescending(x => x.Date)
+                      .Skip((page - 1) * size)
+                      .Take(size)
+                      .ToList()
+      });
     }
   }
Index: branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/GroupController.cs
===================================================================
--- branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/GroupController.cs	(revision 12780)
+++ branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/GroupController.cs	(revision 12858)
@@ -35,38 +35,84 @@
 
     public DT.GroupDetails GetGroupDetails(Guid id) {
-      using (var pm = PersistenceManager) {
-        var dimClientDao = pm.DimClientDao;
-        var factClientInfoDao = pm.FactClientInfoDao;
-        var factTaskDao = pm.FactTaskDao;
-        return pm.UseTransaction(() => {
-          var clientTimeData = factClientInfoDao.GetAll()
-            .Join(dimClientDao.GetAll(), x => x.ClientId, y => y.Id, (x, y) => new {
-              y.ResourceGroupId,
-              x.IdleTime,
-              x.OfflineTime,
-              x.UnavailableTime
-            })
-            .Where(x => x.ResourceGroupId == id)
-            .GroupBy(x => x.ResourceGroupId)
-            .Select(x => new {
-              TotalIdleTime = x.Sum(y => y.IdleTime),
-              TotalOfflineTime = x.Sum(y => y.OfflineTime),
-              TotalUnavailableTime = x.Sum(y => y.UnavailableTime)
-            })
-            .FirstOrDefault();
+      var pm = PersistenceManager;
+      var dimClientDao = pm.DimClientDao;
+      var factClientInfoDao = pm.FactClientInfoDao;
+      var factTaskDao = pm.FactTaskDao;
+      return pm.UseTransaction(() => {
+        var clientTimeData = factClientInfoDao.GetAll()
+          .Join(dimClientDao.GetAll(), x => x.ClientId, y => y.Id, (x, y) => new {
+            y.ResourceGroupId,
+            x.IdleTime,
+            x.OfflineTime,
+            x.UnavailableTime
+          })
+          .Where(x => x.ResourceGroupId == id)
+          .GroupBy(x => x.ResourceGroupId)
+          .Select(x => new {
+            TotalIdleTime = x.Sum(y => y.IdleTime),
+            TotalOfflineTime = x.Sum(y => y.OfflineTime),
+            TotalUnavailableTime = x.Sum(y => y.UnavailableTime)
+          })
+          .FirstOrDefault();
 
-          var taskTimeData = factTaskDao.GetByGroupId(id)
-            .Select(x => new {
-              id,
-              x.CalculatingTime,
-              x.TransferTime
-            })
-            .GroupBy(x => x.id)
-            .Select(x => new {
-              CalculatingTime = x.Sum(y => y.CalculatingTime),
-              TransferTime = x.Sum(y => y.TransferTime)
-            })
-            .FirstOrDefault();
-          return (from client in dimClientDao.GetActiveClients().Where(x => x.ResourceGroupId == id)
+        var taskTimeData = factTaskDao.GetByGroupId(id)
+          .Select(x => new {
+            id,
+            x.CalculatingTime,
+            x.TransferTime
+          })
+          .GroupBy(x => x.id)
+          .Select(x => new {
+            CalculatingTime = x.Sum(y => y.CalculatingTime),
+            TransferTime = x.Sum(y => y.TransferTime)
+          })
+          .FirstOrDefault();
+        return (from client in dimClientDao.GetActiveClients().Where(x => x.ResourceGroupId == id)
+                join info in factClientInfoDao.GetAll()
+                  on client.Id equals info.ClientId into clientInfoJoin
+                from clientInfo in clientInfoJoin.OrderByDescending(x => x.Time).Take(1)
+                let offline = (clientInfo.SlaveState == DA.SlaveState.Offline)
+                select new {
+                  ResourceGroupId = client.ResourceGroupId,
+                  GroupName = client.GroupName,
+                  TotalCores = clientInfo.NumTotalCores,
+                  UsedCores = offline ? 0 : clientInfo.NumUsedCores,
+                  TotalMemory = clientInfo.TotalMemory,
+                  UsedMemory = offline ? 0 : clientInfo.UsedMemory,
+                  CpuUtilization = offline ? 0 : clientInfo.CpuUtilization,
+                  SlaveState = clientInfo.SlaveState
+                })
+          .GroupBy(x => new { x.ResourceGroupId, x.GroupName })
+          .Select(x => new DT.GroupDetails {
+            Id = id,
+            Name = x.Key.GroupName,
+            TotalClients = x.Count(),
+            OnlineClients = x.Count(y => y.SlaveState != DA.SlaveState.Offline),
+            TotalCores = x.Sum(y => y.TotalCores),
+            UsedCores = x.Sum(y => y.UsedCores),
+            TotalMemory = x.Sum(y => y.TotalMemory),
+            UsedMemory = x.Sum(y => y.UsedMemory),
+            TotalCpuUtilization = x.Average(y => (double?)y.CpuUtilization) ?? 0.0,
+            ActiveCpuUtilization = x.Where(y => y.SlaveState != DA.SlaveState.Offline).Average(y => (double?)y.CpuUtilization) ?? 0.0,
+            TotalUnavailableTime = clientTimeData != null ? clientTimeData.TotalUnavailableTime : 0,
+            TotalCalculatingTime = taskTimeData != null ? taskTimeData.CalculatingTime : 0,
+            TotalIdleTime = clientTimeData != null ? clientTimeData.TotalIdleTime : 0,
+            TotalOfflineTime = clientTimeData != null ? clientTimeData.TotalOfflineTime : 0,
+            TotalTransferringTime = taskTimeData != null ? taskTimeData.TransferTime : 0,
+            TasksStates = factTaskDao.GetByGroupId(id)
+                                  .GroupBy(y => y.TaskState)
+                                  .Select(y => new DT.TaskStateCount {
+                                    State = y.Key.ToString(),
+                                    Count = y.Count()
+                                  }).ToList()
+          }).FirstOrDefault();
+      });
+    }
+
+    public DT.GroupPage GetGroups(int page, int size) {
+      var pm = PersistenceManager;
+      var dimClientDao = pm.DimClientDao;
+      var factClientInfoDao = pm.FactClientInfoDao;
+      var data = (from client in dimClientDao.GetActiveClients()
                   join info in factClientInfoDao.GetAll()
                     on client.Id equals info.ClientId into clientInfoJoin
@@ -75,5 +121,4 @@
                   select new {
                     ResourceGroupId = client.ResourceGroupId,
-                    GroupName = client.GroupName,
                     TotalCores = clientInfo.NumTotalCores,
                     UsedCores = offline ? 0 : clientInfo.NumUsedCores,
@@ -82,85 +127,38 @@
                     CpuUtilization = offline ? 0 : clientInfo.CpuUtilization,
                     SlaveState = clientInfo.SlaveState
-                  })
-            .GroupBy(x => new { x.ResourceGroupId, x.GroupName })
-            .Select(x => new DT.GroupDetails {
-              Id = id,
-              Name = x.Key.GroupName,
-              TotalClients = x.Count(),
-              OnlineClients = x.Count(y => y.SlaveState != DA.SlaveState.Offline),
-              TotalCores = x.Sum(y => y.TotalCores),
-              UsedCores = x.Sum(y => y.UsedCores),
-              TotalMemory = x.Sum(y => y.TotalMemory),
-              UsedMemory = x.Sum(y => y.UsedMemory),
-              TotalCpuUtilization = x.Average(y => (double?)y.CpuUtilization) ?? 0.0,
-              ActiveCpuUtilization = x.Where(y => y.SlaveState != DA.SlaveState.Offline).Average(y => (double?)y.CpuUtilization) ?? 0.0,
-              TotalUnavailableTime = clientTimeData != null ? clientTimeData.TotalUnavailableTime : 0,
-              TotalCalculatingTime = taskTimeData != null ? taskTimeData.CalculatingTime : 0,
-              TotalIdleTime = clientTimeData != null ? clientTimeData.TotalIdleTime : 0,
-              TotalOfflineTime = clientTimeData != null ? clientTimeData.TotalOfflineTime : 0,
-              TotalTransferringTime = taskTimeData != null ? taskTimeData.TransferTime : 0,
-              TasksStates = factTaskDao.GetByGroupId(id)
-                                    .GroupBy(y => y.TaskState)
-                                    .Select(y => new DT.TaskStateCount {
-                                      State = y.Key.ToString(),
-                                      Count = y.Count()
-                                    }).ToList()
-            }).FirstOrDefault();
+                  }).GroupBy(x => x.ResourceGroupId).Select(x => new {
+                    GroupId = x.Key,
+                    TotalClients = x.Count(),
+                    OnlineClients = x.Count(y => y.SlaveState != DA.SlaveState.Offline),
+                    TotalCores = x.Sum(y => y.TotalCores),
+                    UsedCores = x.Sum(y => y.UsedCores),
+                    TotalMemory = x.Sum(y => y.TotalMemory),
+                    UsedMemory = x.Sum(y => y.UsedMemory),
+                    CpuUtilization = x.Where(y => y.SlaveState != DA.SlaveState.Offline).Average(y => (double?)y.CpuUtilization) ?? 0.0
+                  });
+      var query = dimClientDao.GetAll()
+        .GroupBy(x => new { x.ResourceGroupId, x.GroupName })
+        .Select(x => new {
+          Id = x.Key.ResourceGroupId ?? default(Guid),
+          Name = x.Key.GroupName
         });
-      }
-    }
-
-    public DT.GroupPage GetGroups(int page, int size) {
-      using (var pm = PersistenceManager) {
-        var dimClientDao = pm.DimClientDao;
-        var factClientInfoDao = pm.FactClientInfoDao;
-        var data = (from client in dimClientDao.GetActiveClients()
-                    join info in factClientInfoDao.GetAll()
-                      on client.Id equals info.ClientId into clientInfoJoin
-                    from clientInfo in clientInfoJoin.OrderByDescending(x => x.Time).Take(1)
-                    let offline = (clientInfo.SlaveState == DA.SlaveState.Offline)
-                    select new {
-                      ResourceGroupId = client.ResourceGroupId,
-                      TotalCores = clientInfo.NumTotalCores,
-                      UsedCores = offline ? 0 : clientInfo.NumUsedCores,
-                      TotalMemory = clientInfo.TotalMemory,
-                      UsedMemory = offline ? 0 : clientInfo.UsedMemory,
-                      CpuUtilization = offline ? 0 : clientInfo.CpuUtilization,
-                      SlaveState = clientInfo.SlaveState
-                    }).GroupBy(x => x.ResourceGroupId).Select(x => new {
-                      GroupId = x.Key,
-                      TotalClients = x.Count(),
-                      OnlineClients = x.Count(y => y.SlaveState != DA.SlaveState.Offline),
-                      TotalCores = x.Sum(y => y.TotalCores),
-                      UsedCores = x.Sum(y => y.UsedCores),
-                      TotalMemory = x.Sum(y => y.TotalMemory),
-                      UsedMemory = x.Sum(y => y.UsedMemory),
-                      CpuUtilization = x.Where(y => y.SlaveState != DA.SlaveState.Offline).Average(y => (double?)y.CpuUtilization) ?? 0.0
-                    });
-        var query = dimClientDao.GetAll()
-          .GroupBy(x => new { x.ResourceGroupId, x.GroupName })
-          .Select(x => new {
-            Id = x.Key.ResourceGroupId ?? default(Guid),
-            Name = x.Key.GroupName
-          });
-        return pm.UseTransaction(() => new DT.GroupPage {
-          TotalGroups = query.Count(),
-          Groups = query
-          .Skip((page - 1) * size)
-          .Take(size)
-          .Join(data, x => x.Id, y => y.GroupId,
-            (group, info) => new DT.Group {
-              Id = group.Id,
-              Name = group.Name,
-              TotalClients = info.TotalClients,
-              OnlineClients = info.OnlineClients,
-              TotalCores = info.TotalCores,
-              UsedCores = info.UsedCores,
-              TotalMemory = info.TotalMemory,
-              UsedMemory = info.UsedMemory,
-              CpuUtilization = info.CpuUtilization
-            }).ToList()
-        });
-      }
+      return pm.UseTransaction(() => new DT.GroupPage {
+        TotalGroups = query.Count(),
+        Groups = query
+        .Skip((page - 1) * size)
+        .Take(size)
+        .Join(data, x => x.Id, y => y.GroupId,
+          (group, info) => new DT.Group {
+            Id = group.Id,
+            Name = group.Name,
+            TotalClients = info.TotalClients,
+            OnlineClients = info.OnlineClients,
+            TotalCores = info.TotalCores,
+            UsedCores = info.UsedCores,
+            TotalMemory = info.TotalMemory,
+            UsedMemory = info.UsedMemory,
+            CpuUtilization = info.CpuUtilization
+          }).ToList()
+      });
     }
   }
Index: branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/JobController.cs
===================================================================
--- branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/JobController.cs	(revision 12780)
+++ branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/JobController.cs	(revision 12858)
@@ -47,47 +47,46 @@
 
     public DT.JobDetails GetJobDetails(Guid id) {
-      using (var pm = PersistenceManager) {
-        var dimJobDao = pm.DimJobDao;
-        var factTaskDao = pm.FactTaskDao;
-        return pm.UseTransaction(() => {
-          var job = dimJobDao.GetById(id);
-          if (job != null) {
-            var timeData = factTaskDao.GetByJobId(id).GroupBy(x => x.JobId).Select(x => new {
-              AvgTransferringTime = (long)x.Average(y => y.TransferTime),
-              MinCalculatingTime = (long)x.Min(y => y.CalculatingTime),
-              MaxCalculatingTime = (long)x.Max(y => y.CalculatingTime),
-              AvgCalculatingTime = (long)x.Average(y => y.CalculatingTime),
-              TotalCalculatingTime = (long)x.Sum(y => y.CalculatingTime),
-              TotalWaitingTime = (long)x.Sum(y => y.WaitingTime)
-            }).FirstOrDefault();
-            DateTime endTime = job.DateCompleted ?? DateTime.Now;
-            long totalTime = (long)(endTime - job.DateCreated).TotalSeconds;
-            return new DT.JobDetails {
-              Id = job.JobId,
-              Name = job.JobName,
-              UserId = job.UserId,
-              UserName = job.UserName,
-              DateCreated = job.DateCreated,
-              DateCompleted = job.DateCompleted,
-              TotalTasks = job.TotalTasks,
-              CompletedTasks = job.CompletedTasks,
-              AvgTransferringTime = timeData != null ? timeData.AvgTransferringTime : 0,
-              AvgCalculatingTime = timeData != null ? timeData.AvgCalculatingTime : 0,
-              MinCalculatingTime = timeData != null ? timeData.MinCalculatingTime : 0,
-              MaxCalculatingTime = timeData != null ? timeData.MaxCalculatingTime : 0,
-              TotalCalculatingTime = timeData != null ? timeData.TotalCalculatingTime : 0,
-              TotalWaitingTime = timeData != null ? timeData.TotalWaitingTime : 0,
-              TotalTime = totalTime,
-              TasksStates = factTaskDao.GetByJobId(id)
-                            .GroupBy(x => x.TaskState)
-                            .Select(x => new DT.TaskStateCount {
-                              State = x.Key.ToString(),
-                              Count = x.Count()
-                            }).ToList()
-            };
-          }
-          return null;
-        });
-      }
+      var pm = PersistenceManager;
+      var dimJobDao = pm.DimJobDao;
+      var factTaskDao = pm.FactTaskDao;
+      return pm.UseTransaction(() => {
+        var job = dimJobDao.GetById(id);
+        if (job != null) {
+          var timeData = factTaskDao.GetByJobId(id).GroupBy(x => x.JobId).Select(x => new {
+            AvgTransferringTime = (long)x.Average(y => y.TransferTime),
+            MinCalculatingTime = (long)x.Min(y => y.CalculatingTime),
+            MaxCalculatingTime = (long)x.Max(y => y.CalculatingTime),
+            AvgCalculatingTime = (long)x.Average(y => y.CalculatingTime),
+            TotalCalculatingTime = (long)x.Sum(y => y.CalculatingTime),
+            TotalWaitingTime = (long)x.Sum(y => y.WaitingTime)
+          }).FirstOrDefault();
+          DateTime endTime = job.DateCompleted ?? DateTime.Now;
+          long totalTime = (long)(endTime - job.DateCreated).TotalSeconds;
+          return new DT.JobDetails {
+            Id = job.JobId,
+            Name = job.JobName,
+            UserId = job.UserId,
+            UserName = job.UserName,
+            DateCreated = job.DateCreated,
+            DateCompleted = job.DateCompleted,
+            TotalTasks = job.TotalTasks,
+            CompletedTasks = job.CompletedTasks,
+            AvgTransferringTime = timeData != null ? timeData.AvgTransferringTime : 0,
+            AvgCalculatingTime = timeData != null ? timeData.AvgCalculatingTime : 0,
+            MinCalculatingTime = timeData != null ? timeData.MinCalculatingTime : 0,
+            MaxCalculatingTime = timeData != null ? timeData.MaxCalculatingTime : 0,
+            TotalCalculatingTime = timeData != null ? timeData.TotalCalculatingTime : 0,
+            TotalWaitingTime = timeData != null ? timeData.TotalWaitingTime : 0,
+            TotalTime = totalTime,
+            TasksStates = factTaskDao.GetByJobId(id)
+                          .GroupBy(x => x.TaskState)
+                          .Select(x => new DT.TaskStateCount {
+                            State = x.Key.ToString(),
+                            Count = x.Count()
+                          }).ToList()
+          };
+        }
+        return null;
+      });
     }
 
@@ -100,18 +99,17 @@
         RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator);
       }
-      using (var pm = PersistenceManager) {
-        var dimJobDao = pm.DimJobDao;
-        return pm.UseTransaction(() => {
-          var jobs = dimJobDao.GetByUserId(id).Where(x => completed ? (x.DateCompleted != null) : (x.DateCompleted == null));
-          return new DT.JobPage {
-            TotalJobs = jobs.Count(),
-            Jobs = jobs.OrderByDescending(x => x.DateCompleted ?? DateTime.MaxValue)
-              .Skip((page - 1) * size)
-              .Take(size)
-              .Select(x => ConvertToDT(x))
-              .ToList()
-          };
-        });
-      }
+      var pm = PersistenceManager;
+      var dimJobDao = pm.DimJobDao;
+      return pm.UseTransaction(() => {
+        var jobs = dimJobDao.GetByUserId(id).Where(x => completed ? (x.DateCompleted != null) : (x.DateCompleted == null));
+        return new DT.JobPage {
+          TotalJobs = jobs.Count(),
+          Jobs = jobs.OrderByDescending(x => x.DateCompleted ?? DateTime.MaxValue)
+            .Skip((page - 1) * size)
+            .Take(size)
+            .Select(x => ConvertToDT(x))
+            .ToList()
+        };
+      });
     }
 
@@ -124,27 +122,25 @@
         RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator);
       }
-      using (var pm = PersistenceManager) {
-        var dimJobDao = pm.DimJobDao;
-        return pm.UseTransaction(() => {
-          return dimJobDao.GetByUserId(id)
-            .Where(x => completed ? (x.DateCompleted != null) : (x.DateCompleted == null))
-            .Select(x => ConvertToDT(x))
-            .ToList();
-        });
-      }
+      var pm = PersistenceManager;
+      var dimJobDao = pm.DimJobDao;
+      return pm.UseTransaction(() => {
+        return dimJobDao.GetByUserId(id)
+          .Where(x => completed ? (x.DateCompleted != null) : (x.DateCompleted == null))
+          .Select(x => ConvertToDT(x))
+          .ToList();
+      });
     }
 
     [Authorize(Roles = HiveRoles.Administrator)]
     public IEnumerable<DT.Job> GetAllActiveJobsFromAllUsers() {
-      using (var pm = PersistenceManager) {
-        var dimJobDao = pm.DimJobDao;
-        return pm.UseTransaction(() => {
-          return dimJobDao.GetAll()
-            .Where(x => x.DateCompleted == null)
-            .OrderByDescending(x => x.DateCreated)
-            .Select(x => ConvertToDT(x))
-            .ToList();
-        });
-      }
+      var pm = PersistenceManager;
+      var dimJobDao = pm.DimJobDao;
+      return pm.UseTransaction(() => {
+        return dimJobDao.GetAll()
+          .Where(x => x.DateCompleted == null)
+          .OrderByDescending(x => x.DateCreated)
+          .Select(x => ConvertToDT(x))
+          .ToList();
+      });
     }
 
Index: branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/TaskController.cs
===================================================================
--- branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/TaskController.cs	(revision 12780)
+++ branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/TaskController.cs	(revision 12858)
@@ -51,57 +51,56 @@
     [HttpPost]
     public DT.TaskPage GetTasksByJobId(Guid id, int page, int size, IEnumerable<string> states) {
-      using (var pm = PersistenceManager) {
-        var dimJobDao = pm.DimJobDao;
-        var dimClientDao = pm.DimClientDao;
-        var factTaskDao = pm.FactTaskDao;
+      var pm = PersistenceManager;
+      var dimJobDao = pm.DimJobDao;
+      var dimClientDao = pm.DimClientDao;
+      var factTaskDao = pm.FactTaskDao;
 
-        DA.DimJob job = pm.UseTransaction(() => dimJobDao.GetById(id));
-        if (job == null) {
-          throw new ArgumentException("invalid job id");
-        }
-        if (job.UserId != UserManager.CurrentUserId) {
-          RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator);
-        }
+      DA.DimJob job = pm.UseTransaction(() => dimJobDao.GetById(id));
+      if (job == null) {
+        throw new ArgumentException("invalid job id");
+      }
+      if (job.UserId != UserManager.CurrentUserId) {
+        RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator);
+      }
 
-        return pm.UseTransaction(() => {
-          var tasks = factTaskDao.GetByJobId(id).Where(x => states.Contains(x.TaskState.ToString()));
-          return new DT.TaskPage {
-            TotalTasks = tasks.Count(),
-            Tasks = (from factTask in tasks
-                     join dimJob in dimJobDao.GetAll() on factTask.JobId equals dimJob.JobId
-                     join dimClient in dimClientDao.GetAll() on factTask.LastClientId equals
-                       dimClient.Id into taskClientJoin
-                     from a in taskClientJoin.DefaultIfEmpty()
-                     let startTime = factTask.StartTime ?? DateTime.Now
-                     let endTime = factTask.EndTime ?? DateTime.Now
-                     select new DT.Task {
-                       Id = factTask.TaskId,
-                       JobId = factTask.JobId,
-                       JobName = dimJob.JobName,
-                       TotalTime = (long)(endTime - startTime).TotalSeconds,
-                       CalculatingTime = factTask.CalculatingTime,
-                       WaitingTime = factTask.WaitingTime,
-                       TransferTime = factTask.TransferTime,
-                       InitialWaitingTime = factTask.InitialWaitingTime,
-                       NumCalculationRuns = factTask.NumCalculationRuns,
-                       NumRetries = factTask.NumRetries,
-                       CoresRequired = factTask.CoresRequired,
-                       MemoryRequired = factTask.MemoryRequired,
-                       Priority = factTask.Priority,
-                       State = factTask.TaskState.ToString(),
-                       LastClientId = factTask.LastClientId,
-                       LastClientName = a != null ? a.Name : string.Empty,
-                       UserId = dimJob.UserId,
-                       UserName = dimJob.UserName,
-                       StartTime = factTask.StartTime,
-                       EndTime = factTask.EndTime,
-                       Exception = factTask.Exception
-                     })
-              .Skip((page - 1) * size)
-              .Take(size)
-              .ToList()
-          };
-        });
-      }
+      return pm.UseTransaction(() => {
+        var tasks = factTaskDao.GetByJobId(id).Where(x => states.Contains(x.TaskState.ToString()));
+        return new DT.TaskPage {
+          TotalTasks = tasks.Count(),
+          Tasks = (from factTask in tasks
+                   join dimJob in dimJobDao.GetAll() on factTask.JobId equals dimJob.JobId
+                   join dimClient in dimClientDao.GetAll() on factTask.LastClientId equals
+                     dimClient.Id into taskClientJoin
+                   from a in taskClientJoin.DefaultIfEmpty()
+                   let startTime = factTask.StartTime ?? DateTime.Now
+                   let endTime = factTask.EndTime ?? DateTime.Now
+                   select new DT.Task {
+                     Id = factTask.TaskId,
+                     JobId = factTask.JobId,
+                     JobName = dimJob.JobName,
+                     TotalTime = (long)(endTime - startTime).TotalSeconds,
+                     CalculatingTime = factTask.CalculatingTime,
+                     WaitingTime = factTask.WaitingTime,
+                     TransferTime = factTask.TransferTime,
+                     InitialWaitingTime = factTask.InitialWaitingTime,
+                     NumCalculationRuns = factTask.NumCalculationRuns,
+                     NumRetries = factTask.NumRetries,
+                     CoresRequired = factTask.CoresRequired,
+                     MemoryRequired = factTask.MemoryRequired,
+                     Priority = factTask.Priority,
+                     State = factTask.TaskState.ToString(),
+                     LastClientId = factTask.LastClientId,
+                     LastClientName = a != null ? a.Name : string.Empty,
+                     UserId = dimJob.UserId,
+                     UserName = dimJob.UserName,
+                     StartTime = factTask.StartTime,
+                     EndTime = factTask.EndTime,
+                     Exception = factTask.Exception
+                   })
+            .Skip((page - 1) * size)
+            .Take(size)
+            .ToList()
+        };
+      });
     }
 
@@ -109,72 +108,70 @@
     public DT.TaskPage GetTasksByClientId(Guid id, int page, int size, IEnumerable<string> states, Guid userId = default(Guid)) {
       bool isAdministrator = User.IsInRole(HiveRoles.Administrator);
-      using (var pm = PersistenceManager) {
-        var dimJobDao = pm.DimJobDao;
-        var dimClientDao = pm.DimClientDao;
-        var factTaskDao = pm.FactTaskDao;
-        return pm.UseTransaction(() => {
-          var tasks = factTaskDao.GetByClientId(id).Where(x => states.Contains(x.TaskState.ToString()));
-          if (userId != Guid.Empty) {
-            tasks = tasks.Where(x => x.DimJob.UserId == userId);
-          }
-          return new DT.TaskPage {
-            TotalTasks = tasks.Count(),
-            Tasks = (from factTask in tasks
-                     join dimJob in dimJobDao.GetAll() on factTask.JobId equals dimJob.JobId
-                     join dimClient in dimClientDao.GetAll() on factTask.LastClientId equals
-                       dimClient.Id into taskClientJoin
-                     from a in taskClientJoin.DefaultIfEmpty()
-                     let startTime = factTask.StartTime ?? DateTime.Now
-                     let endTime = factTask.EndTime ?? DateTime.Now
-                     select new DT.Task {
-                       Id = isAdministrator ? factTask.TaskId : default(Guid),
-                       JobId = isAdministrator ? factTask.JobId : default(Guid),
-                       JobName = isAdministrator ? dimJob.JobName : string.Empty,
-                       TotalTime = (long)(endTime - startTime).TotalSeconds,
-                       CalculatingTime = factTask.CalculatingTime,
-                       WaitingTime = factTask.WaitingTime,
-                       TransferTime = factTask.TransferTime,
-                       InitialWaitingTime = factTask.InitialWaitingTime,
-                       NumCalculationRuns = factTask.NumCalculationRuns,
-                       NumRetries = factTask.NumRetries,
-                       CoresRequired = factTask.CoresRequired,
-                       MemoryRequired = factTask.MemoryRequired,
-                       Priority = factTask.Priority,
-                       State = factTask.TaskState.ToString(),
-                       LastClientId = factTask.LastClientId,
-                       LastClientName = a != null ? a.Name : string.Empty,
-                       UserId = isAdministrator ? dimJob.UserId : default(Guid),
-                       UserName = isAdministrator ? dimJob.UserName : string.Empty,
-                       StartTime = factTask.StartTime,
-                       EndTime = factTask.EndTime,
-                       Exception = isAdministrator ? factTask.Exception : string.Empty
-                     })
-                  .OrderByDescending(x => x.EndTime ?? DateTime.MaxValue)
-                  .Skip((page - 1) * size)
-                  .Take(size)
-                  .ToList()
-          };
-        });
-      }
+      var pm = PersistenceManager;
+      var dimJobDao = pm.DimJobDao;
+      var dimClientDao = pm.DimClientDao;
+      var factTaskDao = pm.FactTaskDao;
+      return pm.UseTransaction(() => {
+        var tasks = factTaskDao.GetByClientId(id).Where(x => states.Contains(x.TaskState.ToString()));
+        if (userId != Guid.Empty) {
+          tasks = tasks.Where(x => x.DimJob.UserId == userId);
+        }
+        return new DT.TaskPage {
+          TotalTasks = tasks.Count(),
+          Tasks = (from factTask in tasks
+                   join dimJob in dimJobDao.GetAll() on factTask.JobId equals dimJob.JobId
+                   join dimClient in dimClientDao.GetAll() on factTask.LastClientId equals
+                     dimClient.Id into taskClientJoin
+                   from a in taskClientJoin.DefaultIfEmpty()
+                   let startTime = factTask.StartTime ?? DateTime.Now
+                   let endTime = factTask.EndTime ?? DateTime.Now
+                   select new DT.Task {
+                     Id = isAdministrator ? factTask.TaskId : default(Guid),
+                     JobId = isAdministrator ? factTask.JobId : default(Guid),
+                     JobName = isAdministrator ? dimJob.JobName : string.Empty,
+                     TotalTime = (long)(endTime - startTime).TotalSeconds,
+                     CalculatingTime = factTask.CalculatingTime,
+                     WaitingTime = factTask.WaitingTime,
+                     TransferTime = factTask.TransferTime,
+                     InitialWaitingTime = factTask.InitialWaitingTime,
+                     NumCalculationRuns = factTask.NumCalculationRuns,
+                     NumRetries = factTask.NumRetries,
+                     CoresRequired = factTask.CoresRequired,
+                     MemoryRequired = factTask.MemoryRequired,
+                     Priority = factTask.Priority,
+                     State = factTask.TaskState.ToString(),
+                     LastClientId = factTask.LastClientId,
+                     LastClientName = a != null ? a.Name : string.Empty,
+                     UserId = isAdministrator ? dimJob.UserId : default(Guid),
+                     UserName = isAdministrator ? dimJob.UserName : string.Empty,
+                     StartTime = factTask.StartTime,
+                     EndTime = factTask.EndTime,
+                     Exception = isAdministrator ? factTask.Exception : string.Empty
+                   })
+                .OrderByDescending(x => x.EndTime ?? DateTime.MaxValue)
+                .Skip((page - 1) * size)
+                .Take(size)
+                .ToList()
+        };
+      });
     }
 
     public HttpResponseMessage GetTaskDataById(Guid id) {
-      using (var pm = PersistenceManager) {
-        var taskDataDao = pm.TaskDataDao;
-        return pm.UseTransaction(() => {
-          var taskData = taskDataDao.GetById(id);
-          if (taskData == null)
-            return new HttpResponseMessage(HttpStatusCode.NotFound);
-          HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);
-          var stream = new MemoryStream(taskData.Data);
-          result.Content = new StreamContent(stream);
-          result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
-          result.Content.Headers.ContentDisposition =
-            new ContentDispositionHeaderValue("attachment") {
-              FileName = string.Format("{0}.hl", id)
-            };
-          return result;
-        });
-      }
+      var pm = PersistenceManager;
+      var taskDataDao = pm.TaskDataDao;
+      return pm.UseTransaction(() => {
+        var taskData = taskDataDao.GetById(id);
+        if (taskData == null)
+          return new HttpResponseMessage(HttpStatusCode.NotFound);
+        HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);
+        var stream = new MemoryStream(taskData.Data);
+        result.Content = new StreamContent(stream);
+        result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
+        result.Content.Headers.ContentDisposition =
+          new ContentDispositionHeaderValue("attachment") {
+            FileName = string.Format("{0}.hl", id)
+          };
+        return result;
+      });
     }
   }
Index: branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/UserController.cs
===================================================================
--- branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/UserController.cs	(revision 12780)
+++ branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/UserController.cs	(revision 12858)
@@ -37,36 +37,34 @@
 
     public IEnumerable<DT.User> GetUsers() {
-      using (var pm = PersistenceManager) {
-        var dimUserDao = pm.DimUserDao;
-        return pm.UseTransaction(() => {
-          return dimUserDao.GetAll().Select(x => new DT.User {
-            Id = x.UserId,
-            Name = x.Name
-          }).ToList();
-        });
-      }
+      var pm = PersistenceManager;
+      var dimUserDao = pm.DimUserDao;
+      return pm.UseTransaction(() => {
+        return dimUserDao.GetAll().Select(x => new DT.User {
+          Id = x.UserId,
+          Name = x.Name
+        }).ToList();
+      });
     }
 
     public DT.UserDetails GetUser(Guid id) {
-      using (var pm = PersistenceManager) {
-        var dimUserDao = pm.DimUserDao;
-        var factTaskDao = pm.FactTaskDao;
-        return pm.UseTransaction(() => {
-          var user = dimUserDao.GetById(id);
-          if (user != null) {
-            return new DT.UserDetails {
-              Id = user.UserId,
-              Name = user.Name,
-              TasksStates = factTaskDao.GetByUserId(id)
-                            .GroupBy(x => x.TaskState)
-                            .Select(x => new DT.TaskStateCount {
-                              State = x.Key.ToString(),
-                              Count = x.Count()
-                            }).ToList()
-            };
-          }
-          return null;
-        });
-      }
+      var pm = PersistenceManager;
+      var dimUserDao = pm.DimUserDao;
+      var factTaskDao = pm.FactTaskDao;
+      return pm.UseTransaction(() => {
+        var user = dimUserDao.GetById(id);
+        if (user != null) {
+          return new DT.UserDetails {
+            Id = user.UserId,
+            Name = user.Name,
+            TasksStates = factTaskDao.GetByUserId(id)
+                          .GroupBy(x => x.TaskState)
+                          .Select(x => new DT.TaskStateCount {
+                            State = x.Key.ToString(),
+                            Count = x.Count()
+                          }).ToList()
+          };
+        }
+        return null;
+      });
     }
   }
