HomeController.cs 2.15 KB
using Hh.Mes.Common.config;
using Hh.Mes.Common.Json;
using Hh.Mes.Service;
using Hh.Mes.Service.Configure;
using Hh.Mes.Service.SystemAuth;
using Microsoft.AspNetCore.Mvc;
using System;

namespace WebMvc
{
    public class HomeController : BaseController
    {
        private readonly SysCompanyService SysCompanyService;
        private readonly BaseInfoCacheService baseInfo;

        public HomeController(IAuth authUtil, SysCompanyService sysCompanyService, BaseInfoCacheService baseInfo) : base(authUtil)
        {
            this.baseInfo = baseInfo;
            SysCompanyService = sysCompanyService;
            if (_loginInfo != null) SysCompanyService.sysWebUser = _loginInfo;
        }

        /// <summary>
        /// 枚举类在Hh.Mes.POJO dll 如果命名改了需要修改ResponseEnumJosn方法
        /// </summary>
        [ResponseCache(Duration = 60)]
        public ActionResult Index()
        {
            if (_loginInfo == null) return Redirect("/Login/Index");
            ResponseEnumJosn();

            var dt = baseInfo.GetOneBaseInfo("base_equipment_type", false);
            ViewBag.equipmentType = dt.ToJson();
            ViewBag.copyright = "Copyright © " + DateTime.Now.ToString("yyyy ") + AppSettings.GetAppSeting("copyright");
            ViewBag.IsDevelopment = string.Format("let IsDevelopment={0}", ConfigRead.GetInstance.GetAppsetConnection().IsDevelopment.ToString().ToLower());
            return View();
        }

        public ActionResult Main()
        {
            return View();
        }

        public ActionResult ProjectMap()
        {
            return View();
        }


        /// <summary>
        /// 统计错误信息
        /// </summary>
        /// <returns></returns>
        public string LogTips()
        {
            SysCompanyService.sysWebUser = _loginInfo;
            var result = SysCompanyService.LogTips();
            return Serialize(result);
        }

        /// <summary>
        /// 更新清空日志提示
        /// </summary>
        [HttpGet]
        public string UpdateLogTips(string flag)
        {
            return Serialize(SysCompanyService.UpdateLogTips(flag));
        }
    }
}