SheQu/Filters/AdminAttribute.cs
(开头部分) 11KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using SheQu.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace SheQu
{
public class AdminAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
try
{
string Controller = filterContext.RouteData.Values["controller"].ToString().Trim();//控制器
string Action = filterContext.RouteData.Values["action"].ToString().Trim();//方法
//获取ID 有ID为修改,没有为添加
string id = filterContext.RouteData.Values["id"] == null ? "" : filterContext.RouteData.Values["id"].ToString().Trim();
string cons = "Home,Lookup,";//直接跳过的控制器
if (cons.Contains(Controller + ","))
{
// string url3 = HttpContext.Current.Request.Url.Authority;
if (Controller == "Home" && Action == "Index")
{
//Session 过期 登陆超时!
if (CurrentUser.logininfor.Id == 0)
{
filterContext.Result = new RedirectResult("/Home/Login");
base.OnActionExecuting(filterContext);
}
else
{
FatherDAL<Logs>.Add(new Logs { Texts = "【Date:"+DateTime.Now+" (" + CurrentUser.logininfor.Type_Id + ") - " + CurrentUser.logininfor.AdminName + " -" + CurrentUser.logininfor.Id + "-】- 登陆 " });
//Note_Gym.NoteAdd(new NoteManager
//{
// UserId = CurrentUser.logininfor.Id,
// Content = "【(" + CurrentUser.logininfor.DroitManager.Name + ") - " + CurrentUser.logininfor.Name + " -" + CurrentUser.logininfor.Id + "-】- 登陆 ",//IP:" + GetLoginIp(filterContext),
// Time = DateTime.Now
//});
}
}
}
else
{
//Session 过期 登陆超时!
if (CurrentUser.logininfor.Id == 0)
{
// filterContext.Result = new RedirectResult("/Home/Login");
MessageResult m = new MessageResult();
m.message = "登陆超时!请重新登陆";
m.statusCode = "301";
filterContext.Result = m;
后面还有 229 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读 AI
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
