Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/27/14 16:39:43 (10 years ago)
Author:
mroscoe
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive.Statistics/3.3/Controllers/ExceptionDataController.cs

    r11030 r11053  
    99  public class ExceptionDataController : Controller {
    1010
    11     public JsonResult TaskExceptions(string userName, string limit, DateTime? start = null, DateTime? end = null, string jobId = null, string taskState = null) {
     11    public JsonResult TaskExceptions(string limit, string userName, DateTime? start = null, DateTime? end = null, string jobId = null, string taskState = null)
     12    {
    1213      using (var db = new HiveDataContext(Settings.Default.HeuristicLab_Hive_LinqConnectionString)) {
    1314        TaskState state = GetTaskState(taskState);
    1415        var data =
    15         (from errors in db.StateLogs
    16           join tasks in db.FactTasks
    17             on errors.TaskId equals tasks.TaskId
     16        (from tasks in db.FactTasks
    1817          join jobs in db.DimJobs
    1918            on tasks.JobId equals jobs.JobId
    20           where jobs.UserName == userName &&
    21           errors.Exception != null &&
    22           !errors.Exception.Equals(string.Empty) &&
     19          where tasks.Exception != null &&
     20          !tasks.Exception.Equals(string.Empty) &&
     21          (string.IsNullOrEmpty(userName) || jobs.UserName == userName) &&
    2322          (!start.HasValue || tasks.StartTime >= start) &&
    2423          (!end.HasValue || tasks.EndTime < end) &&
     
    2726          select new
    2827          {
    29             TaskID = errors.TaskId,
    30             ErrorMessage = errors.Exception,
     28            TaskID = tasks.TaskId,
     29            ErrorMessage = tasks.Exception,
    3130            StartDate = tasks.StartTime
    3231          }).OrderByDescending(s => s.StartDate).Take(Convert.ToInt32(limit)).ToList();
     
    3837
    3938        return Json(new KeyValuePair<List<string>, List<string>>(Task, Error), JsonRequestBehavior.AllowGet);
     39      }
     40    }
     41
     42    public JsonResult SlaveExceptions(string limit, DateTime? start = null, DateTime? end = null, string clientId = null) {
     43      using (var db = new HiveDataContext(Settings.Default.HeuristicLab_Hive_LinqConnectionString)) {
     44        var data =
     45        (from tasks in db.FactTasks
     46         join jobs in db.DimJobs
     47           on tasks.JobId equals jobs.JobId
     48         where tasks.Exception != null &&
     49          !tasks.Exception.Equals(string.Empty) &&
     50          (!start.HasValue || tasks.StartTime >= start) &&
     51         (!end.HasValue || tasks.EndTime < end) &&
     52         (string.IsNullOrEmpty(clientId) || tasks.LastClientId.ToString() == clientId)
     53         select new {
     54           TaskID = tasks.TaskId,
     55           ErrorMessage = tasks.Exception,
     56           ClientID = tasks.LastClientId,
     57           UserName = jobs.UserName,
     58           StartDate = tasks.StartTime
     59         }).OrderByDescending(s => s.StartDate).Take(Convert.ToInt32(limit)).ToList();
     60
     61        List<List<string>> results = new List<List<string>>();
     62
     63        for (int i = 0; i < data.Count; i++) {
     64          results.Add(
     65            new List<string> { data[i].TaskID.ToString(), data[i].ErrorMessage, data[i].ClientID.ToString(), data[i].UserName,
     66              data[i].StartDate.ToString("dd/MM/yyyy HH:mm")}
     67          );
     68        }
     69        return Json(results, JsonRequestBehavior.AllowGet);
    4070      }
    4171    }
Note: See TracChangeset for help on using the changeset viewer.