From 9d1660270272180cd71147d6ddd53d1382643d2e Mon Sep 17 00:00:00 2001
From: wenxiangchao <wenxiangchao@ihengxin.com.cn>
Date: 星期一, 02 十一月 2026 18:00:14 +0800
Subject: [PATCH] merge: 并入远程 Initial commit 作为历史根节点
---
Plugin.TestResult/Lixun/SNValidator.cs | 91 +++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 91 insertions(+), 0 deletions(-)
diff --git a/Plugin.TestResult/Lixun/SNValidator.cs b/Plugin.TestResult/Lixun/SNValidator.cs
new file mode 100644
index 0000000..353b322
--- /dev/null
+++ b/Plugin.TestResult/Lixun/SNValidator.cs
@@ -0,0 +1,91 @@
+锘縰sing HMI.Core.Manager;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Plugin.TestResult.Lixun
+{
+ public class SNValidator
+ {
+ public static bool ValidateSN(string model, string sn, out string msg)
+ {
+ msg = string.Empty;
+ string validate = string.Empty;
+ try
+ {
+ validate = ProductManager.GetParameterByProductAndName(model, "SNRValidate")?.Value;
+ if (string.IsNullOrEmpty(validate))
+ {
+ msg = $"褰撳墠鍨嬪彿[{model}]鏈厤缃甋NRValidate鍙傛暟锛屾棤娉曟牎楠孲N鍚堟硶鎬�";
+ return true;
+ }
+ string[] arr = validate.Split(';');
+ if (arr.Length == 1)
+ {
+ if (!sn.Contains(arr[0]))
+ {
+ msg = $"鏉$爜涓嶅寘鍚浐瀹氱爜[{arr[0]}]";
+ return false;
+ }
+ return true;
+ }
+
+ if (arr.Length == 2)
+ {
+ int length = int.Parse(arr[1]);
+ if (!sn.Contains(arr[0]))
+ {
+ msg = $"鏉$爜涓嶅寘鍚浐瀹氱爜[{arr[0]}]";
+ return false;
+ }
+ if (sn.Length != length)
+ {
+ msg = $"鏉$爜闀垮害搴斾负[{length}]";
+ return false;
+ }
+ return true;
+ }
+
+ if (arr.Length >= 3)
+ {
+ int length = int.Parse(arr[1]);
+ int startIndex = int.Parse(arr[2]);
+
+ if (sn.Length != length)
+ {
+ msg = $"鏉$爜闀垮害搴斾负[{length}]";
+ return false;
+ }
+
+ if (startIndex >= sn.Length)
+ {
+ msg = $"鏉$爜闀胯灏忎簬璧峰涓嬫爣[{validate}]";
+ return false;
+ }
+
+ if (arr[0].Length > sn.Length)
+ {
+ msg = $"鏉$爜闀胯灏忎簬鍥哄畾鐮侀暱搴{validate}]";
+ return false;
+ }
+
+ if (sn.Substring(startIndex, arr[0].Length) != arr[0])
+ {
+ msg = $"鍥哄畾鐮佹鏌ュけ璐ワ細 [{validate}]";
+ return false;
+ }
+ return true;
+ }
+ msg = $"褰撳墠鍨嬪彿[{model}]閰嶇疆鍙傛暟[{validate}]瑙f瀽澶辫触";
+ return false;
+ }
+ catch (Exception ex)
+ {
+ msg = $"褰撳墠鍨嬪彿[{model}]閰嶇疆鍙傛暟[{validate}]瑙f瀽澶辫触";
+ return false;
+ }
+ }
+ }
+}
--
Gitblit v1.9.1