Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/29/16 17:02:16 (9 years ago)
Author:
jlodewyc
Message:

#2582 Overhaul Login service, done

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  
    11using HeuristicLab.Clients.Hive.WebJobManager.Services;
    22using HeuristicLab.Common;
     3using Microsoft.AspNet.Http;
    34using Microsoft.AspNet.SignalR;
    45using Newtonsoft.Json;
    56using System;
    67using System.Collections.Generic;
     8using System.Threading.Tasks;
    79
    810namespace HeuristicLab.Clients.Hive.WebJobManager
     
    1517       
    1618        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        }
    1837        /// <summary>
    1938        /// Initial connection call from client
     
    2140        public void initConnection()
    2241        {
    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;
    2646            updateAll();//start initial update
    2747
     
    3252        public void updateAll()
    3353        {
    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;
    3657            updateJob();
    3758            foreach (var t in Job.HiveTasks)
     
    4566
    4667        }
    47         public void updateJob()
     68        private void updateJob()
    4869        {
    4970            Clients.Caller.processJobData(Job.Job.CalculatingCount, Job.Job.FinishedCount);
     
    5980                int index;
    6081                bool test = false;
    61                 if (FileOpeningService.Instance.previousids.Contains(task.Task.Id))
     82                if (fileopener.previousids.Contains(task.Task.Id))
    6283                {
    63                     index = FileOpeningService.Instance.previousids.IndexOf(task.Task.Id);
     84                    index = fileopener.previousids.IndexOf(task.Task.Id);
    6485                }
    6586                else
    6687                {//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);
    7091                    test = true;//initial added task, data must be sent
    7192                }
    72                 var previous = FileOpeningService.Instance.previousLogs[index];
     93                var previous = fileopener.previousLogs[index];
    7394                if (test || previous < task.Task.StateLog.Count)
    7495                {//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;
    7697                    JsonSerializerSettings settings = new JsonSerializerSettings();
    7798                    settings.ContractResolver = new JsonTaskResolver();
     
    94115        public void restartTask(Guid id)
    95116        {
    96             ((HiveServiceLocatorWeb)(HiveServiceLocatorWeb.Instance)).getHiveServiceClient().RestartTask(id);
     117            loader();
     118            weblog.getServiceLocator(userId).getHiveServiceClient().RestartTask(id);
    97119        }
    98120    }
  • branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Hubs/ProgressHub.cs

    r13735 r13739  
    1515    public class ProgressHub : Hub
    1616    {
    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
    1834        /// <summary>
    1935        /// First message from client
     
    2238        public void HandleMessage(string receivedString)
    2339        {
    24 
     40            loader();
    2541            Clients.Caller.processMessage("Connection Established");
    26             Job = FileOpeningService.Instance.Job;
    27             Job.Progress.StatusChanged += runHub;
     42            fileopener.Job.Progress.StatusChanged += runHub;
    2843        }
    2944        /// <summary>
     
    3348        public void ChangeNameResource(string name, string resource)
    3449        {
     50            loader();
    3551            if (name != null)
    36                 FileOpeningService.Instance.Job.Job.Name = name;
     52                fileopener.Job.Job.Name = name;
    3753            if(resource != null && resource != "")
    3854            {
    39                 FileOpeningService.Instance.Job.Job.ResourceNames += "/" + resource;
     55                fileopener.Job.Job.ResourceNames += "/" + resource;
    4056            }
    4157        }
     
    4965        public void ToggleChild(int[][] arr)
    5066        {
    51             Job = FileOpeningService.Instance.Job;
    52             HiveTask current = Job.HiveTasks.ToList()[0];
     67            loader();
     68            HiveTask current = fileopener.Job.HiveTasks.ToList()[0];
    5369            if (arr.Length == 0)
    5470            {//check if upper job
     
    92108        public void ChangePriority(int[][] arr, int prior)
    93109        {
    94             Job = FileOpeningService.Instance.Job;
    95             HiveTask current = Job.HiveTasks.ToList()[0];
     110            loader();
     111            HiveTask current = fileopener.Job.HiveTasks.ToList()[0];
    96112            if (arr.Length == 0)
    97113            {//check if upper job
     
    132148        public void runHub(object sender, EventArgs e)
    133149        {
     150            loader();
    134151            int value = 0;
    135152
    136             switch (Job.Progress.Status)
     153            switch (fileopener.Job.Progress.Status)
    137154            {
    138155                case "Connecting to server...":
     
    152169                    break;
    153170                default://Tasks are uploading individually
    154                     value = (int)(50 + (40 * Job.Progress.ProgressValue));
     171                    value = (int)(50 + (40 * fileopener.Job.Progress.ProgressValue));
    155172                    break;
    156173
    157174            }
    158175            //send info to client
    159             Clients.Caller.processMessage(Job.Progress.Status, value);
     176            Clients.Caller.processMessage(fileopener.Job.Progress.Status, value);
    160177
    161178        }
Note: See TracChangeset for help on using the changeset viewer.