| | |
| | | using HMI.Core.Entity; |
| | | using HMI.Core.Setting; |
| | | using HMI.Core.Util; |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | |
| | | /// </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 = PathHelper.ProductDataFile; |
| | | string path = GetDataFilePath(); |
| | | if (!File.Exists(path)) return default(T); |
| | | T datas = XmlHelper.DeserializeFromXml<T>(path); |
| | | return datas; |
| | |
| | | /// <returns></returns> |
| | | public static T GetParametersByProductName<T>(string productName) where T : IList<ParameterData> |
| | | { |
| | | string path = Path.Combine(PathHelper.ProductParameterFolder, $"Parameter_{productName}.data"); |
| | | string path = GetParamFolderByProductName(productName); |
| | | if (!File.Exists(path)) return default(T); |
| | | T datas = XmlHelper.DeserializeFromXml<T>(path); |
| | | return datas; |