From e691f2ecede6a962dfa76bb4a494ac1c80c9a389 Mon Sep 17 00:00:00 2001
From: yl <ykxkd@outlook.com>
Date: 星期六, 10 九月 2022 00:05:58 +0800
Subject: [PATCH] 设备点检记录导出接口去掉分页参数,设备保养记录查询、明细查询、导出(接口开发)

---
 VueWebApi/Tools/ChannelActionFilterAttribute.cs |   47 +++++++++++++++++++++++++++++------------------
 1 files changed, 29 insertions(+), 18 deletions(-)

diff --git a/VueWebApi/Tools/ChannelActionFilterAttribute.cs b/VueWebApi/Tools/ChannelActionFilterAttribute.cs
index f219bd2..2ab8df9 100644
--- a/VueWebApi/Tools/ChannelActionFilterAttribute.cs
+++ b/VueWebApi/Tools/ChannelActionFilterAttribute.cs
@@ -26,32 +26,43 @@
         /// <param name="actionContext"></param>
         public override void  OnActionExecuting(HttpActionContext actionContext)
         {
-            User loginUser = JsonConvert.DeserializeObject<User>(HttpContext.Current.Session["User"].ToString());
-            base.OnActionExecuting(actionContext);
-            //濡傛灉瀛樺湪
-            if (redis.Get<User>("LoginUserID" + loginUser.userid, 0).userid.ToString() != "")
+            try
             {
-                //鑾峰彇redis涓綋鍓嶇敤鎴蜂俊鎭�
-                User r_loginUser = redis.Get<User>("LoginUserID" + loginUser.userid, 0);
-                //濡傛灉session涓殑鐢ㄦ埛usercode鍜宺edis涓殑鐢ㄦ埛usercode鍖归厤
-                if (r_loginUser.usercode.Equals(loginUser.usercode))
+                var User = HttpContext.Current.Session["User"].ToString();
+                User loginUser = JsonConvert.DeserializeObject<User>(User);                
+                base.OnActionExecuting(actionContext);
+                //濡傛灉瀛樺湪
+                if (redis.Get<User>("LoginUserID"+loginUser.usertype + loginUser.userid, 0).userid.ToString() != "")
                 {
-                    //閲嶇疆杩囨湡鏃堕棿
-                    redis.Set<User>("LoginUserID" + loginUser.userid, loginUser, redis.secondsTimeOut, 0);
+                    //鑾峰彇redis涓綋鍓嶇敤鎴蜂俊鎭�
+                    User r_loginUser = redis.Get<User>("LoginUserID"+ loginUser.usertype + loginUser.userid, 0);
+                    //濡傛灉session涓殑鐢ㄦ埛guid鍜宺edis涓殑鐢ㄦ埛guid鍖归厤
+                    if (r_loginUser.guid.Equals(loginUser.guid))
+                    {
+                        //閲嶇疆杩囨湡鏃堕棿
+                        redis.Set<User>("LoginUserID"+ loginUser.usertype + loginUser.userid, loginUser, redis.secondsTimeOut, 0);
+                    }
+                    else
+                    {
+                        mes.code = "303";
+                        mes.Message = "鐧诲綍宸茶秴鏃�,璇烽噸鏂扮櫥褰�!";
+                        actionContext.Response = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(mes), Encoding.GetEncoding("UTF-8"), "application/json") };
+                    }
                 }
-                else
+                else //濡傛灉redis鐧诲綍鐢ㄦ埛涓笉瀛樺湪褰撳墠鐢ㄦ埛
                 {
-                    mes.code = "300";
-                    mes.Message = "璐︽埛宸茶繃鏈�,璇烽噸鏂扮櫥褰�2!";
-                    actionContext.Response = new HttpResponseMessage { StatusCode = HttpStatusCode.Ambiguous, Content = new StringContent(JsonConvert.SerializeObject(mes), Encoding.GetEncoding("UTF-8"), "application/json") };
+                    mes.code = "303";
+                    mes.Message = "鐧诲綍宸茶秴鏃�,璇烽噸鏂扮櫥褰�!";
+                    actionContext.Response = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(mes), Encoding.GetEncoding("UTF-8"), "application/json") };
                 }
             }
-            else //濡傛灉redis鐧诲綍鐢ㄦ埛涓笉瀛樺湪褰撳墠鐢ㄦ埛
+            catch (Exception)
             {
-                mes.code = "300";
-                mes.Message = "璐︽埛宸茶繃鏈�,璇烽噸鏂扮櫥褰�1!";
-                actionContext.Response = new HttpResponseMessage { StatusCode = HttpStatusCode.Ambiguous, Content = new StringContent(JsonConvert.SerializeObject(mes), Encoding.GetEncoding("UTF-8"), "application/json") };
+                mes.code = "303";
+                mes.Message = "鐧诲綍宸茶秴鏃�,璇烽噸鏂扮櫥褰�!";
+                actionContext.Response = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(mes), Encoding.GetEncoding("UTF-8"), "application/json") };
             }
+           
         }  
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3