- Timestamp:
- 03/29/16 17:02:16 (9 years ago)
- Location:
- branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Hubs
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Hubs/JobUpdaterHub.cs
r13735 r13739 1 1 using HeuristicLab.Clients.Hive.WebJobManager.Services; 2 2 using HeuristicLab.Common; 3 using Microsoft.AspNet.Http; 3 4 using Microsoft.AspNet.SignalR; 4 5 using Newtonsoft.Json; 5 6 using System; 6 7 using System.Collections.Generic; 8 using System.Threading.Tasks; 7 9 8 10 namespace HeuristicLab.Clients.Hive.WebJobManager … … 15 17 16 18 private RefreshableJob Job;//Current job (only used as reference, instance gets lost) 17 19 20 private WebLoginService weblog; 21 private FileOpeningService fileopener; 22 private Guid userId; 23 24 private void loader() 25 { 26 weblog = WebLoginService.Instance; 27 string uid = Context.QueryString["userid"]; 28 if (uid == null || uid == "" || Guid.Parse(uid) == Guid.Empty) 29 { 30 userId = Guid.Empty; 31 } 32 else { 33 userId = Guid.Parse(uid); 34 fileopener = weblog.getFileOpener(userId); 35 } 36 } 18 37 /// <summary> 19 38 /// Initial connection call from client … … 21 40 public void initConnection() 22 41 { 23 FileOpeningService.Instance.previousids = new List<Guid>(); 24 FileOpeningService.Instance.previousLogs = new List<int>(); 25 Job = FileOpeningService.Instance.Job; 42 loader(); 43 fileopener.previousids = new List<Guid>(); 44 fileopener.previousLogs = new List<int>(); 45 Job = fileopener.Job; 26 46 updateAll();//start initial update 27 47 … … 32 52 public void updateAll() 33 53 { 34 FileOpeningService.Instance.refreshJob();//refresh all data from job 35 Job = FileOpeningService.Instance.Job; 54 loader(); 55 fileopener.refreshJob();//refresh all data from job 56 Job = fileopener.Job; 36 57 updateJob(); 37 58 foreach (var t in Job.HiveTasks) … … 45 66 46 67 } 47 p ublicvoid updateJob()68 private void updateJob() 48 69 { 49 70 Clients.Caller.processJobData(Job.Job.CalculatingCount, Job.Job.FinishedCount); … … 59 80 int index; 60 81 bool test = false; 61 if ( FileOpeningService.Instance.previousids.Contains(task.Task.Id))82 if (fileopener.previousids.Contains(task.Task.Id)) 62 83 { 63 index = FileOpeningService.Instance.previousids.IndexOf(task.Task.Id);84 index = fileopener.previousids.IndexOf(task.Task.Id); 64 85 } 65 86 else 66 87 {//initial add to previous list, used to check if updates happened 67 FileOpeningService.Instance.previousids.Add(task.Task.Id);68 index = FileOpeningService.Instance.previousids.IndexOf(task.Task.Id);69 FileOpeningService.Instance.previousLogs.Add(task.Task.StateLog.Count);88 fileopener.previousids.Add(task.Task.Id); 89 index = fileopener.previousids.IndexOf(task.Task.Id); 90 fileopener.previousLogs.Add(task.Task.StateLog.Count); 70 91 test = true;//initial added task, data must be sent 71 92 } 72 var previous = FileOpeningService.Instance.previousLogs[index];93 var previous = fileopener.previousLogs[index]; 73 94 if (test || previous < task.Task.StateLog.Count) 74 95 {//Checks if change happened so data is not sent unnecessary 75 FileOpeningService.Instance.previousLogs[index] = task.Task.StateLog.Count;96 fileopener.previousLogs[index] = task.Task.StateLog.Count; 76 97 JsonSerializerSettings settings = new JsonSerializerSettings(); 77 98 settings.ContractResolver = new JsonTaskResolver(); … … 94 115 public void restartTask(Guid id) 95 116 { 96 ((HiveServiceLocatorWeb)(HiveServiceLocatorWeb.Instance)).getHiveServiceClient().RestartTask(id); 117 loader(); 118 weblog.getServiceLocator(userId).getHiveServiceClient().RestartTask(id); 97 119 } 98 120 } -
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Hubs/ProgressHub.cs
r13735 r13739 15 15 public class ProgressHub : Hub 16 16 { 17 private RefreshableJob Job; 17 private WebLoginService weblog; 18 private Guid userId; 19 private FileOpeningService fileopener; 20 private void loader() 21 { 22 weblog = WebLoginService.Instance; 23 string uid = Context.QueryString["userid"]; 24 if (uid == null || uid == "" || Guid.Parse(uid) == Guid.Empty) 25 { 26 userId = Guid.Empty; 27 } 28 else { 29 userId = Guid.Parse(uid); 30 fileopener = weblog.getFileOpener(userId); 31 } 32 } 33 18 34 /// <summary> 19 35 /// First message from client … … 22 38 public void HandleMessage(string receivedString) 23 39 { 24 40 loader(); 25 41 Clients.Caller.processMessage("Connection Established"); 26 Job = FileOpeningService.Instance.Job; 27 Job.Progress.StatusChanged += runHub; 42 fileopener.Job.Progress.StatusChanged += runHub; 28 43 } 29 44 /// <summary> … … 33 48 public void ChangeNameResource(string name, string resource) 34 49 { 50 loader(); 35 51 if (name != null) 36 FileOpeningService.Instance.Job.Job.Name = name;52 fileopener.Job.Job.Name = name; 37 53 if(resource != null && resource != "") 38 54 { 39 FileOpeningService.Instance.Job.Job.ResourceNames += "/" + resource;55 fileopener.Job.Job.ResourceNames += "/" + resource; 40 56 } 41 57 } … … 49 65 public void ToggleChild(int[][] arr) 50 66 { 51 Job = FileOpeningService.Instance.Job;52 HiveTask current = Job.HiveTasks.ToList()[0];67 loader(); 68 HiveTask current = fileopener.Job.HiveTasks.ToList()[0]; 53 69 if (arr.Length == 0) 54 70 {//check if upper job … … 92 108 public void ChangePriority(int[][] arr, int prior) 93 109 { 94 Job = FileOpeningService.Instance.Job;95 HiveTask current = Job.HiveTasks.ToList()[0];110 loader(); 111 HiveTask current = fileopener.Job.HiveTasks.ToList()[0]; 96 112 if (arr.Length == 0) 97 113 {//check if upper job … … 132 148 public void runHub(object sender, EventArgs e) 133 149 { 150 loader(); 134 151 int value = 0; 135 152 136 switch ( Job.Progress.Status)153 switch (fileopener.Job.Progress.Status) 137 154 { 138 155 case "Connecting to server...": … … 152 169 break; 153 170 default://Tasks are uploading individually 154 value = (int)(50 + (40 * Job.Progress.ProgressValue));171 value = (int)(50 + (40 * fileopener.Job.Progress.ProgressValue)); 155 172 break; 156 173 157 174 } 158 175 //send info to client 159 Clients.Caller.processMessage( Job.Progress.Status, value);176 Clients.Caller.processMessage(fileopener.Job.Progress.Status, value); 160 177 161 178 }
Note: See TracChangeset
for help on using the changeset viewer.