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

---
 HMI.Core/Manager/ProductManager.cs |   82 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 82 insertions(+), 0 deletions(-)

diff --git a/HMI.Core/Manager/ProductManager.cs b/HMI.Core/Manager/ProductManager.cs
new file mode 100644
index 0000000..96e10d6
--- /dev/null
+++ b/HMI.Core/Manager/ProductManager.cs
@@ -0,0 +1,82 @@
+锘縰sing HMI.Core.Entity;
+using HMI.Core.Setting;
+using HMI.Core.Util;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+
+namespace HMI.Core.Manager
+{
+    /// <summary>
+    /// TODO 浼樺寲鏁版嵁婧愶紝闇�瑕佹敮鎸乻qlite鍜寈ml
+    /// </summary>
+    public class ProductManager
+    {
+        public static string GetFolder()
+        {
+            if (ParamSetting.ShareConfig != null)
+            {
+                return Path.Combine(ParamSetting.ShareConfig, "Product");
+            }
+            return Path.Combine(PathHelper.ConfigFolder, "Product");
+        }
+
+        public static string GetDataFilePath()
+        {
+            return Path.Combine(GetFolder(), "Product.data");
+        }
+
+        public static string GetParamFolderByProductName(string productName)
+        {
+            return Path.Combine(GetFolder(), "Parameter", $"Parameter_{productName}.data");
+        }
+
+        /// <summary>
+        /// 鑾峰彇淇濆瓨鐨勪骇鍝�
+        /// </summary>
+        /// <returns></returns>
+        public static T GetProducts<T>() where T : IList<ProductData>
+        {
+            string path = GetDataFilePath();
+            if (!File.Exists(path)) return default(T);
+            T datas = XmlHelper.DeserializeFromXml<T>(path);
+            return datas;
+        }
+
+        /// <summary>
+        /// 鑾峰彇淇濆瓨鐨勪骇鍝�
+        /// </summary>
+        /// <returns></returns>
+        public static T GetParametersByProductName<T>(string productName) where T : IList<ParameterData>
+        {
+            string path = GetParamFolderByProductName(productName);
+            if (!File.Exists(path)) return default(T);
+            T datas = XmlHelper.DeserializeFromXml<T>(path);
+            return datas;
+        }
+
+
+        public static List<ProductData> GetProducts()
+        {
+            List<ProductData> datas = GetProducts<List<ProductData>>();
+            return datas ?? new List<ProductData>();
+        }
+
+        /// <summary>
+        /// 鏍规嵁浜у搧鍚嶇О鑾峰彇浜у搧鍙傛暟
+        /// </summary>
+        /// <param name="productName"></param>
+        /// <returns></returns>
+        public static List<ParameterData> GetParametersByProductName(string productName)
+        {
+            List<ParameterData> datas = GetParametersByProductName<List<ParameterData>>(productName);
+            return datas ?? new List<ParameterData>();
+        }
+
+        public static ParameterData GetParameterByProductAndName(string product, string name)
+        {
+            List<ParameterData> datas = GetParametersByProductName<List<ParameterData>>(product);
+            return datas?.FirstOrDefault(e => e.Name == name);
+        }
+    }
+}

--
Gitblit v1.9.1