1 | using HeuristicLab.Clients.Hive.WebJobManager.ViewModels;
|
---|
2 | using Microsoft.AspNet.Hosting;
|
---|
3 | using System;
|
---|
4 | using System.Collections.Generic;
|
---|
5 | using System.Linq;
|
---|
6 | using System.Threading;
|
---|
7 | using System.Threading.Tasks;
|
---|
8 |
|
---|
9 | namespace HeuristicLab.Clients.Hive.WebJobManager.Services
|
---|
10 | {
|
---|
11 | public class FileOpeningService
|
---|
12 | {
|
---|
13 | public RefreshableJob Job { get; set; }
|
---|
14 | public FileOpeningViewModel vm { get; set; }
|
---|
15 | public IHostingEnvironment env { get; set; }
|
---|
16 | public List<Guid> previousids {
|
---|
17 | get; set; }
|
---|
18 | public List<int> previousLogs { get; set; }
|
---|
19 | private static FileOpeningService instance;
|
---|
20 | public static FileOpeningService Instance
|
---|
21 | {
|
---|
22 | get
|
---|
23 | {
|
---|
24 | if (instance == null)
|
---|
25 | {
|
---|
26 | instance = new FileOpeningService();
|
---|
27 | }
|
---|
28 | return instance;
|
---|
29 | }
|
---|
30 | }
|
---|
31 | public void NewModel()
|
---|
32 | {
|
---|
33 | vm = new FileOpeningViewModel();
|
---|
34 | Job = new RefreshableJob();
|
---|
35 | Job.Job.Name = "init";
|
---|
36 |
|
---|
37 | }
|
---|
38 | public void setTasks()
|
---|
39 | {
|
---|
40 |
|
---|
41 | Job.HiveTasks.Add(vm.SelectedTask);
|
---|
42 | }
|
---|
43 | public void refreshJob()
|
---|
44 | {
|
---|
45 | // HiveClientWeb.Instance.Refresh();
|
---|
46 | HiveClientWeb.LoadJob(Job);
|
---|
47 | }
|
---|
48 |
|
---|
49 | public RefreshableJob AddCurrentModelToHive()
|
---|
50 | {
|
---|
51 | if (vm != null)
|
---|
52 | {
|
---|
53 |
|
---|
54 |
|
---|
55 |
|
---|
56 | HiveServiceLocatorWebManagerService serv = (HiveServiceLocatorWebManagerService)HiveServiceLocatorWebManagerService.Instance;
|
---|
57 | //job.Job.Id = serv.getHiveServiceClient().AddJob(job.Job);
|
---|
58 | // job.Job = serv.getHiveServiceClient().GetJob(job.Job.Id);
|
---|
59 |
|
---|
60 | HiveClientWeb.CurrentEnv = env;
|
---|
61 | HiveClientWeb.Instance.Refresh();
|
---|
62 | HiveClientWeb.StartJob((ex) => { throw ex; }, Job, CancellationToken.None);
|
---|
63 | return Job;
|
---|
64 | }
|
---|
65 | return null;
|
---|
66 | }
|
---|
67 | }
|
---|
68 | }
|
---|