Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/ExceptionController.cs @ 12560

Last change on this file since 12560 was 12560, checked in by dglaser, 9 years ago

#2388:

HeuristicLab.Services.WebApp-3.3:

  • updated about page

HeuristicLab.Services.WebApp.Statistics-3.3:

  • added missing files
File size: 2.1 KB
Line 
1
2using System;
3using System.Linq;
4using System.Web.Http;
5using HeuristicLab.Services.Hive;
6using HeuristicLab.Services.Hive.DataAccess.Interfaces;
7using DT = HeuristicLab.Services.WebApp.Statistics.WebApi.DataTransfer;
8
9namespace HeuristicLab.Services.WebApp.Statistics.WebApi {
10  [Authorize(Roles = HiveRoles.Administrator)]
11  public class ExceptionController : ApiController {
12    private IPersistenceManager PersistenceManager {
13      get { return ServiceLocator.Instance.PersistenceManager; }
14    }
15
16    public DT.ExceptionPage GetExceptions(int page, int size) {
17      using (var pm = PersistenceManager) {
18        var dimClientDao = pm.DimClientDao;
19        var dimJobDao = pm.DimJobDao;
20        var factTaskDao = pm.FactTaskDao;
21        var tasks = factTaskDao.GetTasksWithException();
22        return pm.UseTransaction(() => new DT.ExceptionPage {
23          TotalExceptions = tasks.Count(),
24          Exceptions = (from factTask in tasks
25                        join dimJob in dimJobDao.GetAll() on factTask.JobId equals dimJob.JobId
26                        join dimClient in dimClientDao.GetAll() on factTask.LastClientId equals
27                          dimClient.Id into taskClientJoin
28                        from a in taskClientJoin.DefaultIfEmpty()
29                        let endTime = factTask.EndTime ?? DateTime.Now
30                        select new DT.Exception {
31                          TaskId = factTask.TaskId,
32                          JobId = factTask.JobId,
33                          JobName = dimJob.JobName,
34                          UserId = dimJob.UserId,
35                          UserName = dimJob.UserName,
36                          ClientId = factTask.LastClientId ?? default(Guid),
37                          ClientName = a != null ? a.Name : string.Empty,
38                          Date = endTime,
39                          Details = factTask.Exception
40                        })
41                        .OrderByDescending(x => x.Date)
42                        .Skip((page - 1) * size)
43                        .Take(size)
44                        .ToList()
45        });
46      }
47    }
48  }
49}
Note: See TracBrowser for help on using the repository browser.