Free cookie consent management tool by TermsFeed Policy Generator

source: branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/JobUpdaterHub.cs @ 13714

Last change on this file since 13714 was 13714, checked in by jlodewyc, 8 years ago

#2582 Implement graphs(Pie and line per task) + live job overview with SignalR

File size: 1.5 KB
Line 
1using HeuristicLab.Clients.Hive.WebJobManager.Services;
2using Microsoft.AspNet.SignalR;
3using Newtonsoft.Json;
4using System;
5using System.Collections.Generic;
6using System.Linq;
7using System.Threading.Tasks;
8using HeuristicLab.Clients.Hive.WebJobManager.Services;
9
10namespace HeuristicLab.Clients.Hive.WebJobManager
11{
12    public class JobUpdaterHub : Hub
13    {
14        private RefreshableJob Job;
15
16        public void initConnection()
17        {
18            Job = FileOpeningService.Instance.Job;
19        }
20        public void sendUpdate()
21        {
22            Clients.All.sendUpdate();
23        }
24        public void updateAll()
25        {
26            FileOpeningService.Instance.refreshJob();
27            Job = FileOpeningService.Instance.Job;
28           
29            foreach (var t in Job.HiveTasks)
30            {
31                looperTasks(t);
32            }
33            Clients.All.requestDone();
34
35        }
36        private void looperTasks(HiveTask task)
37        {
38            try
39            {
40                JsonSerializerSettings settings = new JsonSerializerSettings();
41                settings.ContractResolver = new JsonTaskResolver();
42                var json = JsonConvert.SerializeObject(task.Task, settings);
43                Clients.All.processData(task.Task.Id,json );
44                foreach (var t in task.ChildHiveTasks)
45                {
46                    looperTasks(t);
47                }
48            }
49            catch (JsonSerializationException e) { }
50        }
51    }
52}
Note: See TracBrowser for help on using the repository browser.