From f239838c2206c8cb458e34ae0d4163116694db53 Mon Sep 17 00:00:00 2001 From: wenjy Date: Tue, 28 May 2024 14:15:35 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HandleBusiness.cs | 11 +- SlnMesnac.RfidUpload.Common/INIFile.cs | 101 ++++++++++++++++++ .../SlnMesnac.RfidUpload.Model.csproj | 4 + .../config/AppConfig.cs | 62 +++++++++++ .../viewModel/MainWindowViewModel.cs | 4 +- 5 files changed, 180 insertions(+), 2 deletions(-) create mode 100644 SlnMesnac.RfidUpload.Common/INIFile.cs create mode 100644 SlnMesnac.RfidUpload.Model/config/AppConfig.cs diff --git a/SlnMesnac.RfidUpload.Business/HandleBusiness.cs b/SlnMesnac.RfidUpload.Business/HandleBusiness.cs index 1424a1d..43a0829 100644 --- a/SlnMesnac.RfidUpload.Business/HandleBusiness.cs +++ b/SlnMesnac.RfidUpload.Business/HandleBusiness.cs @@ -1,6 +1,7 @@ using SlnMesnac.RfidUpload.Analysis; using SlnMesnac.RfidUpload.Common; using SlnMesnac.RfidUpload.Model; +using SlnMesnac.RfidUpload.Model.config; using SlnMesnac.RfidUpload.TouchSocket; using System; using System.Collections.Generic; @@ -16,6 +17,7 @@ namespace SlnMesnac.RfidUpload.Business private JsonChange _jsonChange = JsonChange.Instance; private InstructionAdapter adapter = InstructionAdapter.Instance; private WebApiClientApp _webApiClientApp = WebApiClientApp.Instance; + private readonly AppConfig appConfig = AppConfig.Instance; private List instructionInfoList = new List(); @@ -147,7 +149,14 @@ namespace SlnMesnac.RfidUpload.Business TimeSpan timeDifference = instructionInfo.recordtime.Subtract(lastInstructionInfo.recordtime); double minutesDifference = timeDifference.TotalMinutes; - if (minutesDifference < 1) + if (string.IsNullOrEmpty(appConfig.filterInterval)) + { + appConfig.filterInterval = "1"; + } + + int filterInterval = Convert.ToInt32(appConfig.filterInterval); + + if (minutesDifference < filterInterval) { return false; } diff --git a/SlnMesnac.RfidUpload.Common/INIFile.cs b/SlnMesnac.RfidUpload.Common/INIFile.cs new file mode 100644 index 0000000..af1a510 --- /dev/null +++ b/SlnMesnac.RfidUpload.Common/INIFile.cs @@ -0,0 +1,101 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; + +#region << 版 本 注 释 >> +/*-------------------------------------------------------------------- +* 版权所有 (c) 2024 WenJY 保留所有权利。 +* CLR版本:4.0.30319.42000 +* 机器名称:T14-GEN3-7895 +* 命名空间:SlnMesnac.RfidUpload.Common +* 唯一标识:b9e73772-16f9-40b7-92cc-4a95c4c34e6d +* +* 创建者:WenJY +* 电子邮箱: +* 创建时间:2024-05-28 14:10:36 +* 版本:V1.0.0 +* 描述: +* +*-------------------------------------------------------------------- +* 修改人: +* 时间: +* 修改说明: +* +* 版本:V1.0.0 +*--------------------------------------------------------------------*/ +#endregion << 版 本 注 释 >> +namespace SlnMesnac.RfidUpload.Common +{ + /// + /// 配置操作类 + /// + public class INIFile + { + public string path; + + public INIFile(string INIPath) + { + path = INIPath; + } + + [DllImport("kernel32")] + private static extern long WritePrivateProfileString(string section, string key, string val, string filePath); + + [DllImport("kernel32")] + private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath); + + + [DllImport("kernel32")] + private static extern int GetPrivateProfileString(string section, string key, string defVal, Byte[] retVal, int size, string filePath); + + + /// + /// 写INI文件 + /// + /// + /// + /// + public void IniWriteValue(string Section, string Key, string Value) + { + WritePrivateProfileString(Section, Key, Value, this.path); + } + + /// + /// 读取INI文件 + /// + /// + /// + /// + public string IniReadValue(string Section, string Key) + { + StringBuilder temp = new StringBuilder(255); + int i = GetPrivateProfileString(Section, Key, "", temp, 255, this.path); + return temp.ToString(); + } + public byte[] IniReadValues(string section, string key) + { + byte[] temp = new byte[255]; + int i = GetPrivateProfileString(section, key, "", temp, 255, this.path); + return temp; + + } + + + /// + /// 删除ini文件下所有段落 + /// + public void ClearAllSection() + { + IniWriteValue(null, null, null); + } + /// + /// 删除ini文件下personal段落下的所有键 + /// + /// + public void ClearSection(string Section) + { + IniWriteValue(Section, null, null); + } + } +} diff --git a/SlnMesnac.RfidUpload.Model/SlnMesnac.RfidUpload.Model.csproj b/SlnMesnac.RfidUpload.Model/SlnMesnac.RfidUpload.Model.csproj index 89c6484..6f5b237 100644 --- a/SlnMesnac.RfidUpload.Model/SlnMesnac.RfidUpload.Model.csproj +++ b/SlnMesnac.RfidUpload.Model/SlnMesnac.RfidUpload.Model.csproj @@ -9,4 +9,8 @@ + + + + diff --git a/SlnMesnac.RfidUpload.Model/config/AppConfig.cs b/SlnMesnac.RfidUpload.Model/config/AppConfig.cs new file mode 100644 index 0000000..94994e8 --- /dev/null +++ b/SlnMesnac.RfidUpload.Model/config/AppConfig.cs @@ -0,0 +1,62 @@ +using SlnMesnac.RfidUpload.Common; +using System; +using System.Collections.Generic; +using System.Text; + +#region << 版 本 注 释 >> +/*-------------------------------------------------------------------- +* 版权所有 (c) 2024 WenJY 保留所有权利。 +* CLR版本:4.0.30319.42000 +* 机器名称:T14-GEN3-7895 +* 命名空间:SlnMesnac.RfidUpload.Model.config +* 唯一标识:8dc07598-dc8a-4ae3-9f67-bc77314a266e +* +* 创建者:WenJY +* 电子邮箱: +* 创建时间:2024-05-28 14:09:03 +* 版本:V1.0.0 +* 描述: +* +*-------------------------------------------------------------------- +* 修改人: +* 时间: +* 修改说明: +* +* 版本:V1.0.0 +*--------------------------------------------------------------------*/ +#endregion << 版 本 注 释 >> +namespace SlnMesnac.RfidUpload.Model.config +{ + public class AppConfig + { + private static readonly Lazy lazy = new Lazy(() => new AppConfig()); + + + //private static StringChange stringChange = StringChange.Instance; + + + public static AppConfig Instance + { + get + { + return lazy.Value; + } + } + + private AppConfig() + { + + } + + private static INIFile iNIFile = new INIFile(System.Environment.CurrentDirectory + "/App.InI"); + + /// + /// 过滤间隔 + /// + public string filterInterval + { + get { return iNIFile.IniReadValue("SystemConfig", "FilterInterval"); } + set { iNIFile.IniWriteValue("SystemConfig", "FilterInterval", value.ToString()); } + } + } +} diff --git a/SlnMesnac.RfidUpload.UI/viewModel/MainWindowViewModel.cs b/SlnMesnac.RfidUpload.UI/viewModel/MainWindowViewModel.cs index 663591a..a249df3 100644 --- a/SlnMesnac.RfidUpload.UI/viewModel/MainWindowViewModel.cs +++ b/SlnMesnac.RfidUpload.UI/viewModel/MainWindowViewModel.cs @@ -7,6 +7,7 @@ using MiniExcelLibs; using NLog; using SlnMesnac.RfidUpload.Business; using SlnMesnac.RfidUpload.Model; +using SlnMesnac.RfidUpload.Model.config; using System; using System.Collections; using System.Collections.Generic; @@ -25,6 +26,7 @@ namespace SlnMesnac.RfidUpload.UI.viewModel private ObservableCollection listItems = new ObservableCollection(); private ObservableCollection labelItems = new ObservableCollection(); + #region 参数定义 /// @@ -126,7 +128,7 @@ namespace SlnMesnac.RfidUpload.UI.viewModel foreach (byte[] package in dataPackages) { _business.LabelHandle(package); - LabelCountParam += 1; + //LabelCountParam += 1; } };