1 | using HeuristicLab.Clients.Hive.WebJobManager.Services;
|
---|
2 | using Microsoft.AspNet.Hosting;
|
---|
3 | using Microsoft.AspNet.Http;
|
---|
4 | using Microsoft.AspNet.Mvc;
|
---|
5 | using System;
|
---|
6 | using System.Collections.Generic;
|
---|
7 | using System.Linq;
|
---|
8 | using System.ServiceModel.Security;
|
---|
9 | using System.Threading.Tasks;
|
---|
10 |
|
---|
11 | namespace HeuristicLab.Clients.Hive.WebJobManager.Controllers
|
---|
12 | {
|
---|
13 | public class ResourceController : Controller
|
---|
14 | {
|
---|
15 | private WebLoginService weblog;
|
---|
16 | private HiveServiceLocatorWeb serviceLocator;
|
---|
17 | private HiveServiceClient serviceClient;
|
---|
18 | private HiveClientWeb clientWeb;
|
---|
19 | private Guid userId;
|
---|
20 |
|
---|
21 | private IHostingEnvironment _environment;
|
---|
22 |
|
---|
23 | public ResourceController(IHostingEnvironment env)
|
---|
24 | {
|
---|
25 | weblog = WebLoginService.Instance;
|
---|
26 | var u = HttpContext.Session.GetString("UserId");
|
---|
27 | if (u == null || u == "" || Guid.Parse(u) == Guid.Empty)
|
---|
28 | {
|
---|
29 | userId = Guid.Empty;
|
---|
30 | serviceLocator = new HiveServiceLocatorWeb();
|
---|
31 | serviceClient = serviceLocator.getHiveServiceClient();
|
---|
32 | clientWeb = new HiveClientWeb(serviceLocator, userId);
|
---|
33 | }
|
---|
34 | else {
|
---|
35 | userId = Guid.Parse(u);
|
---|
36 |
|
---|
37 | serviceLocator = weblog.getServiceLocator(userId);
|
---|
38 | serviceClient = serviceLocator.getHiveServiceClient();
|
---|
39 | clientWeb = weblog.getClientWeb(userId);
|
---|
40 | }
|
---|
41 |
|
---|
42 | _environment = env;
|
---|
43 | }
|
---|
44 | public IActionResult Index()
|
---|
45 | {
|
---|
46 | if (serviceLocator.CheckLogin())
|
---|
47 | {
|
---|
48 |
|
---|
49 | ViewBag.Title = "Resources";
|
---|
50 | return View("Index");
|
---|
51 | }
|
---|
52 | else
|
---|
53 | {
|
---|
54 | return RedirectToAction("Index", "Home");
|
---|
55 | }
|
---|
56 | }
|
---|
57 | }
|
---|
58 | }
|
---|