From ab9ea4594384b9a25e43bdf991dc5b1c9471e5aa Mon Sep 17 00:00:00 2001
From: schangxiang@126.com <schangxiang@126.com>
Date: 周五, 04 4月 2025 15:37:18 +0800
Subject: [PATCH] 认为是验证成功,不要并发导致读取授权文件失败 去掉

---
 Api/Util/AuthorizeHelper.cs |   30 ++++++++++++++++++++++--------
 1 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/Api/Util/AuthorizeHelper.cs b/Api/Util/AuthorizeHelper.cs
index 631cf72..b59e150 100644
--- a/Api/Util/AuthorizeHelper.cs
+++ b/Api/Util/AuthorizeHelper.cs
@@ -1,4 +1,5 @@
 锘縰sing iWare.Authorize.Dto;
+using Newtonsoft.Json;
 using ProjectCode;
 
 namespace iWare.Authorize
@@ -33,12 +34,13 @@
                 string rst = EnDecode.ReadAndValidateLicenseFile(firstFile.FullName);
                 if (!string.IsNullOrEmpty(rst))
                 {
+                    AuthorizeFunRetEntity newRet = JsonConvert.DeserializeObject<AuthorizeFunRetEntity>(rst);
                     if (EnDecode.ValidatePermanentLicense(firstFile.FullName))
                     {
-                        return AuthorizeFunRetEntity.Success("鎴愬姛");
+                        return AuthorizeFunRetEntity.Success("鎴愬姛", newRet);
                     }
                     else
-                        return ValidateLicenseForDev(firstFile.FullName, input);
+                        return ValidateLicenseForDev(firstFile.FullName, input, newRet);
                 }
                 else
                 {
@@ -57,8 +59,14 @@
         /// </summary>
         /// <param name="filePath"></param>
         /// <returns></returns>
-        private static AuthorizeFunRetEntity ValidateLicenseForDev(string filePath, ValidateLicenseInput input)
+        private static AuthorizeFunRetEntity ValidateLicenseForDev(string filePath, ValidateLicenseInput input, AuthorizeFunRetEntity newRet)
         {
+            var str_expiryDate = "";
+            if (!string.IsNullOrEmpty(newRet.expiryDate))
+            {
+                str_expiryDate = Convert.ToDateTime(newRet.expiryDate).ToString("yyyy-MM-dd HH:mm:ss");
+            }
+
             //璇诲彇 寮�鍙戞巿鏉�
             var val = EnDecode.ValidateDevLicense(filePath);
             if (val.IsValid)
@@ -66,16 +74,22 @@
                 if (input != null && input.WaringDays != null)
                 {
                     int waringDays = (int)input.WaringDays;
-                    if (waringDays >= val.RemainingDays)
+                    double _my_RemainingDays = Convert.ToDouble(val.RemainingDays.ToString("0.0"));
+                    if (waringDays >= _my_RemainingDays)
                     {
-                        return AuthorizeFunRetEntity.Success("鎴愬姛", val.RemainingDays, $"鎺堟潈鍓╀綑澶╂暟{val.RemainingDays}灏忎簬{waringDays}澶�");
+                        return AuthorizeFunRetEntity.Success("鎴愬姛", val.RemainingDays, $"鎺堟潈鍓╀綑澶╂暟{_my_RemainingDays}灏忎簬{waringDays}澶�,鍒版湡鏃{str_expiryDate}]");
                     }
                 }
-                return AuthorizeFunRetEntity.Success("鎴愬姛", val.RemainingDays);
+                return AuthorizeFunRetEntity.Success("鎴愬姛", val.RemainingDays, newRet);
             }
             else
-                return AuthorizeFunRetEntity.Fail("鎺堟潈澶辫触", val.RemainingDays);
-
+            {
+                if (string.IsNullOrEmpty(newRet.expiryDate))
+                {
+                    return AuthorizeFunRetEntity.Fail($"鎺堟潈澶辫触", val.RemainingDays, newRet);
+                }
+                return AuthorizeFunRetEntity.Fail($"鎺堟潈澶辫触,鍒版湡鏃{str_expiryDate}]", val.RemainingDays, newRet);
+            }
         }
 
     }

--
Gitblit v1.9.3