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. 【NOI2019模拟2019.6.29】组合数(Lucas定理、数位dp)

    Description: p<=10且p是质数,n<=7,l,r<=1e18 题解: Lucas定理: \(C_{n}^m=C_{n~mod~p}^{m~mod~p}*C_{n/p} ...

  2. 如何基于 Nacos 和 Sentinel ,实现灰度路由和流量防护一体化

    基于Alibaba Nacos和Sentinel,实现灰度路由和流量防护一体化的解决方案,发布在最新的 Nepxion Discovery 5.4.0 版,具体参考: 源码主页,请访问 源码主页指南主 ...

  3. js手机滚屏效果

    原文地址:https://github.com/yanhaijing/zepto.fullpage 第一步:基于移动端的浏览体验,在头部添加浏览器渲染的分辨率 <meta name=" ...

  4. Service7

    在真机上,利用clone-vm7新建一台虚拟机,名字:PXE-Server     1.设置防火墙为trusted   2.当前及永久关闭SELinux   3.配置IP地址:192.168.4.16 ...

  5. 记录一次项目中dubbo-admin实战部署

    环境: 1.centos7 2.jdk-7u76-linux-x64.tar.gz 2.tomcat:apache-tomcat-7.0.59.tar.gz 3.zookeeper-3.4.6.tar ...

  6. phpstorm使用说明

    1.phpstorm软件可以直接断点调试php代码.具体配置方法参考 http://blog.csdn.net/qq4551091/article/details/55258664 就可以了,不过只要 ...

  7. centos7下命令行配置nginx

    本教程中的步骤要求用户拥有root权限 第一步 - 添加Nginx存储库要添加CentOS 7 EPEL仓库,请打开终端并使用以下命令: sudo yum install epel-release第二 ...

  8. ICPC Asia Nanning 2017 F. The Chosen One (高精度运算)

    题目链接:The Chosen One 比赛链接:ICPC Asia Nanning 2017 题意 \(t\) 组样例,每组给出一个整数 \(n(2\le n\le 10^{50})\),求不大于 ...

  9. Java8 时间调节器

    TemporalAdjuster 是做日期数学计算.例如,要获得“本月第二个星期六”或“下周二”. 让我们来看看他们的操作. 选择使用任何编辑器创建以下java程序在 C:/> JAVA Jav ...

  10. centos7下利用nfs搭建wordpress

    拓扑环境 web1 192.168.198.110 web2 192.168.198.120 mysql 192.168.198.130 DNS 192.168.198.10 NFS 192.168. ...