zhoufan лет назад: 4
Родитель
Сommit
14494c7c0a

+ 34 - 0
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/App_Start/ActionAttribute.cs

@@ -0,0 +1,34 @@
1
+using CallCenter.Utility;
2
+using System;
3
+using System.Collections.Generic;
4
+using System.Linq;
5
+using System.Web;
6
+using System.Web.Mvc;
7
+
8
+namespace CallCenterApi.Interface
9
+{
10
+    public class ActionAttribute: ActionFilterAttribute
11
+    {
12
+        public override void OnActionExecuting(ActionExecutingContext filterContext)
13
+        {
14
+            if (filterContext.Controller.ToString().ToLower() != "login")
15
+            {
16
+                try
17
+                {
18
+                    var datedue = DateTime.Parse(Configs.GetValue("datedue"));
19
+                    if (DateTime.Now > datedue)
20
+                    {
21
+                        filterContext.Result = new ContentResult() { Content = new AjaxResult { state = ResultTypes.notoken.ToString(), message = "授权过期,请联系厂家" }.ToJson() };
22
+                        return;
23
+                    }
24
+                }
25
+                catch
26
+                {
27
+                    filterContext.Result = new ContentResult() { Content = new AjaxResult { state = ResultTypes.notoken.ToString(), message = "授权过期,请联系厂家" }.ToJson() };
28
+                    return;
29
+                }
30
+            }
31
+            base.OnActionExecuting(filterContext);
32
+        }
33
+    }
34
+}

+ 1 - 0
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/App_Start/FilterConfig.cs

@@ -6,6 +6,7 @@ namespace CallCenterApi.Interface
6 6
     {
7 7
         public static void RegisterGlobalFilters(GlobalFilterCollection filters)
8 8
         {
9
+            filters.Add(new ActionAttribute());
9 10
             filters.Add(new ErrorAttribute());
10 11
         }
11 12
     }

+ 2 - 1
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/CallCenterApi.Interface.csproj

@@ -16,7 +16,7 @@
16 16
     <RootNamespace>CallCenterApi.Interface</RootNamespace>
17 17
     <AssemblyName>CallCenterApi.Interface</AssemblyName>
18 18
     <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
19
-    <UseIISExpress>false</UseIISExpress>
19
+    <UseIISExpress>true</UseIISExpress>
20 20
     <IISExpressSSLPort />
21 21
     <IISExpressAnonymousAuthentication />
22 22
     <IISExpressWindowsAuthentication />
@@ -180,6 +180,7 @@
180 180
     </Content>
181 181
   </ItemGroup>
182 182
   <ItemGroup>
183
+    <Compile Include="App_Start\ActionAttribute.cs" />
183 184
     <Compile Include="App_Start\AuthorizeAttribute.cs" />
184 185
     <Compile Include="App_Start\FilterConfig.cs" />
185 186
     <Compile Include="App_Start\ErrorAttribute.cs" />