using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc; namespace WebMvc
{
public class MyController : Controller
{
/// <summary>
/// Action执行前判断
/// </summary>
/// <param name="filterContext"></param>
protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
base.OnActionExecuting(filterContext);
var myAttribute = filterContext.ActionDescriptor.GetCustomAttributes(typeof(MyAttributeAttribute), false);
bool isCheckLogin = true;
bool isCheckApp = true;
bool isCheckUrl = true;
if (myAttribute.Length == )
{
MyAttributeAttribute myAttr = (MyAttributeAttribute)myAttribute[];
isCheckLogin = myAttr.CheckLogin;
isCheckApp = myAttr.CheckApp;
isCheckUrl = myAttr.CheckUrl;
}
if (isCheckUrl)
{
if (!Common.Tools.CheckReferrer(false))
{
filterContext.Result = Content("地址验证错误");
return;
}
}
if (isCheckLogin)
{
string msg;
if (!this.CheckLogin(out msg))
{
if (filterContext.HttpContext.Request.IsAjaxRequest())
{
filterContext.Result = Content("{\"loginstatus\":-1, \"url\":\"\"}");
}
else
{
string lastURL = System.Web.HttpContext.Current.Request.Url.PathAndQuery.UrlEncode();
filterContext.Result = Content(string.Concat("<script>",
msg.IsNullOrEmpty() ? "" : string.Format("alert('{0}');", msg),
string.Compare(filterContext.Controller.ToString(), "WebMvc.Controllers.HomeController", true) == ? "top.location='" + Url.Content("~/Login") + "'" : "top.lastURL='" + lastURL + "';top.currentWindow=window;top.login();", "</script>"), "text/html");
}
return;
}
}
if (isCheckApp)
{
string appMsg;
if (!Common.Tools.CheckApp(out appMsg))
{
filterContext.Result = Content("权限验证错误");
return;
}
}
} /// <summary>
/// 验证登录
/// </summary>
/// <param name="msg"></param>
/// <returns></returns>
protected virtual bool CheckLogin(out string msg)
{
return WebMvc.Common.Tools.CheckLogin(out msg);
} /// <summary>
/// 当前登录用户ID
/// </summary>
public static Guid CurrentUserID
{
get
{
return RoadFlow.Platform.Users.CurrentUserID;
}
} /// <summary>
/// 当前用户
/// </summary>
public static RoadFlow.Data.Model.Users CurrentUser
{
get
{
return RoadFlow.Platform.Users.CurrentUser;
}
} /// <summary>
/// 当前用户姓名
/// </summary>
public static string CurrentUserName
{
get
{
return RoadFlow.Platform.Users.CurrentUserName;
}
} /// <summary>
/// 当前用户部门
/// </summary>
public static RoadFlow.Data.Model.Organize CurrentUserDept
{
get
{
return RoadFlow.Platform.Users.CurrentDept;
}
} /// <summary>
/// 当前用户部门ID
/// </summary>
public static Guid CurrentUserDeptID
{
get
{
return RoadFlow.Platform.Users.CurrentDeptID;
}
} /// <summary>
/// 当前用户部门名称
/// </summary>
public static string CurrentUserDeptName
{
get
{
return RoadFlow.Platform.Users.CurrentDeptName;
}
} /// <summary>
/// 当前用户单位
/// </summary>
public static RoadFlow.Data.Model.Organize CurrentUserUnit
{
get
{
return RoadFlow.Platform.Users.CurrentUnit;
}
} /// <summary>
/// 当前用户单位ID
/// </summary>
public static Guid CurrentUserUnitID
{
get
{
return RoadFlow.Platform.Users.CurrentUnitID;
}
} /// <summary>
/// 当前用户单位名称
/// </summary>
public static string CurrentUserUnitName
{
get
{
return RoadFlow.Platform.Users.CurrentUnitName;
}
} /// <summary>
/// 当前日期时间
/// </summary>
public static DateTime CurrentDateTime
{
get
{
return RoadFlow.Utility.DateTimeNew.Now;
}
}
}
}

RoadFlow2.7.5 MyController.cs的更多相关文章

  1. ngx-admin with Asp.net Core 2.0, possibly plus OrchardCore

    1 Download ngx-admin from https://github.com/akveo/ngx-admin 2 Create a new Web Application in vs201 ...

  2. 【.NetCore学习】ubuntu16.04 搭建.net core mvc api 运行环境

    查看linux内核版本 uname -a 打印结果 python@ubuntu:~$ uname -a Linux ubuntu 4.4.0-31-generic #50-Ubuntu SMP Wed ...

  3. [C#] 剖析 AssemblyInfo.cs - 了解常用的特性 Attribute

    剖析 AssemblyInfo.cs - 了解常用的特性 Attribute [博主]反骨仔 [原文]http://www.cnblogs.com/liqingwen/p/5944391.html 序 ...

  4. Atitit 软件架构方法的进化与演进cs bs soa roa  msa  attilax总结

    Atitit 软件架构方法的进化与演进cs bs soa roa  msa  attilax总结 1.1. 软件体系架构是沿着单机到 CS 架构,再到 BS 的三层架构甚至多层架构逐步发展过来的,关于 ...

  5. 从java文件和CS文件里查询方法使用次数工具

    前几天,领导让我找一下老系统(Java)里getRemoteUser方法都哪个文件用了,package是什么,方法被调用了多少次,当时因为着急,所以,直接人工找的,但是以后要是再出现,人工找就太讨厌了 ...

  6. 关于 WP 开发中.xaml 与.xaml.cs 的关系

    今天我们先来看一下在WP8.1开发中最长见到的几个文件之间的关系.比较论证,在看这个问题之前我们简单看看.NET平台其他两个不同的框架: Windows Forms 先看看Window Forms中的 ...

  7. .net 用户控件ascx.cs注册js脚本代码无效果

    在.net web项目中碰到一个比较奇怪的问题,网上没找到解决方案,先自己mark一下 问题描述: 添加一个用户控件ascx,在后端.cs添加js注册脚本,执行后没有弹出框 注册脚本为: this.P ...

  8. DateHelper.cs日期时间操作辅助类C#

    //==================================================================== //** Copyright © classbao.com ...

  9. 仅用aspx文件实现Ajax调用后台cs程序。(实例)

    仅用aspx文件实现Ajax调用后台cs无刷新程序.(实例) 两个文件:aaa.aspx 和aaa.aspx.cs 一.aaa.aspx <script type="text/java ...

随机推荐

  1. yield列表反转 islice切片(2.6)

    yield列表反转 islice切片 列表反转 l1 = [i for i in range(10)] print(l1) print(l1[::2]) l1.reverse() # 注: pytho ...

  2. VS2010 下C++使用UTF8编码

    http://www.nubaria.com/en/blog/?p=289 #pragma execution_character_set("utf-8")

  3. Dubbo入门到精通学习笔记(十六):Keepalived+Nginx实现高可用Web负载均衡

    文章目录 Keepalived+Nginx实现高可用Web负载均衡 Keepalived+Nginx实现高可用Web负载均衡 高可用架构篇 Keepalived + Nginx 实现高可用 Web 负 ...

  4. 2.5 webpack 进阶

    配置分离 code splitting 异步加载 理解 webpack chunk webpack 调试 2.5.1 配置分离 在大型项目中,可能 webpack.config.js 会变得越来越臃肿 ...

  5. Lilo的实现

    书承上文:http://www.cnblogs.com/long123king/p/3549267.html 我们找一份Lilo的源码来看一下 http://freecode.com/projects ...

  6. 前端(二十二)—— vue组件:局部组件、全局组件、父组件数据传到子组件、子组件数据传到父组件、父子组件实现todoList

    Vue组件 一.组件介绍 每一个组件都是一个vue实例 每个组件均具有自身的模板template,根组件的模板就是挂载点,根组件也可以显式书写模板,会替换掉挂载点 每个组件模板只能拥有一个根标签 子组 ...

  7. 去除字符串中的HTML标签

    背景:Kindeditor内容保存在数据库中的类型是text,包含文字和HTML标签. 需求:显示内容的前50个字(纯文字内容) 方法:将字段查出去除标签,截取前50 import java.util ...

  8. webpack2诸类事宜

    写在最前:webpack的总结也是自己坑过,实践过但是也是针对性的使用,在加上webpack的背景,对于其‘原理’方面有很大的不正确的理解,有错误的地方,请尽情指出(乖巧~) 由于版本遇到的问题: 在 ...

  9. java.io.FileNotFoundException: [WEB-INF/spring-servlet.xml] cannot be opened because it does not exist

    今天启动web 项目出现错误提示: java.io.FileNotFoundException: [WEB-INF/spring-servlet.xml] cannot be opened becau ...

  10. @ApiImplicitParams、ApiImplicitParam的使用

    @ApiImplicitParam:作用在方法上,表示单独的请求参数 参数: 1. name :参数名. 2. value : 参数的具体意义,作用. 3. required : 参数是否必填. 4. ...