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 作为历史根节点

---
 SimpleUtil/HMI.Simple.Util/SerialDataHelper.cs |  117 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 117 insertions(+), 0 deletions(-)

diff --git a/SimpleUtil/HMI.Simple.Util/SerialDataHelper.cs b/SimpleUtil/HMI.Simple.Util/SerialDataHelper.cs
new file mode 100644
index 0000000..569445f
--- /dev/null
+++ b/SimpleUtil/HMI.Simple.Util/SerialDataHelper.cs
@@ -0,0 +1,117 @@
+锘縰sing System;
+using System.Data;
+using System.IO;
+
+namespace HMI.Simple.Util
+{
+    public class SerialDataHelper
+    {
+        public static bool GetFailCountBySNR(string snr, out int count, out string msg)
+        {
+            count = -1;
+            msg = string.Empty;
+            SqliteHelper sqliteHelper = null;
+            try
+            {
+                string dataLogPath = "";
+                var value = ParameterUtil.GetCommonParameterValue("TS_DataLogPath", out msg);
+                if (!string.IsNullOrEmpty(msg))
+                {
+                    string appFolder = RegUtil.GetLocaltion();
+                    dataLogPath = Path.Combine(appFolder, "Config", "DataBoard", "DataLog.db");
+                }
+                if (!File.Exists(dataLogPath))
+                {
+                    msg = "鏁版嵁搴撴枃浠朵笉瀛樺湪";
+                    return false;
+                }
+                sqliteHelper = new SqliteHelper(dataLogPath);
+
+                var sql = $@"SELECT COUNT(*) as num FROM testResult WHERE sn = '{snr}' AND result = 'Failed';";
+                DataTable dt = sqliteHelper.GetDataTable(sql);
+                if (dt.Rows.Count <= 0)
+                {
+                    count = 0;
+                    return true;
+                }
+                count = int.Parse(dt.Rows[0]["num"].ToString());
+                return true;
+            }
+            catch (Exception ex)
+            {
+                msg = ex.Message;
+                return false;
+            }
+            finally
+            {
+                sqliteHelper?.Dispose();
+            }
+        }
+
+        public static bool GetCountBySNRAndPosition(string snr, string position,
+            out int okCount,
+            out int ngCount,
+            out string status,
+            out string msg)
+        {
+            okCount = -1;
+            ngCount = -1;
+            status = string.Empty;
+            msg = string.Empty;
+            SqliteHelper sqliteHelper = null;
+            try
+            {
+                string dataLogPath = "";
+                var value = ParameterUtil.GetCommonParameterValue("TS_DataLogPath", out msg);
+                if (!string.IsNullOrEmpty(msg))
+                {
+                    string appFolder = RegUtil.GetLocaltion();
+                    dataLogPath = Path.Combine(appFolder, "Config", "DataBoard", "DataLog.db");
+                }
+                if (!File.Exists(dataLogPath))
+                {
+                    msg = "鏁版嵁搴撴枃浠朵笉瀛樺湪";
+                    return false;
+                }
+                sqliteHelper = new SqliteHelper(dataLogPath);
+
+                var sql = $@"SELECT COUNT(*) as num FROM testResult WHERE sn = '{snr}' AND position = '{position}' AND result = 'Failed';";
+                DataTable dt = sqliteHelper.GetDataTable(sql);
+                if (dt.Rows.Count <= 0)
+                {
+                    ngCount = 0;
+                    return true;
+                }
+                ngCount = int.Parse(dt.Rows[0]["num"].ToString());
+
+                sql = $@"SELECT COUNT(*) as num FROM testResult WHERE sn = '{snr}' AND position = '{position}' AND result = 'Passed';";
+                dt = sqliteHelper.GetDataTable(sql);
+                if (dt.Rows.Count <= 0)
+                {
+                    okCount = 0;
+                    return true;
+                }
+                okCount = int.Parse(dt.Rows[0]["num"].ToString());
+
+                sql = $@"SELECT status as status FROM testResult WHERE sn = '{snr}' ORDER BY time DESC LIMIT 0,1;";
+                dt = sqliteHelper.GetDataTable(sql);
+                if (dt.Rows.Count <= 0)
+                {
+                    status = string.Empty;
+                    return true;
+                }
+                status = dt.Rows[0]["status"] == DBNull.Value ? string.Empty : dt.Rows[0]["status"].ToString();
+                return true;
+            }
+            catch (Exception ex)
+            {
+                msg = ex.Message;
+                return false;
+            }
+            finally
+            {
+                sqliteHelper?.Dispose();
+            }
+        }
+    }
+}

--
Gitblit v1.9.1