From 4ad7e2335e10ccad665e451b54cfe628b38a5375 Mon Sep 17 00:00:00 2001 From: handefeng <1030428966@qq.com> Date: Sat, 18 Jan 2025 14:25:22 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E7=AE=97=E6=B3=95json=E8=AF=BB?= =?UTF-8?q?=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Model/Services/AlgorithmServer.cs | 16 +++++++++++----- SparkClient.sln.DotSettings.user | 2 ++ ViewModel/Configuration/AlgorithmConfigVM.cs | 6 ++++++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Model/Services/AlgorithmServer.cs b/Model/Services/AlgorithmServer.cs index 074d888..8c894f5 100644 --- a/Model/Services/AlgorithmServer.cs +++ b/Model/Services/AlgorithmServer.cs @@ -12,11 +12,18 @@ using System.Diagnostics; using System.Text; using System.Text.RegularExpressions; using SparkClient.Model.Common; +using SparkClient.ViewModel.Configuration; namespace SparkClient.Model.Services { public class AlgorithmServer { + private readonly AlgorithmConfigVM _algorithmConfigVM; + + public AlgorithmServer() + { + _algorithmConfigVM = new AlgorithmConfigVM(); + } private static readonly ILog Logger = LogManager.GetLogger(typeof(AlgorithmServer)); // 导入 C++ DLL 中的 DetectDiamond 函数 [DllImport("diamond_cut_inspector.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] @@ -37,12 +44,11 @@ namespace SparkClient.Model.Services bool.TryParse(halfCircleValue.ToString(), out bool boolResult); bool half_circle = boolResult; - //算法配置参数 - string sql = $"SELECT JSON FROM ALGORITHM_CONFIG ORDER BY JSON_ORDER ASC"; - DataTable table = DataBaseHelper.ExecuteQuery(sql); - object lightLevelValue = table.Rows[0][0]; - string algo_config = lightLevelValue.ToString() ?? throw new InvalidOperationException(); + //算法配置参数,初始化算法配置数据并获取 AlgorithmConfigJson + _algorithmConfigVM.InitAlgorithmData(null); + string algo_config = _algorithmConfigVM.AlgorithmConfigJson; + //图片根目录 string? image_file_base_path = ConfigurationManager.AppSettings["ImageFileBasePath"]; if (string.IsNullOrEmpty(image_file_base_path)) diff --git a/SparkClient.sln.DotSettings.user b/SparkClient.sln.DotSettings.user index 6436a89..abc4409 100644 --- a/SparkClient.sln.DotSettings.user +++ b/SparkClient.sln.DotSettings.user @@ -59,6 +59,8 @@ ForceIncluded ForceIncluded ForceIncluded + ForceIncluded + ForceIncluded ForceIncluded ForceIncluded ForceIncluded diff --git a/ViewModel/Configuration/AlgorithmConfigVM.cs b/ViewModel/Configuration/AlgorithmConfigVM.cs index a77416a..a4c96aa 100644 --- a/ViewModel/Configuration/AlgorithmConfigVM.cs +++ b/ViewModel/Configuration/AlgorithmConfigVM.cs @@ -166,4 +166,10 @@ public class AlgorithmConfigVM : BaseViewModel } + // 公共方法来获取 AlgorithmConfigJson + public string GetAlgorithmConfigJson() + { + return AlgorithmConfigJson; + } + } \ No newline at end of file