You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
107 lines
2.7 KiB
107 lines
2.7 KiB
using Infrastructure.Data;
|
|
using Infrastructure.Extensions;
|
|
using Infrastructure.Web;
|
|
using IoT.Shared.Application.Domain.Entities;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Platform.ViewModels;
|
|
using System.Linq;
|
|
|
|
namespace Platform.Controllers
|
|
{
|
|
[Authorize]
|
|
//[Device]
|
|
[ApiExplorerSettings(IgnoreApi = true)]
|
|
public class HomeController : BaseController
|
|
{
|
|
private readonly IUserService _useService;
|
|
private readonly IRepository<User> _userRepo;
|
|
private readonly IRepository<Organ> _organRepo;
|
|
private readonly IRepository<Building> _buildingRepo;
|
|
|
|
public HomeController(IUserService userService, IRepository<User> userRepo, IRepository<Organ> organRepo, IRepository<Building> buildingRepo)
|
|
{
|
|
this._useService = userService;
|
|
this._userRepo = userRepo;
|
|
this._organRepo = organRepo;
|
|
this._buildingRepo = buildingRepo;
|
|
}
|
|
|
|
public IActionResult Index()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
public IActionResult Product()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
public IActionResult Device()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
public IActionResult Organ()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
public IActionResult Nodes()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
public IActionResult Node()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
public string Mac(string id)
|
|
{
|
|
return Helper.Instance.MacEncrypt(id);
|
|
}
|
|
|
|
public IActionResult Index2(HomeModel model)
|
|
{
|
|
var currentOrganNumber = User.GetUserData();
|
|
var organ = this._organRepo.ReadOnlyTable()
|
|
.FirstOrDefault(o => o.Number == currentOrganNumber);
|
|
|
|
var children = this._organRepo.Table()
|
|
.Where(o => o.Left >= organ.Left && o.Right <= organ.Right)
|
|
.Include(o => o.Buildings)
|
|
.ToList();
|
|
var root = children.FirstOrDefault(o => o.Number == currentOrganNumber);
|
|
|
|
model.Organ = root;
|
|
if (string.IsNullOrEmpty(model.OrganNumber))
|
|
{
|
|
model.OrganNumber = root.Number;
|
|
}
|
|
return View(model);
|
|
}
|
|
|
|
public IActionResult Index3()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
public IActionResult Index4()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
private object Convert(Organ root)
|
|
{
|
|
return new
|
|
{
|
|
title = root.Name,
|
|
key = root.Number,
|
|
children = root.Children.Select(o => Convert(o))
|
|
};
|
|
}
|
|
}
|
|
}
|