using System; using System.Web.Mvc; using Services.Cache; using Services.Manager; using UI.Controllers; using System.Linq; using Services.Extensions; using Newtonsoft.Json; using Services.Tool; using Models.ModelItems; using Models; using UH_CENTER; public class HomeController : BaseController { public HomeController() { base.ViewBag.Select = 0; } #region 用户信息 public ActionResult Index() { try { return View(); } catch (Exception ex) { LogHelp.WriteExceptionLog(ex); HttpContext.Response.StatusCode = 500; return null; } } #endregion #region 用户权限管理 public ActionResult UAuthority(string id) { try { ViewBag.Appversions = CacheHelp.cacheAppversions; //用户权限 var info = CacheHelp.cacheSysUserInfo.FirstOrDefault(x => x.Uid.TrimEnd().ToLower() == id.TrimEnd().ToLower()); if (info == null) throw new CustomException("无用户,非法访问~"); ViewBag.info = info; ViewBag.HotelList = JsonConvert.SerializeObject( UH_CENTER_Help.Sel_Hotel(info).Select(X=>X.id) ); return View(); } catch (Exception ex) { LogHelp.WriteExceptionLog(ex); HttpContext.Response.StatusCode = 500; return null; } } #endregion #region 添加用户 public ActionResult AddUser() { try { ViewBag.publicYS = (Session["ras"] as Services.Tool.RSA).ToPEM().ToPEM_PKCS8(convertToPublic: true).Replace("\r\n", "") .Replace(Convert.ToChar(10).ToString(), "") .Replace(Convert.ToChar(13).ToString(), "") ?? throw new Exception(); return View(); } catch (Exception ex) { LogHelp.WriteExceptionLog(ex); return Content(ex.Message); } } #endregion #region 修改用户 public ActionResult EditUser(int id) { try { var userinfo = CacheHelp.cacheSysUserInfo.FirstOrDefault(x => x.Id == id); if (userinfo == null || (Umodel.IsValid <= userinfo.IsValid && Umodel.Id != 1 && Umodel.Uid != userinfo.Uid)) throw new CustomException("无权访问!"); ViewBag.Uinfo = userinfo; RSA rSA = new RSA(512); base.Session["ras"] = rSA; ViewBag.publicYS = (Session["ras"] as Services.Tool.RSA).ToPEM().ToPEM_PKCS8(convertToPublic: true).Replace("\r\n", "") .Replace(Convert. ToChar(10).ToString(), "") .Replace(Convert.ToChar(13).ToString(), "") ?? throw new Exception(); return View(); } catch (Exception ex) { LogHelp.WriteExceptionLog(ex); HttpContext.Response.StatusCode = 500; return null; } } #endregion public ActionResult IndexInfo(string Token = "") { if (!string.IsNullOrEmpty(Token)) { string Ip = IPHelper.GetIP(); var userinfo = RedisHelper.StringGet(Token + Ip); RedisHelper.RemoveKey(Token + Ip); } base.ViewBag.Select = -1; base.ViewBag.LogData = SqlSugarBase.Db.Ado.SqlQuery("SELECT * FROM DbLog ORDER BY ID DESC limit 1, 50").ToList(); //CacheHelp.Removesys(CacheHelp.syskey.sysDbLogListKey); //ViewBag.LogData = //CacheHelp.cacheDbLogs.OrderByDescending(x => x.Id).Take(50).ToList(); return View(); } }