using HeuristicLab.Clients.Access.Administration; using HeuristicLab.Clients.Hive.WebJobManager.Services; using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Http; using Microsoft.AspNet.Mvc; using System; using System.Collections.Generic; using System.Linq; using System.ServiceModel.Security; using System.Threading.Tasks; namespace HeuristicLab.Clients.Hive.WebJobManager.Controllers { public class ResourceController : Controller { private WebLoginService weblog; private HiveServiceLocatorWeb serviceLocator; private AccessAdministrationClient accessClient; private Guid userId; private IHostingEnvironment _environment; public ResourceController(IHostingEnvironment env) { weblog = WebLoginService.Instance; _environment = env; } private bool init() { var u = HttpContext.Session.GetString("UserId"); if (u == null || u == "" || Guid.Parse(u) == Guid.Empty) { return false; } else { userId = Guid.Parse(u); serviceLocator = weblog.getServiceLocator(userId); accessClient = weblog.getAccessAdminClient(userId); return serviceLocator.CheckLogin(); } } public IActionResult Index() { if (init()) { ViewBag.SessionId = HttpContext.Session.GetString("UserId"); ViewBag.Title = "Resources"; return View("Index"); } else { return RedirectToAction("Index", "Home"); } } } }