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. Android中的Service 与 Thread 的区别

    很多时候,你可能会问,为什么要用 Service,而不用 Thread 呢,因为用 Thread 是很方便的,比起 Service 也方便多了,下面我详细的来解释一下. 1). Thread:Thre ...

  2. JSON.NET与LINQ序列化示例教程

    1.手动创建JSON对象和数组 JSON格式主要包括对象和数组两种形式,在JSON.NET中分别用JArray和JObject表示,属性用JProperty表示,属性值用 JValue表示,这些对象都 ...

  3. SQLServer如何手动设置id值(主键)的自动增长

    近期做东西,用到了对SQLServer数据库的操作.好吧,确实好久没看了,对这个数据库陌生到了极点,连最简单的如何设置一个id主键,让它随着插入数据的增多,自动增长id值的设置都忘记了,网上查了一下, ...

  4. msgbox用法

    http://www.w3school.com.cn/vbscript/func_msgbox.asp VBScript MsgBox 函数 VBScript 函数参考手册 定义和用法 MsgBox ...

  5. Codeforces 1189B Number Circle

    题目链接:http://codeforces.com/problemset/problem/1189/B AC代码: #include<bits/stdc++.h> using names ...

  6. Ubuntu12.04开机自动挂载windows分区

    最近使用Ubuntu12.04时不知到怎么搞的原本能自动识别的Windows的C .D .E盘突然间无法识别了,于是上网搜了一下Ubuntu12.04下自动挂载Windows NTFS分区的方法. 还 ...

  7. 10 个优秀的JavaScript开发框架

    阅读目录 TouchStone.js Meteor Knockout Enyo.js Reactive-coffee ExtJS Aurajs Cappuccino canjs Feathersjs ...

  8. JUC源码分析-集合篇:并发类容器介绍

    JUC源码分析-集合篇:并发类容器介绍 同步类容器是 线程安全 的,如 Vector.HashTable 等容器的同步功能都是由 Collections.synchronizedMap 等工厂方法去创 ...

  9. 二、springcloud微服务测试环境搭建

    版本说明: springcloud:Greenwich.SR3 springboot:2.1.8 1.构建步骤 1.1.microservicecloud整体父工程Project 新建父工程micro ...

  10. 判断页面是否在iframe中,

    //判断页面是否在iframe中,是的话就跳出iframe框,多用于登录页  ,将此段代码放到要做判断的页面上即可 if (window != top) { top.location.href = l ...