From 9c634fd767aec36ef97c3a814bf7a29c67d20ee1 Mon Sep 17 00:00:00 2001
From: yl <ykxkd@outlook.com>
Date: 星期五, 29 三月 2024 10:57:35 +0800
Subject: [PATCH] 修改单据重复显示问题,增加工单源单id关联

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

diff --git a/VueWebApi/Tools/ChannelActionFilterAttribute.cs b/VueWebApi/Tools/ChannelActionFilterAttribute.cs
index fa4b7e5..04dca50 100644
--- a/VueWebApi/Tools/ChannelActionFilterAttribute.cs
+++ b/VueWebApi/Tools/ChannelActionFilterAttribute.cs
@@ -24,45 +24,47 @@
         /// 璇锋眰鎺ュ彛涔嬪墠娓犻亾杩囨护
         /// </summary>
         /// <param name="actionContext"></param>
-        public override void  OnActionExecuting(HttpActionContext actionContext)
+        public override void OnActionExecuting(HttpActionContext actionContext)
         {
             try
             {
-                var User = HttpContext.Current.Session["User"].ToString();
-                User loginUser = JsonConvert.DeserializeObject<User>(User);
+                var rediskey = HttpContext.Current.Request.Cookies["rediskey"].Value.ToString();
+                var guid = HttpContext.Current.Request.Cookies["guid"].Value.ToString();
+                //var rediskey = HttpContext.Current.Request.Headers["rediskey"].ToString();
+                //var guid = HttpContext.Current.Request.Headers["guid"].ToString();
                 base.OnActionExecuting(actionContext);
                 //濡傛灉瀛樺湪
-                if (redis.Get<User>("LoginUserID" + loginUser.userid, 0).userid.ToString() != "")
+                if (redis.Get<User>(rediskey, 0).userid.ToString() != "")
                 {
                     //鑾峰彇redis涓綋鍓嶇敤鎴蜂俊鎭�
-                    User r_loginUser = redis.Get<User>("LoginUserID" + loginUser.userid, 0);
-                    //濡傛灉session涓殑鐢ㄦ埛usercode鍜宺edis涓殑鐢ㄦ埛usercode鍖归厤
-                    if (r_loginUser.usercode.Equals(loginUser.usercode))
+                    User r_loginUser = redis.Get<User>(rediskey, 0);
+                    //濡傛灉session涓殑鐢ㄦ埛guid鍜宺edis涓殑鐢ㄦ埛guid鍖归厤
+                    if (r_loginUser.guid.Equals(guid))
                     {
                         //閲嶇疆杩囨湡鏃堕棿
-                        redis.Set<User>("LoginUserID" + loginUser.userid, loginUser, redis.secondsTimeOut, 0);
+                        redis.KeyExpire(rediskey, redis.secondsTimeOut);
                     }
                     else
                     {
-                        mes.code = "300";
+                        mes.code = "303";
                         mes.Message = "鐧诲綍宸茶秴鏃�,璇烽噸鏂扮櫥褰�!";
-                        actionContext.Response = new HttpResponseMessage { StatusCode = HttpStatusCode.Ambiguous, Content = new StringContent(JsonConvert.SerializeObject(mes), Encoding.GetEncoding("UTF-8"), "application/json") };
+                        actionContext.Response = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(mes), Encoding.GetEncoding("UTF-8"), "application/json") };
                     }
                 }
                 else //濡傛灉redis鐧诲綍鐢ㄦ埛涓笉瀛樺湪褰撳墠鐢ㄦ埛
                 {
-                    mes.code = "300";
+                    mes.code = "303";
                     mes.Message = "鐧诲綍宸茶秴鏃�,璇烽噸鏂扮櫥褰�!";
-                    actionContext.Response = new HttpResponseMessage { StatusCode = HttpStatusCode.Ambiguous, Content = new StringContent(JsonConvert.SerializeObject(mes), Encoding.GetEncoding("UTF-8"), "application/json") };
+                    actionContext.Response = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(mes), Encoding.GetEncoding("UTF-8"), "application/json") };
                 }
             }
             catch (Exception)
             {
-                mes.code = "300";
+                mes.code = "303";
                 mes.Message = "鐧诲綍宸茶秴鏃�,璇烽噸鏂扮櫥褰�!";
-                actionContext.Response = new HttpResponseMessage { StatusCode = HttpStatusCode.Ambiguous, Content = new StringContent(JsonConvert.SerializeObject(mes), Encoding.GetEncoding("UTF-8"), "application/json") };
+                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