Эх сурвалжийг харах

20250928001 审计基础功能完成,注释掉了Modbus中的常驻异常记录(在线程中运行读取时会大量记录导致数据库阻塞)

向羽 孟 7 сар өмнө
parent
commit
6e0b56ac10

+ 2 - 7
CCDCountWpf/App.config

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <configuration>
   <configSections>
-    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
+    
     <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
   </configSections>
   <startup>
@@ -21,10 +21,5 @@
       <provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
     </providers>
   </entityFramework>
-  <system.data>
-    <DbProviderFactories>
-      <remove invariant="System.Data.SQLite.EF6" />
-      <add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" />
-    <remove invariant="System.Data.SQLite" /><add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" /></DbProviderFactories>
-  </system.data>
+  
 </configuration>

+ 15 - 0
CCDCountWpf/App.xaml.cs

@@ -46,5 +46,20 @@ namespace CCDCountWpf
     /// </summary>
     public partial class App : Application
     {
+        protected override void OnStartup(StartupEventArgs e)
+        {
+            base.OnStartup(e);
+
+            // 处理 UI 线程异常
+            this.DispatcherUnhandledException += (sender, args) =>
+            {
+                if (args.Exception is System.InvalidCastException &&
+                    args.Exception.Message.Contains("Microsoft.Web.WebView2"))
+                {
+                    // 忽略 WebView2 相关的 COM 异常
+                    args.Handled = true;
+                }
+            };
+        }
     }
 }

+ 23 - 27
CCDCountWpf/CCDCountWpf.csproj

@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
 <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <Import Project="..\packages\EntityFramework.6.4.4\build\EntityFramework.props" Condition="Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.props')" />
   <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -61,12 +60,6 @@
     <Prefer32Bit>true</Prefer32Bit>
   </PropertyGroup>
   <ItemGroup>
-    <Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
-      <HintPath>..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.dll</HintPath>
-    </Reference>
-    <Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
-      <HintPath>..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.SqlServer.dll</HintPath>
-    </Reference>
     <Reference Include="MvCameraControl.Net, Version=4.3.2.2, Culture=neutral, PublicKeyToken=a3c7c5e3a730cd12, processorArchitecture=MSIL">
       <SpecificVersion>False</SpecificVersion>
       <HintPath>..\TestWork.DLL\DLL\MvCameraControl.Net.dll</HintPath>
@@ -78,15 +71,6 @@
     <Reference Include="System" />
     <Reference Include="System.ComponentModel.DataAnnotations" />
     <Reference Include="System.Data" />
-    <Reference Include="System.Data.SQLite, Version=1.0.119.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
-      <HintPath>..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.119.0\lib\net46\System.Data.SQLite.dll</HintPath>
-    </Reference>
-    <Reference Include="System.Data.SQLite.EF6, Version=1.0.119.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
-      <HintPath>..\packages\System.Data.SQLite.EF6.1.0.119.0\lib\net46\System.Data.SQLite.EF6.dll</HintPath>
-    </Reference>
-    <Reference Include="System.Data.SQLite.Linq, Version=1.0.119.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
-      <HintPath>..\packages\System.Data.SQLite.Linq.1.0.119.0\lib\net46\System.Data.SQLite.Linq.dll</HintPath>
-    </Reference>
     <Reference Include="System.Drawing" />
     <Reference Include="System.Windows.Forms" />
     <Reference Include="System.Xml" />
@@ -224,7 +208,6 @@
       <Generator>ResXFileCodeGenerator</Generator>
       <LastGenOutput>Resources.Designer.cs</LastGenOutput>
     </EmbeddedResource>
-    <None Include="packages.config" />
     <None Include="Properties\Settings.settings">
       <Generator>SettingsSingleFileGenerator</Generator>
       <LastGenOutput>Settings.Designer.cs</LastGenOutput>
@@ -324,15 +307,28 @@
   <ItemGroup>
     <Resource Include="FromImage\操作_白.png" />
   </ItemGroup>
+  <ItemGroup>
+    <PackageReference Include="EntityFramework">
+      <Version>6.5.1</Version>
+    </PackageReference>
+    <PackageReference Include="Microsoft.Web.WebView2">
+      <Version>1.0.3485.44</Version>
+    </PackageReference>
+    <PackageReference Include="Stub.System.Data.SQLite.Core.NetFramework">
+      <Version>1.0.119</Version>
+    </PackageReference>
+    <PackageReference Include="System.Data.SQLite">
+      <Version>1.0.119</Version>
+    </PackageReference>
+    <PackageReference Include="System.Data.SQLite.Core">
+      <Version>1.0.119</Version>
+    </PackageReference>
+    <PackageReference Include="System.Data.SQLite.EF6">
+      <Version>1.0.119</Version>
+    </PackageReference>
+    <PackageReference Include="System.Data.SQLite.Linq">
+      <Version>1.0.119</Version>
+    </PackageReference>
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
-  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
-    <PropertyGroup>
-      <ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
-    </PropertyGroup>
-    <Error Condition="!Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\EntityFramework.6.4.4\build\EntityFramework.props'))" />
-    <Error Condition="!Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\EntityFramework.6.4.4\build\EntityFramework.targets'))" />
-    <Error Condition="!Exists('..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.119.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.119.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets'))" />
-  </Target>
-  <Import Project="..\packages\EntityFramework.6.4.4\build\EntityFramework.targets" Condition="Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.targets')" />
-  <Import Project="..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.119.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets" Condition="Exists('..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.119.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets')" />
 </Project>

+ 74 - 37
CCDCountWpf/PlcMessageShowBindingClass.cs

@@ -208,7 +208,8 @@ namespace CCDCountWpf
                     if (PlcSettingMessageBus.pLCManagement.WriteSpeedModeRunningSpeed(result))
                     {
                         speedModeRunningSpeed = result;
-                        FaultLog.RecordValueChangeMessage($"速度模式运行速度从{oldValue}修改为{result}");
+                        if (oldValue != result)
+                            FaultLog.RecordValueChangeMessage($"速度模式运行速度从{oldValue}修改为{result}");
                     }
                     OnPropertyChanged("SpeedModeRunningSpeed");
                 }
@@ -230,7 +231,8 @@ namespace CCDCountWpf
                     if(PlcSettingMessageBus.pLCManagement.WriteJogSpeed(result))
                     {
                         jogSpeed = result;
-                        FaultLog.RecordValueChangeMessage($"点动速度从{oldValue}修改为{result}");
+                        if (oldValue != result)
+                            FaultLog.RecordValueChangeMessage($"点动速度从{oldValue}修改为{result}");
                     }
                     OnPropertyChanged("JogSpeed");
                 }
@@ -250,7 +252,8 @@ namespace CCDCountWpf
                 if(PlcSettingMessageBus.pLCManagement.WriteBottValueSet(value))
                 {
                     bottValueSet = value;
-                    FaultLog.RecordValueChangeMessage($"瓶装设定值从{oldValue}修改为{value}");
+                    if (oldValue != value)
+                        FaultLog.RecordValueChangeMessage($"瓶装设定值从{oldValue}修改为{value}");
                 }
                 OnPropertyChanged("BottValueSet");
             }
@@ -271,7 +274,8 @@ namespace CCDCountWpf
                     if(PlcSettingMessageBus.pLCManagement.WriteTransferValveOpeningSpeed(result))
                     {
                         transferValveOpeningSpeed = result;
-                        FaultLog.RecordValueChangeMessage($"中转阀打开速度从{oldValue}修改为{result}");
+                        if (oldValue != result)
+                            FaultLog.RecordValueChangeMessage($"中转阀打开速度从{oldValue}修改为{result}");
                     }
                     OnPropertyChanged("TransferValveOpeningSpeed");
                 }
@@ -291,7 +295,8 @@ namespace CCDCountWpf
                 if (PlcSettingMessageBus.pLCManagement.WriteTransferValveOpeningTime(value))
                 {
                     transferValveOpeningTime = value;
-                    FaultLog.RecordValueChangeMessage($"中转阀打开时间从{oldValue}修改为{value}");
+                    if (oldValue != value)
+                        FaultLog.RecordValueChangeMessage($"中转阀打开时间从{oldValue}修改为{value}");
                 }
                 OnPropertyChanged("TransferValveOpeningTime");
             }
@@ -310,7 +315,8 @@ namespace CCDCountWpf
                 if (PlcSettingMessageBus.pLCManagement.WriteBottingDecelerationValue(value))
                 {
                     bottingDecelerationValue = value;
-                    FaultLog.RecordValueChangeMessage($"罐装减速值从{oldValue}修改为{value}");
+                    if (oldValue != value)
+                        FaultLog.RecordValueChangeMessage($"罐装减速值从{oldValue}修改为{value}");
                 }
                 OnPropertyChanged("BottingDecelerationValue");
             }
@@ -329,7 +335,8 @@ namespace CCDCountWpf
                 if (PlcSettingMessageBus.pLCManagement.WriteCacheDecelerationValue(value))
                 {
                     cacheDecelerationValue = value;
-                    FaultLog.RecordValueChangeMessage($"缓存减速值从{oldValue}修改为{value}");
+                    if (oldValue != value)
+                        FaultLog.RecordValueChangeMessage($"缓存减速值从{oldValue}修改为{value}");
                 }
                 OnPropertyChanged("CacheDecelerationValue");
             }
@@ -348,7 +355,8 @@ namespace CCDCountWpf
                 if (PlcSettingMessageBus.pLCManagement.WriteCacheCountDelayTiming(value))
                 {
                     cacheCountDelayTiming = value;
-                    FaultLog.RecordValueChangeMessage($"缓存计数延迟时间从{oldValue}修改为{value}");
+                    if (oldValue != value)
+                        FaultLog.RecordValueChangeMessage($"缓存计数延迟时间从{oldValue}修改为{value}");
                 }
                 OnPropertyChanged("CacheCountDelayTiming");
             }
@@ -368,7 +376,8 @@ namespace CCDCountWpf
                 if (PlcSettingMessageBus.pLCManagement.WriteCacheShutdownValue(value))
                 {
                     cacheShutdownValue = value;
-                    FaultLog.RecordValueChangeMessage($"缓存停机值从{oldValue}修改为{value}");
+                    if (oldValue != value)
+                        FaultLog.RecordValueChangeMessage($"缓存停机值从{oldValue}修改为{value}");
                 }
                 OnPropertyChanged("CacheShutdownValue");
             }
@@ -387,7 +396,8 @@ namespace CCDCountWpf
                 if (PlcSettingMessageBus.pLCManagement.WriteBottingMaterialCylinderVibrationTableHighSpeedValue(value))
                 {
                     bottingMaterialCylinderVibrationTableHighSpeedValue = value;
-                    FaultLog.RecordValueChangeMessage($"罐装料筒震台高速值从{oldValue}修改为{value}");
+                    if (oldValue != value)
+                        FaultLog.RecordValueChangeMessage($"罐装料筒震台高速值从{oldValue}修改为{value}");
                 }
                 OnPropertyChanged("BottingMaterialCylinderVibrationTableHighSpeedValue");
             }
@@ -406,7 +416,8 @@ namespace CCDCountWpf
                 if (PlcSettingMessageBus.pLCManagement.WriteBottingFilterVibrationTableHighSpeedValue(value))
                 {
                     bottingFilterVibrationTableHighSpeedValue = value;
-                    FaultLog.RecordValueChangeMessage($"罐装过滤震台高速值从{oldValue}修改为{value}");
+                    if (oldValue != value)
+                        FaultLog.RecordValueChangeMessage($"罐装过滤震台高速值从{oldValue}修改为{value}");
                 }
                 OnPropertyChanged("BottingFilterVibrationTableHighSpeedValue");
             }
@@ -425,7 +436,8 @@ namespace CCDCountWpf
                 if(PlcSettingMessageBus.pLCManagement.WriteBottingCountVibrationTableHighSpeedValue(value))
                 {
                     bottingCountVibrationTableHighSpeedValue = value;
-                    FaultLog.RecordValueChangeMessage($"罐装计数震台高速值从{oldValue}修改为{value}");
+                    if (oldValue != value)
+                        FaultLog.RecordValueChangeMessage($"罐装计数震台高速值从{oldValue}修改为{value}");
                 }
                 OnPropertyChanged("BottingCountVibrationTableHighSpeedValue");
             }
@@ -444,7 +456,8 @@ namespace CCDCountWpf
                 if(PlcSettingMessageBus.pLCManagement.WriteBottingMaterialCylinderVibrationTableDecelerationSpeedValue(value))
                 {
                     bottingMaterialCylinderVibrationTableDecelerationSpeedValue = value;
-                    FaultLog.RecordValueChangeMessage($"罐装料筒震台减速值从{oldValue}修改为{value}");
+                    if (oldValue != value)
+                        FaultLog.RecordValueChangeMessage($"罐装料筒震台减速值从{oldValue}修改为{value}");
                 }
                 OnPropertyChanged("BottingMaterialCylinderVibrationTableDecelerationSpeedValue");
             }
@@ -463,7 +476,8 @@ namespace CCDCountWpf
                 if(PlcSettingMessageBus.pLCManagement.WriteBottingFilterVibrationTableDecelerationSpeedValue(value))
                 {
                     bottingFilterVibrationTableDecelerationSpeedValue = value;
-                    FaultLog.RecordValueChangeMessage($"罐装过滤震台减速值从{oldValue}修改为{value}");
+                    if (oldValue != value)
+                        FaultLog.RecordValueChangeMessage($"罐装过滤震台减速值从{oldValue}修改为{value}");
                 }
                 OnPropertyChanged("BottingFilterVibrationTableDecelerationSpeedValue");
             }
@@ -482,7 +496,8 @@ namespace CCDCountWpf
                 if(PlcSettingMessageBus.pLCManagement.WriteBottingCountVibrationTableDecelerationSpeedValue(value))
                 {
                     bottingCountVibrationTableDecelerationSpeedValue = value;
-                    FaultLog.RecordValueChangeMessage($"罐装计数震台减速值从{oldValue}修改为{value}");
+                    if (oldValue != value)
+                        FaultLog.RecordValueChangeMessage($"罐装计数震台减速值从{oldValue}修改为{value}");
                 }
                 OnPropertyChanged("BottingCountVibrationTableDecelerationSpeedValue");
             }
@@ -501,7 +516,8 @@ namespace CCDCountWpf
                 if(PlcSettingMessageBus.pLCManagement.WriteCacheMaterialCylinderVibrationTableHighSpeedValue(value))
                 {
                     cacheMaterialCylinderVibrationTableHighSpeedValue = value;
-                    FaultLog.RecordValueChangeMessage($"缓存料筒震台高速值从{oldValue}修改为{value}");
+                    if (oldValue != value)
+                        FaultLog.RecordValueChangeMessage($"缓存料筒震台高速值从{oldValue}修改为{value}");
                 }
                 OnPropertyChanged("CacheMaterialCylinderVibrationTableHighSpeedValue");
             }
@@ -520,7 +536,8 @@ namespace CCDCountWpf
                 if(PlcSettingMessageBus.pLCManagement.WriteCacheFilterVibrationTableHighSpeedValue(value))
                 {
                     cacheFilterVibrationTableHighSpeedValue = value;
-                    FaultLog.RecordValueChangeMessage($"缓存过滤震台高速值从{oldValue}修改为{value}");
+                    if (oldValue != value)
+                        FaultLog.RecordValueChangeMessage($"缓存过滤震台高速值从{oldValue}修改为{value}");
                 }
                 OnPropertyChanged("CacheFilterVibrationTableHighSpeedValue");
             }
@@ -539,7 +556,8 @@ namespace CCDCountWpf
                 if(PlcSettingMessageBus.pLCManagement.WriteCacheCountVibrationTableHighSpeedValue(value))
                 {
                     cacheCountVibrationTableHighSpeedValue = value;
-                    FaultLog.RecordValueChangeMessage($"缓存计数震台高速值从{oldValue}修改为{value}");
+                    if (oldValue != value)
+                        FaultLog.RecordValueChangeMessage($"缓存计数震台高速值从{oldValue}修改为{value}");
                 }
                 OnPropertyChanged("CacheCountVibrationTableHighSpeedValue");
             }
@@ -558,7 +576,8 @@ namespace CCDCountWpf
                 if(PlcSettingMessageBus.pLCManagement.WriteCacheMaterialCylinderVibrationTableDecelerationSpeedValue(value))
                 {
                     cacheMaterialCylinderVibrationTableDecelerationSpeedValue = value;
-                    FaultLog.RecordValueChangeMessage($"缓存料筒震台减速值从{oldValue}修改为{value}");
+                    if (oldValue != value)
+                        FaultLog.RecordValueChangeMessage($"缓存料筒震台减速值从{oldValue}修改为{value}");
                 }
                 OnPropertyChanged("CacheMaterialCylinderVibrationTableDecelerationSpeedValue");
             }
@@ -577,7 +596,8 @@ namespace CCDCountWpf
                 if(PlcSettingMessageBus.pLCManagement.WriteCacheFilterVibrationTableDecelerationSpeedValue(value))
                 {
                     cacheFilterVibrationTableDecelerationSpeedValue = value;
-                    FaultLog.RecordValueChangeMessage($"缓存过滤震台减速值从{oldValue}修改为{value}");
+                    if (oldValue != value)
+                        FaultLog.RecordValueChangeMessage($"缓存过滤震台减速值从{oldValue}修改为{value}");
                 }
                 OnPropertyChanged("CacheFilterVibrationTableDecelerationSpeedValue");
             }
@@ -596,7 +616,8 @@ namespace CCDCountWpf
                 if(PlcSettingMessageBus.pLCManagement.WriteCacheCountVibrationTableDecelerationSpeedValue(value))
                 {
                     cacheCountVibrationTableDecelerationSpeedValue = value;
-                    FaultLog.RecordValueChangeMessage($"缓存计数震台减速值从{oldValue}修改为{value}");
+                    if (oldValue != value)
+                        FaultLog.RecordValueChangeMessage($"缓存计数震台减速值从{oldValue}修改为{value}");
                 }
                 OnPropertyChanged("CacheCountVibrationTableDecelerationSpeedValue");
             }
@@ -615,7 +636,8 @@ namespace CCDCountWpf
                 if(PlcSettingMessageBus.pLCManagement.WriteGateOpeningDelay(value))
                 {
                     gateOpeningDelay = value;
-                    FaultLog.RecordValueChangeMessage($"阀门打开延时从{oldValue}修改为{value}");
+                    if (oldValue != value)
+                        FaultLog.RecordValueChangeMessage($"阀门打开延时从{oldValue}修改为{value}");
                 }
                 OnPropertyChanged("GateOpeningDelay");
             }
@@ -640,7 +662,8 @@ namespace CCDCountWpf
                     if (PlcSettingMessageBus.pLCManagement.WriteReturnToZeroOffsetValue(result))
                     {
                         returnToZeroOffsetValue = result;
-                        FaultLog.RecordValueChangeMessage($"回零偏移值从{oldValue}修改为{result}");
+                        if (oldValue != result)
+                            FaultLog.RecordValueChangeMessage($"回零偏移值从{oldValue}修改为{result}");
                     }
                     OnPropertyChanged("ReturnToZeroOffsetValue");
                 }
@@ -662,7 +685,8 @@ namespace CCDCountWpf
                     if (PlcSettingMessageBus.pLCManagement.WriteReturnToZeroOffsetSpeed(result))
                     {
                         returnToZeroOffsetSpeed = result;
-                        FaultLog.RecordValueChangeMessage($"回零偏移速度从{oldValue}修改为{result}");
+                        if (oldValue != result)
+                            FaultLog.RecordValueChangeMessage($"回零偏移速度从{oldValue}修改为{result}");
                     }
                     OnPropertyChanged("ReturnToZeroOffsetSpeed");
                 }
@@ -684,7 +708,8 @@ namespace CCDCountWpf
                     if(PlcSettingMessageBus.pLCManagement.WriteTransferValveClosingSpeed(result))
                     {
                         transferValveClosingSpeed = result;
-                        FaultLog.RecordValueChangeMessage($"中转阀关闭速度从{oldValue}修改为{result}");
+                        if (oldValue != result)
+                            FaultLog.RecordValueChangeMessage($"中转阀关闭速度从{oldValue}修改为{result}");
                     }
                     OnPropertyChanged("TransferValveClosingSpeed");
                 }
@@ -706,7 +731,8 @@ namespace CCDCountWpf
                     if(PlcSettingMessageBus.pLCManagement.WriteTransferValveOpenPosition(result))
                     {
                         transferValveOpenPosition = result;
-                        FaultLog.RecordValueChangeMessage($"中转阀开位置从{oldValue}修改为{result}");
+                        if (oldValue != result)
+                            FaultLog.RecordValueChangeMessage($"中转阀开位置从{oldValue}修改为{result}");
                     }
                     OnPropertyChanged("TransferValveOpenPosition");
                 }
@@ -728,7 +754,8 @@ namespace CCDCountWpf
                     if(PlcSettingMessageBus.pLCManagement.WriteTransferValveClosePosition(result))
                     {
                         transferValveClosePosition = result;
-                        FaultLog.RecordValueChangeMessage($"中转阀关位置从{oldValue}修改为{result}");
+                        if (oldValue != result)
+                            FaultLog.RecordValueChangeMessage($"中转阀关位置从{oldValue}修改为{result}");
                     }
                     OnPropertyChanged("TransferValveClosePosition");
                 }
@@ -748,7 +775,8 @@ namespace CCDCountWpf
                 if(PlcSettingMessageBus.pLCManagement.WriteAirValveOpeningDelay(value))
                 {
                     airValveOpeningDelay = value;
-                    FaultLog.RecordValueChangeMessage($"气阀开延时从{oldValue}修改为{value}");
+                    if (oldValue != value)
+                        FaultLog.RecordValueChangeMessage($"气阀开延时从{oldValue}修改为{value}");
                 }
                 OnPropertyChanged("AirValveOpeningDelay");
             }
@@ -767,7 +795,8 @@ namespace CCDCountWpf
                 if(PlcSettingMessageBus.pLCManagement.WriteBottlingShutdownValue(value))
                 {
                     bottlingShutdownValue = value;
-                    FaultLog.RecordValueChangeMessage($"装瓶停机值从{oldValue}修改为{value}");
+                    if (oldValue != value)
+                        FaultLog.RecordValueChangeMessage($"装瓶停机值从{oldValue}修改为{value}");
                 }
                 OnPropertyChanged("BottlingShutdownValue");
             }
@@ -786,7 +815,8 @@ namespace CCDCountWpf
                 if(PlcSettingMessageBus.pLCManagement.WriteBottlingShutdownTime(value))
                 {
                     bottlingShutdownTime = value;
-                    FaultLog.RecordValueChangeMessage($"装瓶停机时间从{oldValue}修改为{value}");
+                    if (oldValue != value)
+                        FaultLog.RecordValueChangeMessage($"装瓶停机时间从{oldValue}修改为{value}");
                 }
                 OnPropertyChanged("BottlingShutdownTime");
             }
@@ -807,7 +837,8 @@ namespace CCDCountWpf
                     if (PlcSettingMessageBus.pLCManagement.WriteBottleFeedingWheelRunningSpeed(result))
                     {
                         bottleFeedingWheelRunningSpeed = result;
-                        FaultLog.RecordValueChangeMessage($"送瓶轮运行速度从{oldValue}修改为{result}");
+                        if (oldValue != result)
+                            FaultLog.RecordValueChangeMessage($"送瓶轮运行速度从{oldValue}修改为{result}");
                     }
                     OnPropertyChanged("BottleFeedingWheelRunningSpeed");
                 }
@@ -829,7 +860,8 @@ namespace CCDCountWpf
                     if (PlcSettingMessageBus.pLCManagement.WriteBottleFeedingWheelJogRunningSpeed(result))
                     {
                         bottleFeedingWheelJogRunningSpeed = result;
-                        FaultLog.RecordValueChangeMessage($"送瓶轮点动速度从{oldValue}修改为{result}");
+                        if (oldValue != result)
+                            FaultLog.RecordValueChangeMessage($"送瓶轮点动速度从{oldValue}修改为{result}");
                     }
                     OnPropertyChanged("BottleFeedingWheelJogRunningSpeed");
                 }
@@ -851,7 +883,8 @@ namespace CCDCountWpf
                     if (PlcSettingMessageBus.pLCManagement.WriteBottleFeedingWheelReturnToZeroOffsetValue(result))
                     {
                         bottleFeedingWheelReturnToZeroOffsetValue = result;
-                        FaultLog.RecordValueChangeMessage($"送瓶轮回零偏移值从{oldValue}修改为{result}");
+                        if (oldValue != result)
+                            FaultLog.RecordValueChangeMessage($"送瓶轮回零偏移值从{oldValue}修改为{result}");
                     }
                     OnPropertyChanged("BottleFeedingWheelReturnToZeroOffsetValue");
                 }
@@ -873,7 +906,8 @@ namespace CCDCountWpf
                     if (PlcSettingMessageBus.pLCManagement.WriteBottleFeedingWheelReturnToZeroSpeed(result))
                     {
                         bottleFeedingWheelReturnToZeroSpeed = result;
-                        FaultLog.RecordValueChangeMessage($"送瓶轮回零速度从{oldValue}修改为{result}");
+                        if (oldValue != result)
+                            FaultLog.RecordValueChangeMessage($"送瓶轮回零速度从{oldValue}修改为{result}");
                     }
                     OnPropertyChanged("BottleFeedingWheelReturnToZeroSpeed");
                 }
@@ -895,7 +929,8 @@ namespace CCDCountWpf
                     if (PlcSettingMessageBus.pLCManagement.WriteBottleFeedingWheelPositionLength(result))
                     {
                         bottleFeedingWheelPositionLength = result;
-                        FaultLog.RecordValueChangeMessage($"送瓶轮定位长度从{oldValue}修改为{result}");
+                        if (oldValue != result)
+                            FaultLog.RecordValueChangeMessage($"送瓶轮定位长度从{oldValue}修改为{result}");
                     }
                     OnPropertyChanged("BottleFeedingWheelPositionLength");
                 }
@@ -915,7 +950,8 @@ namespace CCDCountWpf
                 if (PlcSettingMessageBus.pLCManagement.WriteBottleFeedingWheelPauseTime(value))
                 {
                     bottleFeedingWheelPauseTime = value;
-                    FaultLog.RecordValueChangeMessage($"送瓶轮暂停时间从{oldValue}修改为{value}");
+                    if (oldValue != value)
+                        FaultLog.RecordValueChangeMessage($"送瓶轮暂停时间从{oldValue}修改为{value}");
                 }
                 OnPropertyChanged("BottleFeedingWheelPauseTime");
             }
@@ -934,7 +970,8 @@ namespace CCDCountWpf
                 if (PlcSettingMessageBus.pLCManagement.WriteDelayBlanking(value))
                 {
                     delayBlanking = value;
-                    FaultLog.RecordValueChangeMessage($"下料延时从{oldValue}修改为{value}");
+                    if (oldValue != value)
+                        FaultLog.RecordValueChangeMessage($"下料延时从{oldValue}修改为{value}");
                 }
                 OnPropertyChanged("DelayBlanking");
             }

+ 33 - 31
CCDCountWpf/Properties/Resources.Designer.cs

@@ -1,71 +1,73 @@
 //------------------------------------------------------------------------------
 // <auto-generated>
 //     此代码由工具生成。
-//     运行时版本: 4.0.30319.42000
+//     运行时版本:4.0.30319.42000
 //
-//     对此文件的更改可能导致不正确的行为,如果
-//     重新生成代码,则所做更改将丢失。
+//     对此文件的更改可能导致不正确的行为,并且如果
+//     重新生成代码,这些更改将会丢失。
 // </auto-generated>
 //------------------------------------------------------------------------------
 
-namespace CCDCountWpf.Properties
-{
-
-
+namespace CCDCountWpf.Properties {
+    using System;
+    
+    
     /// <summary>
-    ///   强类型资源类,用于查找本地化字符串等。
+    ///   一个强类型资源类,用于查找本地化字符串等。
     /// </summary>
     // 此类是由 StronglyTypedResourceBuilder
     // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
     // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
     // (以 /str 作为命令选项),或重新生成 VS 项目。
-    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
     [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
-    internal class Resources
-    {
-
+    internal class Resources {
+        
         private static global::System.Resources.ResourceManager resourceMan;
-
+        
         private static global::System.Globalization.CultureInfo resourceCulture;
-
+        
         [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
-        internal Resources()
-        {
+        internal Resources() {
         }
-
+        
         /// <summary>
-        ///   返回此类使用的缓存 ResourceManager 实例。
+        ///   返回此类使用的缓存 ResourceManager 实例。
         /// </summary>
         [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
-        internal static global::System.Resources.ResourceManager ResourceManager
-        {
-            get
-            {
-                if ((resourceMan == null))
-                {
+        internal static global::System.Resources.ResourceManager ResourceManager {
+            get {
+                if (object.ReferenceEquals(resourceMan, null)) {
                     global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CCDCountWpf.Properties.Resources", typeof(Resources).Assembly);
                     resourceMan = temp;
                 }
                 return resourceMan;
             }
         }
-
+        
         /// <summary>
         ///   重写当前线程的 CurrentUICulture 属性,对
         ///   使用此强类型资源类的所有资源查找执行重写。
         /// </summary>
         [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
-        internal static global::System.Globalization.CultureInfo Culture
-        {
-            get
-            {
+        internal static global::System.Globalization.CultureInfo Culture {
+            get {
                 return resourceCulture;
             }
-            set
-            {
+            set {
                 resourceCulture = value;
             }
         }
+        
+        /// <summary>
+        ///   查找 System.Byte[] 类型的本地化资源。
+        /// </summary>
+        internal static byte[] Logo {
+            get {
+                object obj = ResourceManager.GetObject("Logo", resourceCulture);
+                return ((byte[])(obj));
+            }
+        }
     }
 }

+ 12 - 5
CCDCountWpf/Properties/Resources.resx

@@ -46,7 +46,7 @@
     
     mimetype: application/x-microsoft.net.object.binary.base64
     value   : The object must be serialized with 
-            : System.Serialization.Formatters.Binary.BinaryFormatter
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
             : and then encoded with base64 encoding.
     
     mimetype: application/x-microsoft.net.object.soap.base64
@@ -60,6 +60,7 @@
             : and then encoded with base64 encoding.
     -->
   <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
     <xsd:element name="root" msdata:IsDataSet="true">
       <xsd:complexType>
         <xsd:choice maxOccurs="unbounded">
@@ -68,9 +69,10 @@
               <xsd:sequence>
                 <xsd:element name="value" type="xsd:string" minOccurs="0" />
               </xsd:sequence>
-              <xsd:attribute name="name" type="xsd:string" />
+              <xsd:attribute name="name" use="required" type="xsd:string" />
               <xsd:attribute name="type" type="xsd:string" />
               <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
             </xsd:complexType>
           </xsd:element>
           <xsd:element name="assembly">
@@ -85,9 +87,10 @@
                 <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
                 <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
               </xsd:sequence>
-              <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
               <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
               <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
             </xsd:complexType>
           </xsd:element>
           <xsd:element name="resheader">
@@ -109,9 +112,13 @@
     <value>2.0</value>
   </resheader>
   <resheader name="reader">
-    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
   <resheader name="writer">
-    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
+  <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+  <data name="Logo" type="System.Resources.ResXFileRef, System.Windows.Forms">
+    <value>..\FromImage\mmexport1752891278116.jpg;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </data>
 </root>

+ 62 - 18
CCDCountWpf/ShowBindingClass.cs

@@ -224,7 +224,8 @@ namespace CCDCountWpf
                     string oldValue = MessageBus.NowSettingLoadMainThread.FormulationName;
                     MessageBus.NowSettingLoadMainThread.FormulationName = value;
                     MessageBus.NowSettingLoadMainThread.CameraConfigIsChange = true;
-                    FaultLog.RecordValueChangeMessage($"配方名称从{ oldValue }修改为{value}");
+                    if (oldValue != value)
+                        FaultLog.RecordValueChangeMessage($"配方名称从{ oldValue }修改为{value}");
                     OnPropertyChanged("FormulationName");
                 }
             }
@@ -253,7 +254,8 @@ namespace CCDCountWpf
                     MessageBus.NowSettingLoadMainThread.cameraConfig.ExposureTimeValue = newValue;
                     MessageBus.NowSettingLoadMainThread.CameraConfigIsChange = true;
                     MessageBus.NowSettingLoadMainThread.ReLoadCameraConfig();
-                    FaultLog.RecordValueChangeMessage($"相机{MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum}的曝光时间已从{oldValue}修改为{newValue}");
+                    if (oldValue != newValue)
+                        FaultLog.RecordValueChangeMessage($"相机{MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum}的曝光时间已从{oldValue}修改为{newValue}");
                     OnPropertyChanged("ExposureTimeValue");
                 }
             }
@@ -285,7 +287,8 @@ namespace CCDCountWpf
                         MessageBus.NowSettingLoadMainThread.cameraConfig.AcquistionLineRateValue = int.Parse(value);
                         MessageBus.NowSettingLoadMainThread.CameraConfigIsChange = true;
                         MessageBus.NowSettingLoadMainThread.ReLoadCameraConfig();
-                        FaultLog.RecordValueChangeMessage($"相机{MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum}的行频从{oldValue}修改为{value}");
+                        if (oldValue != int.Parse(value))
+                            FaultLog.RecordValueChangeMessage($"相机{MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum}的行频从{oldValue}修改为{value}");
                         OnPropertyChanged("AcquistionLineRate");
                     }
                     catch (Exception)
@@ -323,7 +326,8 @@ namespace CCDCountWpf
                         MessageBus.NowSettingLoadMainThread.cameraConfig.Width = int.Parse(value);
                         MessageBus.NowSettingLoadMainThread.CameraConfigIsChange = true;
                         MessageBus.NowSettingLoadMainThread.ReLoadCameraConfig();
-                        FaultLog.RecordValueChangeMessage($"相机{MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum}的图像宽从{oldValue}修改为{value}");
+                        if (oldValue != int.Parse(value))
+                            FaultLog.RecordValueChangeMessage($"相机{MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum}的图像宽从{oldValue}修改为{value}");
                         OnPropertyChanged("ImageWidth");
                     }
                     catch (Exception)
@@ -361,7 +365,8 @@ namespace CCDCountWpf
                         MessageBus.NowSettingLoadMainThread.cameraConfig.CameraName = value;
                         MessageBus.NowSettingLoadMainThread.CameraConfigIsChange = true;
                         MessageBus.NowSettingLoadMainThread.ReLoadCameraConfig();
-                        FaultLog.RecordValueChangeMessage($"相机{MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum}的用户自定义名从{oldValue}修改为{value}");
+                        if (oldValue != value)
+                            FaultLog.RecordValueChangeMessage($"相机{MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum}的用户自定义名从{oldValue}修改为{value}");
                         OnPropertyChanged("CamUserName");
                     }
                     catch (Exception)
@@ -399,7 +404,8 @@ namespace CCDCountWpf
                         MessageBus.NowSettingLoadMainThread.cameraConfig.OffsetX = int.Parse(value);
                         MessageBus.NowSettingLoadMainThread.CameraConfigIsChange = true;
                         MessageBus.NowSettingLoadMainThread.ReLoadCameraConfig();
-                        FaultLog.RecordValueChangeMessage($"相机{MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum}的图像X偏移从{oldValue}修改为{value}");
+                        if (oldValue != int.Parse(value))
+                            FaultLog.RecordValueChangeMessage($"相机{MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum}的图像X偏移从{oldValue}修改为{value}");
                         OnPropertyChanged("CamOffsetX");
                     }
                     catch (Exception)
@@ -420,6 +426,10 @@ namespace CCDCountWpf
 
         public ObservableCollection<string> BatchItems { get; } = new ObservableCollection<string>();
 
+        public ObservableCollection<string> ValueChangeItems { get; } = new ObservableCollection<string>();
+
+        public ObservableCollection<string> ErrorMessItems { get; } = new ObservableCollection<string>();
+
         /// <summary>
         /// 当前选择的相机SN
         /// </summary>
@@ -482,7 +492,8 @@ namespace CCDCountWpf
                     {
                         int oldValue = MessageBus.NowSettingLoadMainThread.shuLiConfig.RegionThreshold;
                         MessageBus.NowSettingLoadMainThread.shuLiConfig.RegionThreshold = int.Parse(value);
-                        FaultLog.RecordValueChangeMessage($"数粒识别{MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum}的预处理阈值从{oldValue}修改为{value}");
+                        if (oldValue != int.Parse(value))
+                            FaultLog.RecordValueChangeMessage($"数粒识别{MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum}的预处理阈值从{oldValue}修改为{value}");
                         OnPropertyChanged("RegionThreshold");
                     }
                     catch (Exception)
@@ -518,7 +529,8 @@ namespace CCDCountWpf
                     {
                         int oldValue = MessageBus.NowSettingLoadMainThread.shuLiConfig.Channel;
                         MessageBus.NowSettingLoadMainThread.shuLiConfig.Channel = int.Parse(value);
-                        FaultLog.RecordValueChangeMessage($"数粒识别{MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum}的通道数从{oldValue}修改为{value}");
+                        if (oldValue != int.Parse(value))
+                            FaultLog.RecordValueChangeMessage($"数粒识别{MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum}的通道数从{oldValue}修改为{value}");
                         OnPropertyChanged("Channel");
                     }
                     catch (Exception)
@@ -554,7 +566,8 @@ namespace CCDCountWpf
                     {
                         int oldValue = MessageBus.NowSettingLoadMainThread.shuLiConfig.NoiseFilter_Threshold;
                         MessageBus.NowSettingLoadMainThread.shuLiConfig.NoiseFilter_Threshold = int.Parse(value);
-                        FaultLog.RecordValueChangeMessage($"数粒识别{MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum}的噪声滤波阈值从{oldValue}修改为{value}");
+                        if (oldValue != int.Parse(value))
+                            FaultLog.RecordValueChangeMessage($"数粒识别{MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum}的噪声滤波阈值从{oldValue}修改为{value}");
                         OnPropertyChanged("NoiseFilter");
                     }
                     catch (Exception)
@@ -590,7 +603,8 @@ namespace CCDCountWpf
                     {
                         int oldValue = MessageBus.NowSettingLoadMainThread.shuLiConfig.MIN_OBJECT_WIDTH;
                         MessageBus.NowSettingLoadMainThread.shuLiConfig.MIN_OBJECT_WIDTH = int.Parse(value);
-                        FaultLog.RecordValueChangeMessage($"数粒识别{MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum}的异常粒最小宽从{oldValue}修改为{value}");
+                        if (oldValue != int.Parse(value))
+                            FaultLog.RecordValueChangeMessage($"数粒识别{MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum}的异常粒最小宽从{oldValue}修改为{value}");
                         OnPropertyChanged("MIN_OBJECT_WIDTH");
                     }
                     catch (Exception)
@@ -626,7 +640,8 @@ namespace CCDCountWpf
                     {
                         int oldValue = MessageBus.NowSettingLoadMainThread.shuLiConfig.MAX_OBJECT_WIDTH;
                         MessageBus.NowSettingLoadMainThread.shuLiConfig.MAX_OBJECT_WIDTH = int.Parse(value);
-                        FaultLog.RecordValueChangeMessage($"数粒识别{MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum}的异常粒最大宽从{oldValue}修改为{value}");
+                        if (oldValue != int.Parse(value))
+                            FaultLog.RecordValueChangeMessage($"数粒识别{MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum}的异常粒最大宽从{oldValue}修改为{value}");
                         OnPropertyChanged("MAX_OBJECT_WIDTH");
                     }
                     catch (Exception)
@@ -662,7 +677,8 @@ namespace CCDCountWpf
                     {
                         int oldValue = MessageBus.NowSettingLoadMainThread.shuLiConfig.MIN_OBJECT_HEIGHT;
                         MessageBus.NowSettingLoadMainThread.shuLiConfig.MIN_OBJECT_HEIGHT = int.Parse(value);
-                        FaultLog.RecordValueChangeMessage($"数粒识别{MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum}的异常粒最小高从{oldValue}修改为{value}");
+                        if (oldValue != int.Parse(value))
+                            FaultLog.RecordValueChangeMessage($"数粒识别{MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum}的异常粒最小高从{oldValue}修改为{value}");
                         OnPropertyChanged("MIN_OBJECT_HEIGHT");
                     }
                     catch (Exception)
@@ -698,7 +714,8 @@ namespace CCDCountWpf
                     {
                         int oldValue = MessageBus.NowSettingLoadMainThread.shuLiConfig.MAX_OBJECT_HEIGHT;
                         MessageBus.NowSettingLoadMainThread.shuLiConfig.MAX_OBJECT_HEIGHT = int.Parse(value);
-                        FaultLog.RecordValueChangeMessage($"数粒识别{MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum}的异常粒最大高从{oldValue}修改为{value}");
+                        if (oldValue != int.Parse(value))
+                            FaultLog.RecordValueChangeMessage($"数粒识别{MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum}的异常粒最大高从{oldValue}修改为{value}");
                         OnPropertyChanged("MAX_OBJECT_HEIGHT");
                     }
                     catch (Exception)
@@ -734,7 +751,8 @@ namespace CCDCountWpf
                     {
                         int oldValue = MessageBus.NowSettingLoadMainThread.shuLiConfig.MAX_Object_LENGTH;
                         MessageBus.NowSettingLoadMainThread.shuLiConfig.MAX_Object_LENGTH = int.Parse(value);
-                        FaultLog.RecordValueChangeMessage($"数粒识别{MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum}的合格粒最长长度从{oldValue}修改为{value}");
+                        if (oldValue != int.Parse(value))
+                            FaultLog.RecordValueChangeMessage($"数粒识别{MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum}的合格粒最长长度从{oldValue}修改为{value}");
                         OnPropertyChanged("MAX_Object_LENGTH");
                     }
                     catch (Exception)
@@ -770,7 +788,8 @@ namespace CCDCountWpf
                     {
                         int oldValue = MessageBus.NowSettingLoadMainThread.shuLiConfig.MIN_Object_LENGTH;
                         MessageBus.NowSettingLoadMainThread.shuLiConfig.MIN_Object_LENGTH = int.Parse(value);
-                        FaultLog.RecordValueChangeMessage($"数粒识别{MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum}的合格粒的最短长度从{oldValue}修改为{value}");
+                        if (oldValue != int.Parse(value))
+                            FaultLog.RecordValueChangeMessage($"数粒识别{MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum}的合格粒的最短长度从{oldValue}修改为{value}");
                         OnPropertyChanged("MIN_Object_LENGTH");
                     }
                     catch (Exception)
@@ -806,7 +825,8 @@ namespace CCDCountWpf
                     {
                         int oldValue = MessageBus.NowSettingLoadMainThread.shuLiConfig.MinArea;
                         MessageBus.NowSettingLoadMainThread.shuLiConfig.MinArea = int.Parse(value);
-                        FaultLog.RecordValueChangeMessage($"数粒识别{MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum}的异常粒最小面积从{oldValue}修改为{value}");
+                        if (oldValue != int.Parse(value))
+                            FaultLog.RecordValueChangeMessage($"数粒识别{MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum}的异常粒最小面积从{oldValue}修改为{value}");
                         OnPropertyChanged("MinArea");
                     }
                     catch (Exception)
@@ -842,7 +862,8 @@ namespace CCDCountWpf
                     {
                         int oldValue = MessageBus.NowSettingLoadMainThread.shuLiConfig.MaxArea;
                         MessageBus.NowSettingLoadMainThread.shuLiConfig.MaxArea = int.Parse(value);
-                        FaultLog.RecordValueChangeMessage($"数粒识别{MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum}的异常粒最大面积从{oldValue}修改为{value}");
+                        if (oldValue != int.Parse(value))
+                            FaultLog.RecordValueChangeMessage($"数粒识别{MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum}的异常粒最大面积从{oldValue}修改为{value}");
                         OnPropertyChanged("MaxArea");
                     }
                     catch (Exception)
@@ -880,7 +901,8 @@ namespace CCDCountWpf
                         if(oldValue != int.Parse(value))
                         {
                             MessageBus.NowSettingLoadMainThread.shuLiConfig.PandingCode = int.Parse(value);
-                            FaultLog.RecordValueChangeMessage($"数粒识别{MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum}的判断标准识别码从{oldValue}修改为{value}");
+                            if (oldValue != int.Parse(value))
+                                FaultLog.RecordValueChangeMessage($"数粒识别{MessageBus.NowSettingLoadMainThread.cameraConfig.CameraSNNum}的判断标准识别码从{oldValue}修改为{value}");
                         }
                         OnPropertyChanged("PandingCode");
                     }
@@ -943,6 +965,28 @@ namespace CCDCountWpf
             }
         }
 
+        private int bottingCount;
+        public int BottingCount
+        {
+            get { return bottingCount; }
+            set
+            {
+                bottingCount = value;
+                OnPropertyChanged("BottingCount");
+            }
+        }
+
+        private ushort bottingSpeed;
+        public ushort BottingSpeed
+        {
+            get { return bottingSpeed; }
+            set
+            {
+                bottingSpeed = value;
+                OnPropertyChanged("BottingSpeed");
+            }
+        }
+
         //数据绑定核心实现
         public event PropertyChangedEventHandler PropertyChanged;
 

+ 2 - 0
CCDCountWpf/WpfFrom/MainWindow.xaml.cs

@@ -327,6 +327,8 @@ namespace CCDCountWpf
             ShowMessageBus.ShowBinding.AllOkNum = MessageBus.MainThreadS[MessageBus.NowLoadCameraIndex].OkHistoryNum.ToString();
             ShowMessageBus.ShowBinding.AllNgNum = MessageBus.MainThreadS[MessageBus.NowLoadCameraIndex].NgHistoryNum.ToString();
             ShowMessageBus.ShowBinding.ShuLiSpeed = MessageBus.MainThreadS[MessageBus.NowLoadCameraIndex].GetOneSecondActiveNum().ToString();
+            PlcSettingMessageBus.pLCManagement.ReadBottingCount(out ushort BottingCount);
+            ShowMessageBus.ShowBinding.BottingCount = BottingCount;
         }
 
         /// <summary>

+ 50 - 12
CCDCountWpf/WpfPage/AuditTrailPage.xaml

@@ -3,7 +3,7 @@
       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
       xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
       xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
-      xmlns:local="clr-namespace:CCDCountWpf.WpfPage"
+      xmlns:local="clr-namespace:CCDCountWpf.WpfPage" xmlns:wpf="clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf"
       mc:Ignorable="d" 
       d:DesignHeight="450" d:DesignWidth="800"
       Title="AuditTrailPage">
@@ -20,24 +20,62 @@
                 <ColumnDefinition Width="*" />
                 <ColumnDefinition Width="*" />
             </Grid.ColumnDefinitions>
-            <Button x:Name="BatchRecordBtn" Content="批记录" Grid.Column="0"></Button>
-            <Button x:Name="FormulationRecordBtn" Content="生产配方记录" Grid.Column="1"></Button>
-            <Button x:Name="ValueChangeRecordBtd" Content="参数修改记录" Grid.Column="2"></Button>
-            <Button x:Name="ErrorRecordBtn" Content="异常记录" Grid.Column="3"></Button>
+            <Button x:Name="BatchRecordBtn" Content="批记录" Grid.Column="0" Click="BatchRecordBtn_Click"></Button>
+            <Button x:Name="FormulationRecordBtn" Content="生产配方记录" Grid.Column="1" Click="FormulationRecordBtn_Click"></Button>
+            <Button x:Name="ValueChangeRecordBtd" Content="参数修改记录" Grid.Column="2" Click="ValueChangeRecordBtd_Click"></Button>
+            <Button x:Name="ErrorRecordBtn" Content="异常记录" Grid.Column="3" Click="ErrorRecordBtn_Click"></Button>
         </Grid>
         <Grid Grid.Row="1">
-            <Grid x:Name="BatchRecordGrid" Visibility="Visible">
+            <Grid x:Name="BatchRecordGrid" Visibility="Collapsed">
                 <Grid.RowDefinitions>
                     <RowDefinition Height="50" />
                     <RowDefinition Height="*" />
                 </Grid.RowDefinitions>
-                <DatePicker Grid.Row="0" x:Name="BatchMinTime" Width="120" Height="30"  HorizontalAlignment="Left" VerticalAlignment="Center" SelectedDateChanged="BatchMinTime_SelectedDateChanged"/>
-                <DatePicker Grid.Row="0" x:Name="BatchMaxTime" Width="120" Height="30"  HorizontalAlignment="Left" Margin="140,0,0,0" VerticalAlignment="Center" SelectedDateChanged="BatchMaxTime_SelectedDateChanged"/>
-                <ComboBox Grid.Row="0" x:Name="BatchNumComBox" ItemsSource="{Binding BatchItems}" MaxDropDownHeight="100" Background="{x:Null}" HorizontalAlignment="Right" VerticalAlignment="Center" Height="30" Width="180" FontSize="12" HorizontalContentAlignment="Center" Padding="6,6,5,3" Margin="0,0,10,0"/>
+                <Label Content="日期筛选:" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5,0,0,0" />
+                <DatePicker x:Name="BatchMinTime" Width="120" Height="25"  HorizontalAlignment="Left" VerticalAlignment="Center" SelectedDateChanged="BatchMinTime_SelectedDateChanged" Margin="65,0,0,0"/>
+                <Label Content="-" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="190,0,0,0" />
+                <DatePicker x:Name="BatchMaxTime" Width="120" Height="25"  HorizontalAlignment="Left" Margin="210,0,0,0" VerticalAlignment="Center" SelectedDateChanged="BatchMaxTime_SelectedDateChanged"/>
+                <Label Content="记录间隔:" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,350,0" />
+                <ComboBox x:Name="TimeIntervalComBox" Grid.Row="0" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,270,0" Width="80" SelectionChanged="TimeIntervalComBox_SelectionChanged" />
+                <Label Content="批次选择:" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,200,0" />
+                <ComboBox Grid.Row="0" x:Name="BatchNumComBox" ItemsSource="{Binding BatchItems}" MaxDropDownHeight="100" Background="{x:Null}" HorizontalAlignment="Right" VerticalAlignment="Center" Height="30" Width="180" FontSize="12" HorizontalContentAlignment="Center" Padding="6,6,5,3" Margin="0,0,10,0" SelectionChanged="BatchNumComBox_SelectionChanged"/>
+                <wpf:WebView2 x:Name="BatchRecordWebBrowser" Grid.Row="1" />
+            </Grid>
+            <Grid x:Name="FormulationRecordGrid" Visibility="Collapsed">
+                <Grid.RowDefinitions>
+                    <RowDefinition Height="50" />
+                    <RowDefinition Height="*" />
+                </Grid.RowDefinitions>
+                <Label Content="配方选择:" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,200,0" />
+                <ComboBox Grid.Row="0" x:Name="FormulationRecordComBox" ItemsSource="{Binding FormulationItems}" MaxDropDownHeight="100" Background="{x:Null}" HorizontalAlignment="Right" VerticalAlignment="Center" Height="30" Width="180" FontSize="12" HorizontalContentAlignment="Center" Padding="6,6,5,3" Margin="0,0,10,0" SelectionChanged="FormulationRecordComBox_SelectionChanged"/>
+                <wpf:WebView2 x:Name="FormulationRecordWebBrowser" Grid.Row="1" />
+            </Grid>
+            <Grid x:Name="ValueChangeRecordGrid" Visibility="Collapsed">
+                <Grid.RowDefinitions>
+                    <RowDefinition Height="50" />
+                    <RowDefinition Height="*" />
+                </Grid.RowDefinitions>
+                <Label Content="日期筛选:" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5,0,0,0" />
+                <DatePicker x:Name="ValueChangeRecordMinTime" Width="120" Height="25"  HorizontalAlignment="Left" VerticalAlignment="Center" SelectedDateChanged="ValueChangeRecordMinTime_SelectedDateChanged" Margin="65,0,0,0"/>
+                <Label Content="-" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="190,0,0,0" />
+                <DatePicker x:Name="ValueChangeRecordMaxTime" Width="120" Height="25"  HorizontalAlignment="Left" Margin="210,0,0,0" VerticalAlignment="Center" SelectedDateChanged="ValueChangeRecordMaxTime_SelectedDateChanged"/>
+                <Label Content="日期选择:" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,200,0" />
+                <ComboBox Grid.Row="0" x:Name="ValueChangeDateComBox" ItemsSource="{Binding ValueChangeItems}" MaxDropDownHeight="100" Background="{x:Null}" HorizontalAlignment="Right" VerticalAlignment="Center" Height="30" Width="180" FontSize="12" HorizontalContentAlignment="Center" Padding="6,6,5,3" Margin="0,0,10,0" SelectionChanged="ValueChangeRecordComBox_SelectionChanged"/>
+                <wpf:WebView2 x:Name="ValueChangeRecordWebBrowser" Grid.Row="1" />
+            </Grid>
+            <Grid x:Name="ErrorRecordGrid" Visibility="Visible">
+                <Grid.RowDefinitions>
+                    <RowDefinition Height="50" />
+                    <RowDefinition Height="*" />
+                </Grid.RowDefinitions>
+                <Label Content="日期筛选:" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5,0,0,0" />
+                <DatePicker x:Name="ErrorMessageRecordMinTime" Width="120" Height="25"  HorizontalAlignment="Left" VerticalAlignment="Center" SelectedDateChanged="ErrorMessageRecordMinTime_SelectedDateChanged" Margin="65,0,0,0"/>
+                <Label Content="-" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="190,0,0,0" />
+                <DatePicker x:Name="ErrorMessageRecordMaxTime" Width="120" Height="25"  HorizontalAlignment="Left" Margin="210,0,0,0" VerticalAlignment="Center" SelectedDateChanged="ErrorMessageRecordMaxTime_SelectedDateChanged"/>
+                <Label Content="日期选择:" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,200,0" />
+                <ComboBox Grid.Row="0" x:Name="ErrorMessageDateComBox" ItemsSource="{Binding ErrorMessItems}" MaxDropDownHeight="100" Background="{x:Null}" HorizontalAlignment="Right" VerticalAlignment="Center" Height="30" Width="180" FontSize="12" HorizontalContentAlignment="Center" Padding="6,6,5,3" Margin="0,0,10,0" SelectionChanged="ErrorMessageRecordComBox_SelectionChanged"/>
+                <wpf:WebView2 x:Name="ErrorMessageRecordWebBrowser" Grid.Row="1" />
             </Grid>
-            <Grid x:Name="FormulationRecordGrid" Visibility="Collapsed"></Grid>
-            <Grid x:Name="ValueChangeRecordGrid" Visibility="Collapsed"></Grid>
-            <Grid x:Name="ErrorRecordGrid" Visibility="Collapsed"></Grid>
         </Grid>
     </Grid>
 </Page>

+ 785 - 40
CCDCountWpf/WpfPage/AuditTrailPage.xaml.cs

@@ -1,8 +1,13 @@
-using CCDCount.DLL.Tools;
+using CCDCount.DLL.AuditTrail;
+using CCDCount.DLL.SqlDataClass;
+using CCDCount.DLL.Tools;
+using CCDCount.MODEL.AuditTrailModel;
+using CCDCount.MODEL.ConfigModel;
 using System;
 using System.Collections.Generic;
 using System.IO;
 using System.Linq;
+using System.Threading.Tasks;
 using System.Windows.Controls;
 
 
@@ -13,6 +18,37 @@ namespace CCDCountWpf.WpfPage
     /// </summary>
     public partial class AuditTrailPage : Page
     {
+        #region 实例
+        /// <summary>
+        /// 批次信息数据类
+        /// </summary>
+        BatchMessSqliteDataClass batchMessSqliteData = null;
+        ErrorMesSqliteDataClass errorMesSqliteData = null;
+
+        // <summary>
+        /// 批次记录类(数据转PDF)
+        /// </summary>
+        BatchRecordClass batchRecord = new BatchRecordClass();
+
+        FormulationRecordClass formulationRecordClass = new FormulationRecordClass();
+
+        ValueChangeRecordClass ValueChangeRecordClass = new ValueChangeRecordClass();
+
+        ErrorMessageRecordClass errorMessageRecordClass = new ErrorMessageRecordClass();
+        #endregion
+
+        #region 变量
+        /// <summary>
+        /// 时间间隔
+        /// </summary>
+        int TimeInterval = 0;
+        string FormulationfolderPath = "";
+        #endregion
+
+        #region 窗口事件
+        /// <summary>
+        /// 构建方法
+        /// </summary>
         public AuditTrailPage()
         {
             InitializeComponent();
@@ -20,16 +56,301 @@ namespace CCDCountWpf.WpfPage
             this.Width = Double.NaN;
             DataContext = ShowMessageBus.ShowBinding;
             InitBatchItems();
-            test();
-            string patch = $"{AppDomain.CurrentDomain.BaseDirectory}PDF\\report_with_images.pdf";
-            //BatchRecordWebBrowser.Navigate(new Uri(patch));
+            InitTimeIntervalComBox();
+            InitFormationItems();
+            InitValueChangeItems();
+            InitErrorMessage();
         }
+
         /// <summary>
-        /// 初始化配方列表
+        /// 批号时间筛选选择时间-最小时间
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void BatchMinTime_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
+        {
+            if (BatchMinTime.SelectedDate == null)
+            {
+                return;
+            }
+            else
+            {
+                if (BatchMaxTime.SelectedDate == null)
+                {
+                    InitBatchItemsByMinTime((DateTime)BatchMinTime.SelectedDate);
+                }
+                else
+                {
+                    InitBatchItems((DateTime)BatchMinTime.SelectedDate, (DateTime)BatchMaxTime.SelectedDate);
+                }
+            }
+        }
+
+        /// <summary>
+        /// 批号时间筛选选择时间-最大时间
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void BatchMaxTime_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
+        {
+            if (BatchMaxTime.SelectedDate == null)
+            {
+                return;
+            }
+            else
+            {
+                if (BatchMinTime.SelectedDate == null)
+                {
+                    InitBatchItemsByMaxTime((DateTime)BatchMaxTime.SelectedDate);
+                }
+                else
+                {
+                    InitBatchItems((DateTime)BatchMinTime.SelectedDate, (DateTime)BatchMaxTime.SelectedDate);
+                }
+            }
+        }
+
+        /// <summary>
+        /// 批号选择事件
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void BatchNumComBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            if (BatchNumComBox.SelectedItem == null || BatchNumComBox.SelectedItem.ToString() == "")
+            {
+                return;
+            }
+            if (TimeInterval == 0) return;
+            string LoadPath = GenerateBatchPDF();
+            BatchLoadPdf(LoadPath);
+        }
+
+        /// <summary>
+        /// 时间间隔选择事件
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void TimeIntervalComBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            if (TimeIntervalComBox.SelectedItem != null)
+            {
+                // 获取显示的文本
+                var selectedText = TimeIntervalComBox.Text;
+
+                // 获取选中的值
+                var selectedValue = Convert.ToInt32(TimeIntervalComBox.SelectedValue?.ToString());
+
+                TimeInterval = selectedValue;
+
+                if (BatchNumComBox.SelectedItem == null || BatchNumComBox.SelectedItem.ToString() == "")
+                {
+                    return;
+                }
+                if (TimeInterval == 0) return;
+                string LoadPath = GenerateBatchPDF();
+                BatchLoadPdf(LoadPath);
+            }
+        }
+
+        /// <summary>
+        /// 批号记录按钮点击事件
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void BatchRecordBtn_Click(object sender, System.Windows.RoutedEventArgs e)
+        {
+            BatchRecordGrid.Visibility = System.Windows.Visibility.Visible;
+            FormulationRecordGrid.Visibility = System.Windows.Visibility.Collapsed;
+            ValueChangeRecordGrid.Visibility = System.Windows.Visibility.Collapsed;
+            ErrorRecordGrid.Visibility = System.Windows.Visibility.Collapsed;
+        }
+
+        /// <summary>
+        /// 配方记录按钮点击事件
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void FormulationRecordBtn_Click(object sender, System.Windows.RoutedEventArgs e)
+        {
+            BatchRecordGrid.Visibility = System.Windows.Visibility.Collapsed;
+            FormulationRecordGrid.Visibility = System.Windows.Visibility.Visible;
+            ValueChangeRecordGrid.Visibility = System.Windows.Visibility.Collapsed;
+            ErrorRecordGrid.Visibility = System.Windows.Visibility.Collapsed;
+        }
+
+        /// <summary>
+        /// 值改变记录按钮点击事件
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void ValueChangeRecordBtd_Click(object sender, System.Windows.RoutedEventArgs e)
+        {
+            BatchRecordGrid.Visibility = System.Windows.Visibility.Collapsed;
+            FormulationRecordGrid.Visibility = System.Windows.Visibility.Collapsed;
+            ValueChangeRecordGrid.Visibility = System.Windows.Visibility.Visible;
+            ErrorRecordGrid.Visibility = System.Windows.Visibility.Collapsed;
+        }
+
+        /// <summary>
+        /// 错误记录按钮点击事件
+        /// </summary>
+        private void ErrorRecordBtn_Click(object sender, System.Windows.RoutedEventArgs e)
+        {
+            BatchRecordGrid.Visibility = System.Windows.Visibility.Collapsed;
+            FormulationRecordGrid.Visibility = System.Windows.Visibility.Collapsed;
+            ValueChangeRecordGrid.Visibility = System.Windows.Visibility.Collapsed;
+            ErrorRecordGrid.Visibility = System.Windows.Visibility.Visible;
+        }
+
+        /// <summary>
+        /// 配方选择事件
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void FormulationRecordComBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            if (FormulationRecordComBox.SelectedItem == null || FormulationRecordComBox.SelectedItem.ToString() == "")
+            {
+                return;
+            }
+            FormulationfolderPath = $"{AppDomain.CurrentDomain.BaseDirectory}Formulations\\{FormulationRecordComBox.SelectedItem.ToString()}.xml";
+            string pdfFilePath = GenerateFormulationPDF();
+            FormulationLoadPdf(pdfFilePath);
+        }
+
+        /// <summary>
+        /// 值改变记录最小时间选择框选择事件
+        /// </summary>
+        private void ValueChangeRecordMinTime_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
+        {
+            if (ValueChangeRecordMinTime.SelectedDate == null)
+            {
+                return;
+            }
+            else
+            {
+                if (ValueChangeRecordMaxTime.SelectedDate == null)
+                {
+                    InitValueChangeItemsByMinTime((DateTime)ValueChangeRecordMinTime.SelectedDate);
+                }
+                else
+                {
+                    InitValueChangeItems((DateTime)ValueChangeRecordMinTime.SelectedDate, (DateTime)ValueChangeRecordMaxTime.SelectedDate);
+                }
+            }
+        }
+
+        /// <summary>
+        /// 值改变记录最大时间选择框选择事件
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void ValueChangeRecordMaxTime_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
+        {
+            if (ValueChangeRecordMaxTime.SelectedDate == null)
+            {
+                return;
+            }
+            else
+            {
+                if (ValueChangeRecordMinTime.SelectedDate == null)
+                {
+                    InitValueChangeItemsByMaxTime((DateTime)ValueChangeRecordMaxTime.SelectedDate);
+                }
+                else
+                {
+                    InitValueChangeItems((DateTime)ValueChangeRecordMinTime.SelectedDate, (DateTime)ValueChangeRecordMaxTime.SelectedDate);
+                }
+            }
+        }
+
+        /// <summary>
+        /// 值改变记录选择框选择事件
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void ValueChangeRecordComBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            if (ValueChangeDateComBox.SelectedItem == null || ValueChangeDateComBox.SelectedItem.ToString() == "")
+            {
+                return;
+            }
+            string LoadPath = GenerateValueChangePDF();
+            ValueChangeLoadPdf(LoadPath);
+        }
+
+        /// <summary>
+        /// 异常信息选择事件
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void ErrorMessageRecordComBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            if (ErrorMessageDateComBox.SelectedItem == null || ErrorMessageDateComBox.SelectedItem.ToString() == "")
+            {
+                return;
+            }
+            string LoadPath = GenerateErrorMessagePDF();
+            ErrorMessageLoadPdf(LoadPath);
+        }
+
+        /// <summary>
+        /// 异常信息时间选择事件-最小时间
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void ErrorMessageRecordMinTime_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
+        {
+            if (ErrorMessageRecordMinTime.SelectedDate == null)
+            {
+                return;
+            }
+            else
+            {
+                if (ErrorMessageRecordMaxTime.SelectedDate == null)
+                {
+                    InitErrorMessageByMinTime((DateTime)ErrorMessageRecordMinTime.SelectedDate);
+                }
+                else
+                {
+                    InitErrorMessage((DateTime)ErrorMessageRecordMinTime.SelectedDate, (DateTime)ErrorMessageRecordMaxTime.SelectedDate);
+                }
+            }
+        }
+
+        /// <summary>
+        /// 异常信息时间选择事件-最大时间
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void ErrorMessageRecordMaxTime_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
+        {
+            if (ErrorMessageRecordMaxTime.SelectedDate == null)
+            {
+                return;
+            }
+            else
+            {
+                if (ErrorMessageRecordMinTime.SelectedDate == null)
+                {
+                    InitErrorMessageByMaxTime((DateTime)ErrorMessageRecordMaxTime.SelectedDate);
+                }
+                else
+                {
+                    InitErrorMessage((DateTime)ErrorMessageRecordMinTime.SelectedDate, (DateTime)ErrorMessageRecordMaxTime.SelectedDate);
+                }
+            }
+        }
+        #endregion
+
+        #region 私有方法
+        /// <summary>
+        /// 初始化批次列表
         /// </summary>
         private void InitBatchItems()
         {
-            string folderPath = $"{AppDomain.CurrentDomain.BaseDirectory}DATA\\ActiveObjectData\\Cam{MessageBus.MainThreadS[0].cameraConfig.CamerNo}";
+            string folderPath = $"{AppDomain.CurrentDomain.BaseDirectory}DATA\\BatchData";
             if (!Directory.Exists(folderPath))
             {
                 // 创建文件夹
@@ -55,11 +376,11 @@ namespace CCDCountWpf.WpfPage
         }
 
         /// <summary>
-        /// 初始化配方列表
+        /// 初始化批号列表
         /// </summary>
-        private void InitBatchItems(DateTime Mintime,DateTime MaxTime)
+        private void InitBatchItems(DateTime Mintime, DateTime MaxTime)
         {
-            string folderPath = $"{AppDomain.CurrentDomain.BaseDirectory}DATA\\ActiveObjectData\\Cam{MessageBus.MainThreadS[0].cameraConfig.CamerNo}";
+            string folderPath = $"{AppDomain.CurrentDomain.BaseDirectory}DATA\\BatchData";
             if (!Directory.Exists(folderPath))
             {
                 // 创建文件夹
@@ -72,7 +393,7 @@ namespace CCDCountWpf.WpfPage
                 FileInfo[] files = dirInfo.GetFiles("*.*", SearchOption.AllDirectories);
 
                 // 按照修改时间排序(最新的在前)
-                var sortedFiles = files.Where(f=>f.CreationTime>Mintime&&f.CreationTime<MaxTime.AddDays(1)).OrderByDescending(f => f.LastWriteTime).ToArray();
+                var sortedFiles = files.Where(f => f.CreationTime > Mintime && f.CreationTime < MaxTime.AddDays(1)).OrderByDescending(f => f.LastWriteTime).ToArray();
                 ShowMessageBus.ShowBinding.BatchItems.Clear();
                 foreach (FileInfo file in sortedFiles)
                 {
@@ -85,11 +406,11 @@ namespace CCDCountWpf.WpfPage
         }
 
         /// <summary>
-        /// 初始化配方列表
+        /// 初始化批号列表
         /// </summary>
         private void InitBatchItemsByMinTime(DateTime Mintime)
         {
-            string folderPath = $"{AppDomain.CurrentDomain.BaseDirectory}DATA\\ActiveObjectData\\Cam{MessageBus.MainThreadS[0].cameraConfig.CamerNo}";
+            string folderPath = $"{AppDomain.CurrentDomain.BaseDirectory}DATA\\BatchData";
             if (!Directory.Exists(folderPath))
             {
                 // 创建文件夹
@@ -115,11 +436,11 @@ namespace CCDCountWpf.WpfPage
         }
 
         /// <summary>
-        /// 初始化配方列表
+        /// 初始化批号列表
         /// </summary>
         private void InitBatchItemsByMaxTime(DateTime MaxTime)
         {
-            string folderPath = $"{AppDomain.CurrentDomain.BaseDirectory}DATA\\ActiveObjectData\\Cam{MessageBus.MainThreadS[0].cameraConfig.CamerNo}";
+            string folderPath = $"{AppDomain.CurrentDomain.BaseDirectory}DATA\\BatchData";
             if (!Directory.Exists(folderPath))
             {
                 // 创建文件夹
@@ -132,7 +453,7 @@ namespace CCDCountWpf.WpfPage
                 FileInfo[] files = dirInfo.GetFiles("*.*", SearchOption.AllDirectories);
 
                 // 按照修改时间排序(最新的在前)
-                var sortedFiles = files.Where(f=>f.CreationTime < MaxTime.AddDays(1)).OrderByDescending(f => f.LastWriteTime).ToArray();
+                var sortedFiles = files.Where(f => f.CreationTime < MaxTime.AddDays(1)).OrderByDescending(f => f.LastWriteTime).ToArray();
                 ShowMessageBus.ShowBinding.BatchItems.Clear();
                 foreach (FileInfo file in sortedFiles)
                 {
@@ -144,54 +465,478 @@ namespace CCDCountWpf.WpfPage
             { }
         }
 
-        private void BatchMinTime_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
+        /// <summary>
+        /// 初始化时间间隔下拉框
+        /// </summary>
+        private void InitTimeIntervalComBox()
         {
-            if(BatchMinTime.SelectedDate==null)
+            // 数据源
+            var items = new List<KeyValuePair<string, int>>
             {
-                return;
+                new KeyValuePair<string, int>("1秒", 1),
+                new KeyValuePair<string, int>("5秒", 5),
+                new KeyValuePair<string, int>("10秒", 10),
+                new KeyValuePair<string, int>("30秒",30),
+                new KeyValuePair<string, int>("1分", 60),
+                new KeyValuePair<string, int>("5分", 300),
+            };
+            TimeIntervalComBox.ItemsSource = items;
+            TimeIntervalComBox.DisplayMemberPath = "Key";
+            TimeIntervalComBox.SelectedValuePath = "Value";
+            TimeIntervalComBox.SelectedIndex = 0;
+        }
+
+        /// <summary>
+        /// 初始化配方列表
+        /// </summary>
+        private void InitFormationItems()
+        {
+            string folderPath = $"{AppDomain.CurrentDomain.BaseDirectory}Formulations";
+            if (!Directory.Exists(folderPath))
+            {
+                // 创建文件夹
+                Directory.CreateDirectory(folderPath);
             }
-            else
+            try
             {
-                if(BatchMaxTime.SelectedDate == null)
+                // 获取文件列表(包含子目录)
+                string[] files = Directory.GetFiles(folderPath, "*.*", SearchOption.AllDirectories);
+                ShowMessageBus.ShowBinding.FormulationItems.Clear();
+                foreach (string file in files)
                 {
-                    InitBatchItemsByMinTime((DateTime)BatchMinTime.SelectedDate);
+                    ShowMessageBus.ShowBinding.FormulationItems.Add(Path.GetFileNameWithoutExtension(file));
                 }
-                else
+                if (ShowMessageBus.ShowBinding.FormulationName != null && ShowMessageBus.ShowBinding.FormulationName != string.Empty)
                 {
-                    InitBatchItems((DateTime)BatchMinTime.SelectedDate, (DateTime)BatchMaxTime.SelectedDate);
+                    try
+                    {
+                        FormulationRecordComBox.SelectedItem = ShowMessageBus.ShowBinding.FormulationName;
+                    }
+                    catch { }
                 }
             }
+            catch
+            { }
         }
 
-        private void BatchMaxTime_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
+        /// <summary>
+        /// 生成批记录PDF
+        /// </summary>
+        /// <returns></returns>
+        private string GenerateBatchPDF()
         {
-            if (BatchMaxTime.SelectedDate == null)
+            string BatchNumber = BatchNumComBox.SelectedItem.ToString();
+            //string LoadPath = $"{AppDomain.CurrentDomain.BaseDirectory}PDF\\BatchData.PDF";
+            batchMessSqliteData = new BatchMessSqliteDataClass($"{AppDomain.CurrentDomain.BaseDirectory}DATA\\BatchData\\BatchData_{BatchNumber}.db");
+            var batchMess = batchMessSqliteData.GetAllBatchMessage();
+            var ShowtableMessage = batchMess.Where((item, index) => index % TimeInterval == 0).ToList();
+            List<string> ColSpan = new List<string>()
             {
-                return;
+                "批次号",
+                "料筒震盘速度",
+                "过滤震台速度",
+                "计数震台速度",
+                "装瓶数量",
+                "装瓶速度",
+                "记录时间"
+            };
+            batchRecord.GetRecordLogo(Properties.Resources.Logo);
+            return batchRecord.BatchRecordToPDFReColspan(ShowtableMessage, ColSpan);
+        }
+
+        /// <summary>
+        /// 生成配方PDF
+        /// </summary>
+        /// <returns></returns>
+        private string GenerateFormulationPDF()
+        {
+            string BatchNumber = BatchNumComBox.SelectedItem.ToString();
+            FormulationConfigClass formulationConfigClass = null;
+            formulationConfigClass = XmlStorage.DeserializeFromXml<FormulationConfigClass>(FormulationfolderPath);
+            formulationRecordClass.GetRecordLogo(Properties.Resources.Logo);
+            List<string> RowSpanNames = new List<string>()
+            {
+                "配方名称",
+                "二值化阈值",
+                "允许物体中断的最大连续行数",
+                "合格物体的最长长度",
+                "合格物体的最短长度",
+                "判定标准识别码",
+                "合格物体的最大面积",
+                "合格物体的最小面积",
+                "噪声过滤阈值",
+                "通道数量",
+                "曝光时间",
+                "采集行频",
+                "设备名称",
+                "速度模式运行速度",
+                "点动速度",
+                "瓶装设定值",
+                "中转阀打开速度",
+                "中转阀打开时间",
+                "罐装减速值",
+                "缓存减速值",
+                "缓存计数延迟时间",
+                "缓存停机值",
+                "罐装料筒震台高速值",
+                "罐装过滤震台高速值",
+                "罐装计数震台高速值",
+                "罐装料筒震台减速值",
+                "罐装过滤震台减速值",
+                "罐装计数震台减速值",
+                "缓存料筒震台高速值",
+                "缓存过滤震台高速值",
+                "缓存计数震台高速值",
+                "缓存料筒震台减速值",
+                "缓存过滤震台减速值",
+                "缓存计数震台减速值",
+                "阀门打开延迟",
+                "回零偏移值",
+                "回零偏移速度",
+                "中转阀关闭速度",
+                "中转阀打开位置",
+                "中转阀关闭位置",
+                "气阀打开延迟",
+                "装瓶停机值",
+                "装瓶停机时间",
+                "送瓶轮运行速度",
+                "送瓶轮点动速度",
+                "送瓶轮回零偏移值",
+                "送瓶轮回零速度",
+                "送瓶轮位置长度",
+                "送瓶轮暂停时间",
+                "下料延时"
+            };
+            return formulationRecordClass.FormulationRecordToPDFReRowspan(formulationConfigClass, RowSpanNames);
+        }
+
+        /// <summary>
+        /// 加载PDF
+        /// </summary>
+        /// <param name="pdfFilePath"></param>
+        private async void BatchLoadPdf(string pdfFilePath)
+        {
+            // 加载 PDF 文件
+            await BatchRecordWebBrowser.EnsureCoreWebView2Async(null);
+            BatchRecordWebBrowser.CoreWebView2.Navigate(pdfFilePath);
+        }
+
+        /// <summary>
+        /// 加载PDF
+        /// </summary>
+        /// <param name="pdfFilePath"></param>
+        private async void FormulationLoadPdf(string pdfFilePath)
+        {
+            // 加载 PDF 文件
+            await FormulationRecordWebBrowser.EnsureCoreWebView2Async(null);
+            FormulationRecordWebBrowser.CoreWebView2.Navigate(pdfFilePath);
+        }
+
+        /// <summary>
+        /// 加载PDF
+        /// </summary>
+        /// <param name="pdfFilePath"></param>
+        private async void ValueChangeLoadPdf(string pdfFilePath)
+        {
+            // 加载 PDF 文件
+            await ValueChangeRecordWebBrowser.EnsureCoreWebView2Async(null);
+            ValueChangeRecordWebBrowser.CoreWebView2.Navigate(pdfFilePath);
+        }
+
+        /// <summary>
+        /// 加载PDF
+        /// </summary>
+        /// <param name="pdfFilePath"></param>
+        private async void ErrorMessageLoadPdf(string pdfFilePath)
+        {
+            // 加载 PDF 文件
+            await ErrorMessageRecordWebBrowser.EnsureCoreWebView2Async(null);
+            ErrorMessageRecordWebBrowser.CoreWebView2.Navigate(pdfFilePath);
+        }
+
+        /// <summary>
+        /// 初始化异常数据列表
+        /// </summary>
+        private void InitValueChangeItems()
+        {
+            string folderPath = $"{AppDomain.CurrentDomain.BaseDirectory}DATA\\FaultMessage";
+            if (!Directory.Exists(folderPath))
+            {
+                // 创建文件夹
+                Directory.CreateDirectory(folderPath);
             }
-            else
+            try
             {
-                if (BatchMinTime.SelectedDate == null)
+                // 使用 DirectoryInfo 获取文件并按修改时间排序
+                DirectoryInfo dirInfo = new DirectoryInfo(folderPath);
+                FileInfo[] files = dirInfo.GetFiles("*.*", SearchOption.AllDirectories);
+
+                // 按照修改时间排序(最新的在前)
+                var sortedFiles = files.OrderByDescending(f => f.LastWriteTime).ToArray();
+                ShowMessageBus.ShowBinding.ValueChangeItems.Clear();
+                foreach (FileInfo file in sortedFiles)
                 {
-                    InitBatchItemsByMaxTime((DateTime)BatchMaxTime.SelectedDate);
+                    ShowMessageBus.ShowBinding.ValueChangeItems.Add(Path.GetFileNameWithoutExtension(file.Name).Split('_')[1]);
                 }
-                else
+                ValueChangeDateComBox.SelectedIndex = 0;
+            }
+            catch
+            { }
+        }
+
+        /// <summary>
+        /// 初始化异常数据列表
+        /// </summary>
+        private void InitValueChangeItems(DateTime Mintime, DateTime MaxTime)
+        {
+            string folderPath = $"{AppDomain.CurrentDomain.BaseDirectory}DATA\\FaultMessage";
+            if (!Directory.Exists(folderPath))
+            {
+                // 创建文件夹
+                Directory.CreateDirectory(folderPath);
+            }
+            try
+            {
+                // 使用 DirectoryInfo 获取文件并按修改时间排序
+                DirectoryInfo dirInfo = new DirectoryInfo(folderPath);
+                FileInfo[] files = dirInfo.GetFiles("*.*", SearchOption.AllDirectories);
+
+                // 按照修改时间排序(最新的在前)
+                var sortedFiles = files.Where(f => f.CreationTime > Mintime && f.CreationTime < MaxTime.AddDays(1)).OrderByDescending(f => f.LastWriteTime).ToArray();
+                ShowMessageBus.ShowBinding.ValueChangeItems.Clear();
+                foreach (FileInfo file in sortedFiles)
                 {
-                    InitBatchItems((DateTime)BatchMinTime.SelectedDate, (DateTime)BatchMaxTime.SelectedDate);
+                    ShowMessageBus.ShowBinding.ValueChangeItems.Add(Path.GetFileNameWithoutExtension(file.Name).Split('_')[1]);
+                }
+                ValueChangeDateComBox.SelectedIndex = 0;
+            }
+            catch
+            { }
+        }
+
+        /// <summary>
+        /// 初始化异常数据列表
+        /// </summary>
+        private void InitValueChangeItemsByMinTime(DateTime Mintime)
+        {
+            string folderPath = $"{AppDomain.CurrentDomain.BaseDirectory}DATA\\FaultMessage";
+            if (!Directory.Exists(folderPath))
+            {
+                // 创建文件夹
+                Directory.CreateDirectory(folderPath);
+            }
+            try
+            {
+                // 使用 DirectoryInfo 获取文件并按修改时间排序
+                DirectoryInfo dirInfo = new DirectoryInfo(folderPath);
+                FileInfo[] files = dirInfo.GetFiles("*.*", SearchOption.AllDirectories);
+
+                // 按照修改时间排序(最新的在前)
+                var sortedFiles = files.Where(f => f.CreationTime > Mintime).OrderByDescending(f => f.LastWriteTime).ToArray();
+                ShowMessageBus.ShowBinding.ValueChangeItems.Clear();
+                foreach (FileInfo file in sortedFiles)
+                {
+                    ShowMessageBus.ShowBinding.ValueChangeItems.Add(Path.GetFileNameWithoutExtension(file.Name).Split('_')[1]);
+                }
+                ValueChangeDateComBox.SelectedIndex = 0;
+            }
+            catch
+            { }
+        }
+
+        /// <summary>
+        /// 初始化异常数据列表
+        /// </summary>
+        private void InitValueChangeItemsByMaxTime(DateTime MaxTime)
+        {
+            string folderPath = $"{AppDomain.CurrentDomain.BaseDirectory}DATA\\FaultMessage";
+            if (!Directory.Exists(folderPath))
+            {
+                // 创建文件夹
+                Directory.CreateDirectory(folderPath);
+            }
+            try
+            {
+                // 使用 DirectoryInfo 获取文件并按修改时间排序
+                DirectoryInfo dirInfo = new DirectoryInfo(folderPath);
+                FileInfo[] files = dirInfo.GetFiles("*.*", SearchOption.AllDirectories);
+
+                // 按照修改时间排序(最新的在前)
+                var sortedFiles = files.Where(f => f.CreationTime < MaxTime.AddDays(1)).OrderByDescending(f => f.LastWriteTime).ToArray();
+                ShowMessageBus.ShowBinding.ValueChangeItems.Clear();
+                foreach (FileInfo file in sortedFiles)
+                {
+                    ShowMessageBus.ShowBinding.ValueChangeItems.Add(Path.GetFileNameWithoutExtension(file.Name).Split('_')[1]);
+                }
+                ValueChangeDateComBox.SelectedIndex = 0;
+            }
+            catch
+            { }
+        }
+
+        /// <summary>
+        /// 生成值更改记录PDF
+        /// </summary>
+        /// <returns></returns>
+        private string GenerateValueChangePDF()
+        {
+            string ValueChangeValue = ValueChangeDateComBox.SelectedItem.ToString();
+            errorMesSqliteData = new ErrorMesSqliteDataClass($"{AppDomain.CurrentDomain.BaseDirectory}DATA\\FaultMessage\\FaultMessage_{ValueChangeValue}.db");
+            var ValueChangeMess = errorMesSqliteData.GetValueChangeMessage();
+            List<string> ColSpan = new List<string>()
+            {
+                "信息类别",
+                "信息类型",
+                "错误信息",
+                "记录时间",
+                "操作员ID",
+            };
+            ValueChangeRecordClass.GetRecordLogo(Properties.Resources.Logo);
+            return ValueChangeRecordClass.ValueChangeRecordToPDFReColspan(ValueChangeMess, ColSpan);
+            //return ValueChangeRecordClass.ValueChangeRecordToPDF(ValueChangeMess);
+        }
+
+        /// <summary>
+        /// 初始化异常数据列表
+        /// </summary>
+        private void InitErrorMessage()
+        {
+            string folderPath = $"{AppDomain.CurrentDomain.BaseDirectory}DATA\\FaultMessage";
+            if (!Directory.Exists(folderPath))
+            {
+                // 创建文件夹
+                Directory.CreateDirectory(folderPath);
+            }
+            try
+            {
+                // 使用 DirectoryInfo 获取文件并按修改时间排序
+                DirectoryInfo dirInfo = new DirectoryInfo(folderPath);
+                FileInfo[] files = dirInfo.GetFiles("*.*", SearchOption.AllDirectories);
+
+                // 按照修改时间排序(最新的在前)
+                var sortedFiles = files.OrderByDescending(f => f.LastWriteTime).ToArray();
+                ShowMessageBus.ShowBinding.ErrorMessItems.Clear();
+                foreach (FileInfo file in sortedFiles)
+                {
+                    ShowMessageBus.ShowBinding.ErrorMessItems.Add(Path.GetFileNameWithoutExtension(file.Name).Split('_')[1]);
+                }
+                ErrorMessageDateComBox.SelectedIndex = 0;
+            }
+            catch
+            { }
+        }
+
+        /// <summary>
+        /// 初始化异常数据列表
+        /// </summary>
+        private void InitErrorMessage(DateTime Mintime, DateTime MaxTime)
+        {
+            string folderPath = $"{AppDomain.CurrentDomain.BaseDirectory}DATA\\FaultMessage";
+            if (!Directory.Exists(folderPath))
+            {
+                // 创建文件夹
+                Directory.CreateDirectory(folderPath);
+            }
+            try
+            {
+                // 使用 DirectoryInfo 获取文件并按修改时间排序
+                DirectoryInfo dirInfo = new DirectoryInfo(folderPath);
+                FileInfo[] files = dirInfo.GetFiles("*.*", SearchOption.AllDirectories);
+
+                // 按照修改时间排序(最新的在前)
+                var sortedFiles = files.Where(f => f.CreationTime > Mintime && f.CreationTime < MaxTime.AddDays(1)).OrderByDescending(f => f.LastWriteTime).ToArray();
+                ShowMessageBus.ShowBinding.ErrorMessItems.Clear();
+                foreach (FileInfo file in sortedFiles)
+                {
+                    ShowMessageBus.ShowBinding.ErrorMessItems.Add(Path.GetFileNameWithoutExtension(file.Name).Split('_')[1]);
+                }
+                ErrorMessageDateComBox.SelectedIndex = 0;
+            }
+            catch
+            { }
+        }
+
+        /// <summary>
+        /// 初始化异常数据列表
+        /// </summary>
+        private void InitErrorMessageByMinTime(DateTime Mintime)
+        {
+            string folderPath = $"{AppDomain.CurrentDomain.BaseDirectory}DATA\\FaultMessage";
+            if (!Directory.Exists(folderPath))
+            {
+                // 创建文件夹
+                Directory.CreateDirectory(folderPath);
+            }
+            try
+            {
+                // 使用 DirectoryInfo 获取文件并按修改时间排序
+                DirectoryInfo dirInfo = new DirectoryInfo(folderPath);
+                FileInfo[] files = dirInfo.GetFiles("*.*", SearchOption.AllDirectories);
+
+                // 按照修改时间排序(最新的在前)
+                var sortedFiles = files.Where(f => f.CreationTime > Mintime).OrderByDescending(f => f.LastWriteTime).ToArray();
+                ShowMessageBus.ShowBinding.ErrorMessItems.Clear();
+                foreach (FileInfo file in sortedFiles)
+                {
+                    ShowMessageBus.ShowBinding.ErrorMessItems.Add(Path.GetFileNameWithoutExtension(file.Name).Split('_')[1]);
+                }
+                ErrorMessageDateComBox.SelectedIndex = 0;
+            }
+            catch
+            { }
+        }
+
+        /// <summary>
+        /// 初始化异常数据列表
+        /// </summary>
+        private void InitErrorMessageByMaxTime(DateTime MaxTime)
+        {
+            string folderPath = $"{AppDomain.CurrentDomain.BaseDirectory}DATA\\FaultMessage";
+            if (!Directory.Exists(folderPath))
+            {
+                // 创建文件夹
+                Directory.CreateDirectory(folderPath);
+            }
+            try
+            {
+                // 使用 DirectoryInfo 获取文件并按修改时间排序
+                DirectoryInfo dirInfo = new DirectoryInfo(folderPath);
+                FileInfo[] files = dirInfo.GetFiles("*.*", SearchOption.AllDirectories);
+
+                // 按照修改时间排序(最新的在前)
+                var sortedFiles = files.Where(f => f.CreationTime < MaxTime.AddDays(1)).OrderByDescending(f => f.LastWriteTime).ToArray();
+                ShowMessageBus.ShowBinding.ErrorMessItems.Clear();
+                foreach (FileInfo file in sortedFiles)
+                {
+                    ShowMessageBus.ShowBinding.ErrorMessItems.Add(Path.GetFileNameWithoutExtension(file.Name).Split('_')[1]);
                 }
+                ErrorMessageDateComBox.SelectedIndex = 0;
             }
+            catch
+            { }
         }
 
-        private void test()
+        /// <summary>
+        /// 生成值更改记录PDF
+        /// </summary>
+        /// <returns></returns>
+        private string GenerateErrorMessagePDF()
         {
-            PDFGenerateTools pDFGenerate = new PDFGenerateTools($"{AppDomain.CurrentDomain.BaseDirectory}PDF\\report_with_images.pdf");
-            pDFGenerate.InsertText("工资单", 20, 3);
-            pDFGenerate.InsertNewLine();
-            pDFGenerate.InsertImage("D:\\work\\WindowsFormsTest\\PDFTest\\bin\\Debug\\mmexport1752891278116.jpg");
-            pDFGenerate.InsertNewLine();
-            pDFGenerate.InsertNewLine();
-            pDFGenerate.InsertText("员工列表", 12, 1);
-            pDFGenerate.SavePDF();
+            string ValueChangeValue = ErrorMessageDateComBox.SelectedItem.ToString();
+            errorMesSqliteData = new ErrorMesSqliteDataClass($"{AppDomain.CurrentDomain.BaseDirectory}DATA\\FaultMessage\\FaultMessage_{ValueChangeValue}.db");
+            var ValueChangeMess = errorMesSqliteData.GetErrorMessage();
+            List<string> ColSpan = new List<string>()
+            {
+                "信息类别",
+                "信息类型",
+                "错误信息",
+                "记录时间",
+                "操作员ID",
+            };
+            errorMessageRecordClass.GetRecordLogo(Properties.Resources.Logo);
+            return errorMessageRecordClass.ErrorMessageRecordToPDFReColspan(ValueChangeMess, ColSpan);
+            //return ValueChangeRecordClass.ValueChangeRecordToPDF(ValueChangeMess);
         }
+        #endregion
     }
 }

+ 2 - 2
CCDCountWpf/WpfPage/MainPage.xaml

@@ -49,7 +49,7 @@
                             </StackPanel>
                             <StackPanel Orientation="Horizontal">
                                 <Label  Content="装瓶数:" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" FontWeight="Bold" FontSize="20" Foreground="White"/>
-                                <Label  Content="{Binding AllNgNum}" HorizontalAlignment="Left" Margin="0,10,0,0" Width="80" FontWeight="Bold" FontSize="20" Background="{x:Null}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Foreground="White"/>
+                                <Label  Content="{Binding BottingCount}" HorizontalAlignment="Left" Margin="20,10,0,0" Width="80" FontWeight="Bold" FontSize="20" Background="{x:Null}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Foreground="White"/>
                             </StackPanel>
                         </StackPanel>
                         <Label x:Name="CamRunStaticLab" Content="{Binding CamRunStatic}" HorizontalAlignment="Right" Margin="10,5,10,0" VerticalAlignment="Top" Background="{x:Null}" FontSize="25" Foreground="{Binding CameraStaticColor}" FontWeight="Bold" />
@@ -89,7 +89,7 @@
                     Margin="5,75,5,0" Height="153" VerticalAlignment="Top">
                     <StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">
                         <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
-                            <TextBlock Text="生产批次:" FontSize="20" Margin="0,0,0,0" VerticalAlignment="Center" Foreground="White"/>
+                            <TextBlock Text="生产批次:" FontSize="20" Margin="0,0,20,0" VerticalAlignment="Center" Foreground="White"/>
                             <TextBox x:Name="BatchNumberTbx" Text="{Binding Source={x:Static BindNameSpace:ShowMessageBus.ShowBinding},Path = BatchNumber,Mode=TwoWay,UpdateSourceTrigger=LostFocus}" FontSize="16" Width="160" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Background="{x:Null}" Foreground="White" KeyDown="TextBox_KeyDown" Height="45"/>
                         </StackPanel>
                         <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,10,0,0">

+ 62 - 10
CCDCountWpf/WpfPage/MainPage.xaml.cs

@@ -1,17 +1,22 @@
 
 using CCDCount.DLL;
+using CCDCount.DLL.SqlDataClass;
+using CCDCount.MODEL.AuditTrailModel;
 using CCDCount.MODEL.ConfigModel;
 using LogClass;
 using MvCameraControl;
 using System;
+using System.Collections.Generic;
 using System.Diagnostics;
 using System.Drawing;
 using System.IO;
+using System.Linq;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Data;
+using System.Windows.Documents;
 using System.Windows.Input;
 using System.Windows.Interop;
 using System.Windows.Media;
@@ -135,6 +140,61 @@ namespace CCDCountWpf.WpfPage
             }
         }
 
+        private bool RunBatchIsRun =false;
+
+        /// <summary>
+        /// 运行批次记录
+        /// </summary>
+        /// <param name="BatchNumber"></param>
+        private void RunBatchRecord(string BatchNumber)
+        {
+            if (RunBatchIsRun)
+            {
+                return;
+            }
+            List<BatchRecordModel> batchRecordModels = new List<BatchRecordModel>();
+            Stopwatch stopwatch = new Stopwatch();
+            BatchMessSqliteDataClass batchMessSqliteData = new BatchMessSqliteDataClass($"{AppDomain.CurrentDomain.BaseDirectory}DATA\\BatchData\\BatchData_{BatchNumber}.db");
+            RunBatchIsRun = true;
+            Task.Run(() =>
+            {
+                while (RunBatchIsRun)
+                {
+                    stopwatch.Restart();
+                    DateTime RecordTime = DateTime.Now;
+                    var OutTimeBatch = batchRecordModels.Where(x => x.RecordTime.AddMinutes(1) < RecordTime).ToList();
+                    OutTimeBatch.ForEach(x => batchRecordModels.Remove(x));
+                    PlcSettingMessageBus.pLCManagement.ReadBottingVibrationTableHighSpeedValue(out ushort BottingVibrationTableHighSpeedValue, out ushort FilterVibrationTableHighSpeedValue, out ushort CountVibrationTableHighSpeedValue);
+                    PlcSettingMessageBus.pLCManagement.ReadBottingCount(out ushort BottingCount);
+                    ushort CountSPeed = (ushort)(batchRecordModels.Count() > 0 ? (BottingCount - batchRecordModels.Min(o => o.BottingCount)) > 0 ? BottingCount - batchRecordModels.Min(o => o.BottingCount) : 0 : 0);
+                    ShowMessageBus.ShowBinding.BottingSpeed = CountSPeed;
+                    BatchRecordModel batchRecordModel = new BatchRecordModel
+                    {
+                        BatchNunber = BatchNumber,
+                        MaterialCylinderVibrationTableSpeed = BottingVibrationTableHighSpeedValue,
+                        FilterVibrationTableSpeed = FilterVibrationTableHighSpeedValue,
+                        CountVibrationTableSpeed = CountVibrationTableHighSpeedValue,
+                        BottingCount = BottingCount,
+                        BottingSpeed = CountSPeed,
+                        RecordTime = RecordTime
+                    };
+                    batchMessSqliteData.InsertBatchMessage(batchRecordModel);
+                    batchRecordModels.Add(batchRecordModel);
+                    stopwatch.Stop();
+                    int SleepTime = 998 - (int)stopwatch.ElapsedMilliseconds;
+                    if(SleepTime > 0)
+                    {
+                        Thread.Sleep(SleepTime);
+                    }
+                }
+            });
+        }
+
+        private void StopBatchRecord()
+        {
+            RunBatchIsRun = false;
+        }
+
         private void StartIdentifyBtn_Click(object sender, RoutedEventArgs e)
         {
             if(ShowMessageBus.ShowBinding.BatchNumber == "")
@@ -142,6 +202,7 @@ namespace CCDCountWpf.WpfPage
                 MessageBox.Show("请输入批次号!");
                 return;
             }
+            RunBatchRecord(ShowMessageBus.ShowBinding.BatchNumber);
             RunCameraIdentify();
             StartIdentifyBtn.IsEnabled = false;
             StartIdentifyBtn.Opacity = 0.5;
@@ -156,6 +217,7 @@ namespace CCDCountWpf.WpfPage
         private void StopIdentifyBtn_Click(object sender, RoutedEventArgs e)
         {
             StopCameraIdentify();
+            StopBatchRecord();
             StartIdentifyBtn.IsEnabled = true;
             StartIdentifyBtn.Opacity = 1;
             StopIdentifyBtn.IsEnabled = false;
@@ -324,16 +386,6 @@ namespace CCDCountWpf.WpfPage
             }
         }
 
-        private void MyCombo_OnLoaded(object sender, RoutedEventArgs e)
-        {
-            var textbox = (TextBox)FormulationCoBox.Template.FindName("PART_EditableTextBox", FormulationCoBox);
-            if (textbox != null)
-            {
-                var parent = (Border)textbox.Parent;
-                parent.Background = new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#FF0087FF"));
-            }
-        }
-
         /// <summary>
         /// 初始化配方列表
         /// </summary>

+ 0 - 9
CCDCountWpf/packages.config

@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<packages>
-  <package id="EntityFramework" version="6.4.4" targetFramework="net48" />
-  <package id="Stub.System.Data.SQLite.Core.NetFramework" version="1.0.119.0" targetFramework="net48" />
-  <package id="System.Data.SQLite" version="1.0.119.0" targetFramework="net48" />
-  <package id="System.Data.SQLite.Core" version="1.0.119.0" targetFramework="net48" />
-  <package id="System.Data.SQLite.EF6" version="1.0.119.0" targetFramework="net48" />
-  <package id="System.Data.SQLite.Linq" version="1.0.119.0" targetFramework="net48" />
-</packages>

+ 69 - 0
TestWork.DLL/AuditTrail/BatchRecordClass.cs

@@ -0,0 +1,69 @@
+using CCDCount.DLL.SqlDataClass;
+using CCDCount.DLL.Tools;
+using CCDCount.MODEL.AuditTrailModel;
+using CCDCount.MODEL.ConfigModel;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace CCDCount.DLL.AuditTrail
+{
+    public class BatchRecordClass
+    {
+        private byte[] imageBytes = null;
+        public void GetRecordLogo(byte[] LogoPath)
+        {
+            imageBytes = LogoPath;
+        }
+        public string BatchRecordToPDF(List<BatchRecordModel> batchRecords) 
+        {
+            string SavePath = $"{AppDomain.CurrentDomain.BaseDirectory}PDF\\BatchRecord.pdf";
+            PDFGenerateTools pDFGenerate = new PDFGenerateTools(SavePath);
+            pDFGenerate.InsertText("批记录", 20, 3);
+            pDFGenerate.InsertNewLine();
+            if (imageBytes != null)
+            {
+                pDFGenerate.InsertImage(imageBytes);
+            }
+            pDFGenerate.InsertNewLine();
+            pDFGenerate.InsertTable(batchRecords, "批记录");
+            pDFGenerate.SavePDF();
+            return SavePath;
+        }
+
+        public string BatchRecordToPDFReColspan(List<BatchRecordModel> batchRecords,List<string> ColSpanNames)
+        {
+            string SavePath = $"{AppDomain.CurrentDomain.BaseDirectory}PDF\\BatchRecord.pdf";
+            PDFGenerateTools pDFGenerate = new PDFGenerateTools(SavePath);
+            pDFGenerate.InsertText("批记录", 20, 3);
+            pDFGenerate.InsertNewLine();
+            if (imageBytes != null)
+            {
+                pDFGenerate.InsertImage(imageBytes);
+            }
+            pDFGenerate.InsertNewLine();
+            pDFGenerate.InsertTable(batchRecords, ColSpanNames, "批记录");
+            pDFGenerate.SavePDF();
+            return SavePath;
+        }
+
+        public string BatchRecordToPDF(List<BatchRecordModel> batchRecords,string FileName)
+        {
+            string SavePath = $"{AppDomain.CurrentDomain.BaseDirectory}PDF\\{FileName}.pdf";
+            PDFGenerateTools pDFGenerate = new PDFGenerateTools(SavePath);
+            pDFGenerate.InsertText("批记录", 20, 3);
+            pDFGenerate.InsertNewLine();
+            if (imageBytes != null)
+            {
+                pDFGenerate.InsertImage(imageBytes);
+            }
+            pDFGenerate.InsertNewLine();
+            pDFGenerate.InsertTable(batchRecords, "批记录");
+            pDFGenerate.SavePDF();
+            return SavePath;
+        }
+    }
+}

+ 70 - 0
TestWork.DLL/AuditTrail/ErrorMessageRecordClass.cs

@@ -0,0 +1,70 @@
+using CCDCount.DLL.Tools;
+using CCDCount.MODEL.SqlDataModel;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CCDCount.DLL.AuditTrail
+{
+    public class ErrorMessageRecordClass
+    {
+        private byte[] imageBytes = null;
+        public void GetRecordLogo(byte[] LogoPath)
+        {
+            imageBytes = LogoPath;
+        }
+        public string ErrorMessageRecordToPDF(List<ErroeMesDataModelClass> ErrrorMes)
+        {
+            string SavePath = $"{AppDomain.CurrentDomain.BaseDirectory}PDF\\ErrorMessageRecord.pdf";
+            PDFGenerateTools pDFGenerate = new PDFGenerateTools(SavePath);
+            pDFGenerate.InsertText("异常记录", 20, 3);
+            pDFGenerate.InsertNewLine();
+            if (imageBytes != null)
+            {
+                pDFGenerate.InsertImage(imageBytes);
+            }
+            pDFGenerate.InsertNewLine();
+            pDFGenerate.InsertTable(ErrrorMes.Select(o =>
+            new { o.Category, o.MessageType, o.Message, o.DateTime, o.UserID }).ToList(), "异常记录");
+            pDFGenerate.SavePDF();
+            return SavePath;
+        }
+
+
+        public string ErrorMessageRecordToPDFReColspan(List<ErroeMesDataModelClass> ErrorMes, List<string> ColSpanNames)
+        {
+            string SavePath = $"{AppDomain.CurrentDomain.BaseDirectory}PDF\\ErrorMessageRecord.pdf";
+            PDFGenerateTools pDFGenerate = new PDFGenerateTools(SavePath);
+            pDFGenerate.InsertText("异常记录", 20, 3);
+            pDFGenerate.InsertNewLine();
+            if (imageBytes != null)
+            {
+                pDFGenerate.InsertImage(imageBytes);
+            }
+            pDFGenerate.InsertNewLine();
+            pDFGenerate.InsertTable(ErrorMes.Select(o =>
+            new { o.Category, o.MessageType, o.Message, o.DateTime, o.UserID }).ToList(), ColSpanNames, "异常记录");
+            pDFGenerate.SavePDF();
+            return SavePath;
+        }
+
+        public string ErrorMessageRecordToPDF(List<ErroeMesDataModelClass> ErrorMes, string FileName)
+        {
+            string SavePath = $"{AppDomain.CurrentDomain.BaseDirectory}PDF\\{FileName}.pdf";
+            PDFGenerateTools pDFGenerate = new PDFGenerateTools(SavePath);
+            pDFGenerate.InsertText("异常记录", 20, 3);
+            pDFGenerate.InsertNewLine();
+            if (imageBytes != null)
+            {
+                pDFGenerate.InsertImage(imageBytes);
+            }
+            pDFGenerate.InsertNewLine();
+            pDFGenerate.InsertTable(ErrorMes.Select(o =>
+            new { o.Category, o.MessageType, o.Message, o.DateTime, o.UserID }).ToList(), "异常记录");
+            pDFGenerate.SavePDF();
+            return SavePath;
+        }
+    }
+}

+ 67 - 0
TestWork.DLL/AuditTrail/FormulationRecordClass.cs

@@ -0,0 +1,67 @@
+using CCDCount.DLL.Tools;
+using CCDCount.MODEL.AuditTrailModel;
+using CCDCount.MODEL.ConfigModel;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CCDCount.DLL.AuditTrail
+{
+    public class FormulationRecordClass
+    {
+        private byte[] imageBytes = null;
+        public void GetRecordLogo(byte[] LogoPath)
+        {
+            imageBytes = LogoPath;
+        }
+        public string FormulationRecordToPDF(FormulationConfigClass FormulationRecords)
+        {
+            string SavePath = $"{AppDomain.CurrentDomain.BaseDirectory}PDF\\FormulationRecord.pdf";
+            PDFGenerateTools pDFGenerate = new PDFGenerateTools(SavePath);
+            pDFGenerate.InsertText("生产配方记录", 20, 3);
+            pDFGenerate.InsertNewLine();
+            if (imageBytes != null)
+            {
+                pDFGenerate.InsertImage(imageBytes);
+            }
+            pDFGenerate.InsertNewLine();
+            pDFGenerate.InsertTable(FormulationRecords, "生产配方记录");
+            pDFGenerate.SavePDF();
+            return SavePath;
+        }
+
+        public string FormulationRecordToPDFReRowspan(FormulationConfigClass FormulationRecords, List<string> RowSpanNames)
+        {
+            string SavePath = $"{AppDomain.CurrentDomain.BaseDirectory}PDF\\FormulationRecord.pdf";
+            PDFGenerateTools pDFGenerate = new PDFGenerateTools(SavePath);
+            pDFGenerate.InsertText("批记录", 20, 3);
+            pDFGenerate.InsertNewLine();
+            if (imageBytes != null)
+            {
+                pDFGenerate.InsertImage(imageBytes);
+            }
+            pDFGenerate.InsertNewLine();
+            pDFGenerate.InsertTable(FormulationRecords, RowSpanNames, "批记录");
+            pDFGenerate.SavePDF();
+            return SavePath;
+        }
+
+        public string FormulationRecordToPDF(FormulationConfigClass FormulationRecords, string FileName)
+        {
+            string SavePath = $"{AppDomain.CurrentDomain.BaseDirectory}PDF\\{FileName}.pdf";
+            PDFGenerateTools pDFGenerate = new PDFGenerateTools(SavePath);
+            pDFGenerate.InsertText("批记录", 20, 3);
+            pDFGenerate.InsertNewLine();
+            if (imageBytes != null)
+            {
+                pDFGenerate.InsertImage(imageBytes);
+            }
+            pDFGenerate.InsertNewLine();
+            pDFGenerate.InsertTable(FormulationRecords, "批记录");
+            pDFGenerate.SavePDF();
+            return SavePath;
+        }
+    }
+}

+ 71 - 0
TestWork.DLL/AuditTrail/ValueChangeRecordClass.cs

@@ -0,0 +1,71 @@
+using CCDCount.DLL.Tools;
+using CCDCount.MODEL.AuditTrailModel;
+using CCDCount.MODEL.SqlDataModel;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CCDCount.DLL.AuditTrail
+{
+    public class ValueChangeRecordClass
+    {
+        private byte[] imageBytes = null;
+        public void GetRecordLogo(byte[] LogoPath)
+        {
+            imageBytes = LogoPath;
+        }
+        public string ValueChangeRecordToPDF(List<ErroeMesDataModelClass> ErrrorMes)
+        {
+            string SavePath = $"{AppDomain.CurrentDomain.BaseDirectory}PDF\\ValueChangeRecord.pdf";
+            PDFGenerateTools pDFGenerate = new PDFGenerateTools(SavePath);
+            pDFGenerate.InsertText("值更改", 20, 3);
+            pDFGenerate.InsertNewLine();
+            if (imageBytes != null)
+            {
+                pDFGenerate.InsertImage(imageBytes);
+            }
+            pDFGenerate.InsertNewLine();
+            pDFGenerate.InsertTable(ErrrorMes.Select(o =>
+            new { o.Category, o.MessageType, o.Message, o.DateTime, o.UserID }).ToList(), "值更改");
+            pDFGenerate.SavePDF();
+            return SavePath;
+        }
+
+
+        public string ValueChangeRecordToPDFReColspan(List<ErroeMesDataModelClass> ErrorMes, List<string> ColSpanNames)
+        {
+            string SavePath = $"{AppDomain.CurrentDomain.BaseDirectory}PDF\\ValueChangeRecord.pdf";
+            PDFGenerateTools pDFGenerate = new PDFGenerateTools(SavePath);
+            pDFGenerate.InsertText("值更改", 20, 3);
+            pDFGenerate.InsertNewLine();
+            if (imageBytes != null)
+            {
+                pDFGenerate.InsertImage(imageBytes);
+            }
+            pDFGenerate.InsertNewLine();
+            pDFGenerate.InsertTable(ErrorMes.Select(o =>
+            new { o.Category, o.MessageType, o.Message, o.DateTime, o.UserID }).ToList(), ColSpanNames, "值更改");
+            pDFGenerate.SavePDF();
+            return SavePath;
+        }
+
+        public string ValueChangeRecordToPDF(List<ErroeMesDataModelClass> ErrorMes, string FileName)
+        {
+            string SavePath = $"{AppDomain.CurrentDomain.BaseDirectory}PDF\\{FileName}.pdf";
+            PDFGenerateTools pDFGenerate = new PDFGenerateTools(SavePath);
+            pDFGenerate.InsertText("值更改", 20, 3);
+            pDFGenerate.InsertNewLine();
+            if (imageBytes != null)
+            {
+                pDFGenerate.InsertImage(imageBytes);
+            }
+            pDFGenerate.InsertNewLine();
+            pDFGenerate.InsertTable(ErrorMes.Select(o =>
+            new { o.Category, o.MessageType, o.Message, o.DateTime, o.UserID }).ToList(), "值更改");
+            pDFGenerate.SavePDF();
+            return SavePath;
+        }
+    }
+}

+ 62 - 60
TestWork.DLL/CCDCount.DLL.csproj

@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
 <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <Import Project="..\packages\EntityFramework.6.4.4\build\EntityFramework.props" Condition="Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.props')" />
   <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -54,64 +53,16 @@
     <ErrorReport>prompt</ErrorReport>
   </PropertyGroup>
   <ItemGroup>
-    <Reference Include="BouncyCastle.Cryptography, Version=2.0.0.0, Culture=neutral, PublicKeyToken=072edcf4a5328938, processorArchitecture=MSIL">
-      <HintPath>..\packages\BouncyCastle.Cryptography.2.4.0\lib\net461\BouncyCastle.Cryptography.dll</HintPath>
-    </Reference>
-    <Reference Include="CsvHelper, Version=33.0.0.0, Culture=neutral, PublicKeyToken=8c4959082be5c823, processorArchitecture=MSIL">
-      <HintPath>..\packages\CsvHelper.33.0.1\lib\net48\CsvHelper.dll</HintPath>
-    </Reference>
-    <Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
-      <HintPath>..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.dll</HintPath>
-    </Reference>
-    <Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
-      <HintPath>..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.SqlServer.dll</HintPath>
-    </Reference>
-    <Reference Include="itextsharp, Version=5.5.13.4, Culture=neutral, PublicKeyToken=8354ae6d2174ddca, processorArchitecture=MSIL">
-      <HintPath>..\packages\iTextSharp.5.5.13.4\lib\net461\itextsharp.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
-      <HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Bcl.HashCode, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
-      <HintPath>..\packages\Microsoft.Bcl.HashCode.1.1.1\lib\net461\Microsoft.Bcl.HashCode.dll</HintPath>
-    </Reference>
     <Reference Include="MvCameraControl.Net, Version=4.5.0.2, Culture=neutral, PublicKeyToken=a3c7c5e3a730cd12, processorArchitecture=MSIL">
       <SpecificVersion>False</SpecificVersion>
       <HintPath>DLL\MvCameraControl.Net.dll</HintPath>
     </Reference>
-    <Reference Include="NModbus, Version=3.0.81.0, Culture=neutral, processorArchitecture=MSIL">
-      <HintPath>..\packages\NModbus.3.0.81\lib\net46\NModbus.dll</HintPath>
-    </Reference>
     <Reference Include="PresentationCore" />
     <Reference Include="System" />
-    <Reference Include="System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
-      <HintPath>..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll</HintPath>
-    </Reference>
     <Reference Include="System.ComponentModel.DataAnnotations" />
     <Reference Include="System.Core" />
-    <Reference Include="System.Data.SQLite, Version=1.0.119.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
-      <HintPath>..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.119.0\lib\net46\System.Data.SQLite.dll</HintPath>
-    </Reference>
-    <Reference Include="System.Data.SQLite.EF6, Version=1.0.119.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
-      <HintPath>..\packages\System.Data.SQLite.EF6.1.0.119.0\lib\net46\System.Data.SQLite.EF6.dll</HintPath>
-    </Reference>
-    <Reference Include="System.Data.SQLite.Linq, Version=1.0.119.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
-      <HintPath>..\packages\System.Data.SQLite.Linq.1.0.119.0\lib\net46\System.Data.SQLite.Linq.dll</HintPath>
-    </Reference>
     <Reference Include="System.Drawing" />
-    <Reference Include="System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
-      <HintPath>..\packages\System.Memory.4.5.0\lib\netstandard2.0\System.Memory.dll</HintPath>
-    </Reference>
     <Reference Include="System.Numerics" />
-    <Reference Include="System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
-      <HintPath>..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
-    </Reference>
-    <Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
-      <HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
-    </Reference>
-    <Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
-      <HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
-    </Reference>
     <Reference Include="System.Xml.Linq" />
     <Reference Include="System.Data.DataSetExtensions" />
     <Reference Include="Microsoft.CSharp" />
@@ -120,6 +71,10 @@
     <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="AuditTrail\BatchRecordClass.cs" />
+    <Compile Include="AuditTrail\ErrorMessageRecordClass.cs" />
+    <Compile Include="AuditTrail\FormulationRecordClass.cs" />
+    <Compile Include="AuditTrail\ValueChangeRecordClass.cs" />
     <Compile Include="BottingClass.cs" />
     <Compile Include="CameraClass.cs" />
     <Compile Include="Delta\DeltaClass.cs" />
@@ -132,6 +87,7 @@
       <DependentUpon>Resources.resx</DependentUpon>
     </Compile>
     <Compile Include="SqlDataClass\ActionMesSqliteDataClass.cs" />
+    <Compile Include="SqlDataClass\BatchMessSqliteDataClass.cs" />
     <Compile Include="SqlDataClass\UserMessSqliteDataClass.cs" />
     <Compile Include="Tools\IniFileClass.cs" />
     <Compile Include="Tools\LoadSplieImageClass.cs" />
@@ -164,7 +120,6 @@
   </ItemGroup>
   <ItemGroup>
     <None Include="app.config" />
-    <None Include="packages.config" />
   </ItemGroup>
   <ItemGroup>
     <EmbeddedResource Include="Properties\Resources.resx">
@@ -172,15 +127,62 @@
       <LastGenOutput>Resources.Designer.cs</LastGenOutput>
     </EmbeddedResource>
   </ItemGroup>
+  <ItemGroup>
+    <PackageReference Include="BouncyCastle.Cryptography">
+      <Version>2.4.0</Version>
+    </PackageReference>
+    <PackageReference Include="CsvHelper">
+      <Version>33.0.1</Version>
+    </PackageReference>
+    <PackageReference Include="EntityFramework">
+      <Version>6.4.4</Version>
+    </PackageReference>
+    <PackageReference Include="iTextSharp">
+      <Version>5.5.13.4</Version>
+    </PackageReference>
+    <PackageReference Include="Microsoft.Bcl.AsyncInterfaces">
+      <Version>8.0.0</Version>
+    </PackageReference>
+    <PackageReference Include="Microsoft.Bcl.HashCode">
+      <Version>1.1.1</Version>
+    </PackageReference>
+    <PackageReference Include="Microsoft.CSharp">
+      <Version>4.7.0</Version>
+    </PackageReference>
+    <PackageReference Include="NModbus">
+      <Version>3.0.81</Version>
+    </PackageReference>
+    <PackageReference Include="Stub.System.Data.SQLite.Core.NetFramework">
+      <Version>1.0.119</Version>
+    </PackageReference>
+    <PackageReference Include="System.Buffers">
+      <Version>4.4.0</Version>
+    </PackageReference>
+    <PackageReference Include="System.Data.SQLite">
+      <Version>1.0.119</Version>
+    </PackageReference>
+    <PackageReference Include="System.Data.SQLite.Core">
+      <Version>1.0.119</Version>
+    </PackageReference>
+    <PackageReference Include="System.Data.SQLite.EF6">
+      <Version>1.0.119</Version>
+    </PackageReference>
+    <PackageReference Include="System.Data.SQLite.Linq">
+      <Version>1.0.119</Version>
+    </PackageReference>
+    <PackageReference Include="System.Memory">
+      <Version>4.5.0</Version>
+    </PackageReference>
+    <PackageReference Include="System.Numerics.Vectors">
+      <Version>4.4.0</Version>
+    </PackageReference>
+    <PackageReference Include="System.Runtime.CompilerServices.Unsafe">
+      <Version>4.5.3</Version>
+    </PackageReference>
+    <PackageReference Include="System.Threading.Tasks.Extensions">
+      <Version>4.5.4</Version>
+    </PackageReference>
+  </ItemGroup>
+  <ItemGroup />
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
-  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
-    <PropertyGroup>
-      <ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
-    </PropertyGroup>
-    <Error Condition="!Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\EntityFramework.6.4.4\build\EntityFramework.props'))" />
-    <Error Condition="!Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\EntityFramework.6.4.4\build\EntityFramework.targets'))" />
-    <Error Condition="!Exists('..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.119.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.119.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets'))" />
-  </Target>
-  <Import Project="..\packages\EntityFramework.6.4.4\build\EntityFramework.targets" Condition="Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.targets')" />
-  <Import Project="..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.119.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets" Condition="Exists('..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.119.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets')" />
 </Project>

+ 1 - 1
TestWork.DLL/FaultLogClass.cs

@@ -13,7 +13,7 @@ namespace CCDCount.DLL
     {
         public static event Action<ErrorMesDataEventModelClass> FaultError;
         static ErrorMesSqliteDataClass errorMesSqliteDataClass = null;
-        static string dbPath = $"{AppDomain.CurrentDomain.BaseDirectory}DATA\\FaultMessage\\FaultMessage{DateTime.Now:yyyyMMdd}.db";
+        static string dbPath = $"{AppDomain.CurrentDomain.BaseDirectory}DATA\\FaultMessage\\FaultMessage_{DateTime.Now:yyyyMMdd}.db";
         static int userid = 0;
 
         static FaultLog()

+ 84 - 41
TestWork.DLL/PLCManagementClass.cs

@@ -837,49 +837,83 @@ namespace CCDCount.DLL
         public PlcParaModelClass ReadAllPara()
         {
             PlcParaModelClass result = null;
-            var results = modbusTcpClient.ReadHoldingRegisters(slaveId: 1, startAddress: 1110, numRegisters: 124);
-            if (results == null) return null;
+            var results = modbusTcpClient.ReadHoldingRegisters(slaveId: 1, startAddress: 1110, numRegisters: 124,out ushort[] ReturnValue);
+            if (ReturnValue == null) return null;
             result = new PlcParaModelClass()
             {
-                SpeedModeRunningSpeed = GetFloatFromRegisters(results.Take(2).ToArray()),
-                JogSpeed = GetFloatFromRegisters(results.Skip(4).Take(2).ToArray()),
-                BottValueSet = results[8],
-                TransferValveOpeningSpeed = GetFloatFromRegisters(results.Skip(12).Take(2).ToArray()),
-                TransferValveOpeningTime = GetInt32FromRegisters(results.Skip(16).Take(2).ToArray()),
-                BottingDecelerationValue = results[20],
-                CacheDecelerationValue = results[24],
-                CacheCountDelayTiming = GetInt32FromRegisters(results.Skip(28).Take(2).ToArray()),
-                CacheShutdownValue = results[32],
-                BottingMaterialCylinderVibrationTableHighSpeedValue = results[36],
-                BottingFilterVibrationTableHighSpeedValue = results[40],
-                BottingCountVibrationTableHighSpeedValue = results[44],
-                BottingMaterialCylinderVibrationTableDecelerationSpeedValue = results[48],
-                BottingFilterVibrationTableDecelerationSpeedValue = results[52],
-                BottingCountVibrationTableDecelerationSpeedValue = results[56],
-                CacheMaterialCylinderVibrationTableHighSpeedValue = results[60],
-                CacheFilterVibrationTableHighSpeedValue = results[64],
-                CacheCountVibrationTableHighSpeedValue = results[68],
-                CacheMaterialCylinderVibrationTableDecelerationSpeedValue = results[72],
-                CacheFilterVibrationTableDecelerationSpeedValue = results[76],
-                CacheCountVibrationTableDecelerationSpeedValue = results[80],
-                GateOpeningDelay = GetInt32FromRegisters(results.Skip(84).Take(2).ToArray()),
-                ReturnToZeroOffsetValue = GetFloatFromRegisters(results.Skip(88).Take(2).ToArray()),
-                ReturnToZeroOffsetSpeed = GetFloatFromRegisters(results.Skip(92).Take(2).ToArray()),
-                TransferValveClosingSpeed = GetFloatFromRegisters(results.Skip(96).Take(2).ToArray()),
-                TransferValveOpenPosition = GetFloatFromRegisters(results.Skip(100).Take(2).ToArray()),
-                TransferValveClosePosition = GetFloatFromRegisters(results.Skip(104).Take(2).ToArray()),
-                AirValveOpeningDelay = GetInt32FromRegisters(results.Skip(108).Take(2).ToArray()),
-                BottlingShutdownValue = results[120],
+                SpeedModeRunningSpeed = GetFloatFromRegisters(ReturnValue.Take(2).ToArray()),
+                JogSpeed = GetFloatFromRegisters(ReturnValue.Skip(4).Take(2).ToArray()),
+                BottValueSet = ReturnValue[8],
+                TransferValveOpeningSpeed = GetFloatFromRegisters(ReturnValue.Skip(12).Take(2).ToArray()),
+                TransferValveOpeningTime = GetInt32FromRegisters(ReturnValue.Skip(16).Take(2).ToArray()),
+                BottingDecelerationValue = ReturnValue[20],
+                CacheDecelerationValue = ReturnValue[24],
+                CacheCountDelayTiming = GetInt32FromRegisters(ReturnValue.Skip(28).Take(2).ToArray()),
+                CacheShutdownValue = ReturnValue[32],
+                BottingMaterialCylinderVibrationTableHighSpeedValue = ReturnValue[36],
+                BottingFilterVibrationTableHighSpeedValue = ReturnValue[40],
+                BottingCountVibrationTableHighSpeedValue = ReturnValue[44],
+                BottingMaterialCylinderVibrationTableDecelerationSpeedValue = ReturnValue[48],
+                BottingFilterVibrationTableDecelerationSpeedValue = ReturnValue[52],
+                BottingCountVibrationTableDecelerationSpeedValue = ReturnValue[56],
+                CacheMaterialCylinderVibrationTableHighSpeedValue = ReturnValue[60],
+                CacheFilterVibrationTableHighSpeedValue = ReturnValue[64],
+                CacheCountVibrationTableHighSpeedValue = ReturnValue[68],
+                CacheMaterialCylinderVibrationTableDecelerationSpeedValue = ReturnValue[72],
+                CacheFilterVibrationTableDecelerationSpeedValue = ReturnValue[76],
+                CacheCountVibrationTableDecelerationSpeedValue = ReturnValue[80],
+                GateOpeningDelay = GetInt32FromRegisters(ReturnValue.Skip(84).Take(2).ToArray()),
+                ReturnToZeroOffsetValue = GetFloatFromRegisters(ReturnValue.Skip(88).Take(2).ToArray()),
+                ReturnToZeroOffsetSpeed = GetFloatFromRegisters(ReturnValue.Skip(92).Take(2).ToArray()),
+                TransferValveClosingSpeed = GetFloatFromRegisters(ReturnValue.Skip(96).Take(2).ToArray()),
+                TransferValveOpenPosition = GetFloatFromRegisters(ReturnValue.Skip(100).Take(2).ToArray()),
+                TransferValveClosePosition = GetFloatFromRegisters(ReturnValue.Skip(104).Take(2).ToArray()),
+                AirValveOpeningDelay = GetInt32FromRegisters(ReturnValue.Skip(108).Take(2).ToArray()),
+                BottlingShutdownValue = ReturnValue[120],
             };
-            results = modbusTcpClient.ReadHoldingRegisters(slaveId: 1, startAddress: 1234, numRegisters: 36);
-            result.BottlingShutdownTime = GetInt32FromRegisters(results.Take(2).ToArray());
-            result.BottleFeedingWheelRunningSpeed = GetFloatFromRegisters(results.Skip(8).Take(2).ToArray());
-            result.BottleFeedingWheelJogRunningSpeed = GetFloatFromRegisters(results.Skip(12).Take(2).ToArray());
-            result.BottleFeedingWheelReturnToZeroOffsetValue = GetFloatFromRegisters(results.Skip(16).Take(2).ToArray());
-            result.BottleFeedingWheelReturnToZeroSpeed = GetFloatFromRegisters(results.Skip(20).Take(2).ToArray());
-            result.BottleFeedingWheelPositionLength = GetFloatFromRegisters(results.Skip(24).Take(2).ToArray());
-            result.BottleFeedingWheelPauseTime = GetInt32FromRegisters(results.Skip(28).Take(2).ToArray());
-            result.DelayBlanking = GetInt32FromRegisters(results.Skip(32).Take(2).ToArray());
+            results = modbusTcpClient.ReadHoldingRegisters(slaveId: 1, startAddress: 1234, numRegisters: 36,out ReturnValue);
+            result.BottlingShutdownTime = GetInt32FromRegisters(ReturnValue.Take(2).ToArray());
+            result.BottleFeedingWheelRunningSpeed = GetFloatFromRegisters(ReturnValue.Skip(8).Take(2).ToArray());
+            result.BottleFeedingWheelJogRunningSpeed = GetFloatFromRegisters(ReturnValue.Skip(12).Take(2).ToArray());
+            result.BottleFeedingWheelReturnToZeroOffsetValue = GetFloatFromRegisters(ReturnValue.Skip(16).Take(2).ToArray());
+            result.BottleFeedingWheelReturnToZeroSpeed = GetFloatFromRegisters(ReturnValue.Skip(20).Take(2).ToArray());
+            result.BottleFeedingWheelPositionLength = GetFloatFromRegisters(ReturnValue.Skip(24).Take(2).ToArray());
+            result.BottleFeedingWheelPauseTime = GetInt32FromRegisters(ReturnValue.Skip(28).Take(2).ToArray());
+            result.DelayBlanking = GetInt32FromRegisters(ReturnValue.Skip(32).Take(2).ToArray());
+            return result;
+        }
+
+        public bool ReadBottingVibrationTableHighSpeedValue(out ushort MaterialCylinderValue,out ushort FilterValue,out ushort CountValue)
+        {
+            bool result = false;
+            if(modbusTcpClient.ReadHoldingRegisters(1, 1146, 12,out ushort[] ReturnValue))
+            {
+                MaterialCylinderValue = ReturnValue[0];
+                FilterValue = ReturnValue[4];
+                CountValue = ReturnValue[8];
+                result = true;
+            }
+            else
+            {
+                MaterialCylinderValue = 0;
+                FilterValue = 0;
+                CountValue = 0;
+            }
+            return result;
+        }
+
+        public bool ReadBottingCount(out ushort Count)
+        {
+            bool result = false;
+            if(modbusTcpClient.ReadHoldingRegisters(1, 1269, 1,out ushort[] ReturnValue))//临时地址
+            {
+                Count = ReturnValue[0];
+                result = true;
+            }
+            else
+            {
+                Count = 0;
+            }
             return result;
         }
 
@@ -1054,7 +1088,16 @@ namespace CCDCount.DLL
         /// </summary>
         public ushort ReadValveJog()
         {
-            return modbusTcpClient.ReadHoldingRegisters(slaveId: 1, startAddress: 238, numRegisters: 1)[0];
+            ushort result = 0;
+            if (modbusTcpClient.ReadHoldingRegisters(slaveId: 1, startAddress: 238, numRegisters: 1, out ushort[] returnValue))
+            {
+                result = returnValue[0];
+            }
+            else
+            {
+                result = 0;
+            }
+            return result;
         }
     }
 }

+ 113 - 0
TestWork.DLL/SqlDataClass/BatchMessSqliteDataClass.cs

@@ -0,0 +1,113 @@
+using CCDCount.MODEL.AuditTrailModel;
+using CCDCount.MODEL.SqlDataModel;
+using System;
+using System.Collections.Generic;
+using System.Data.SQLite;
+using System.IO;
+
+namespace CCDCount.DLL.SqlDataClass
+{
+    public class BatchMessSqliteDataClass
+    {
+        private string DatabaseFile;
+        private readonly string _connectionString;
+        private object locker = new object();
+
+        public BatchMessSqliteDataClass(string dbPath)
+        {
+            DatabaseFile = dbPath;
+            _connectionString = $"Data Source={DatabaseFile};Version=3;" +
+                "Journal Mode=WAL;" +           // 使用WAL模式提高并发性
+                "Synchronous=Normal;" +         // 平衡性能和安全性
+                "Cache Size=10000;" +           // 增加缓存大小
+                "Pooling=true;" +               // 启用连接池
+                "Max Pool Size=100;";           // 设置最大连接池大小
+            string directoryPath = Path.GetDirectoryName(DatabaseFile);
+            if (!Directory.Exists(directoryPath))
+            {
+                // 创建文件夹
+                Directory.CreateDirectory(directoryPath);
+            }
+            InitializeDatabase();
+        }
+
+        // 初始化数据库和表
+        private void InitializeDatabase()
+        {
+            if (!File.Exists(DatabaseFile))
+            {
+                SQLiteConnection.CreateFile(DatabaseFile);
+            }
+
+            using (var conn = new SQLiteConnection(_connectionString))
+            {
+                conn.Open();
+                string createTableSql = @"
+                    CREATE TABLE IF NOT EXISTS BatchMessage (
+                        Id INTEGER PRIMARY KEY AUTOINCREMENT,
+                        BatchNunber TEXT NOT NULL,
+                        MaterialCylinderVibrationTableSpeed REAL NOT NULL,
+                        FilterVibrationTableSpeed REAL NOT NULL,
+                        CountVibrationTableSpeed REAL NOT NULL,
+                        BottingCount INTEGER NOT NULL,
+                        BottingSpeed INTEGER NOT NULL,
+                        RecordTime TEXT NOT NULL
+                )";
+                new SQLiteCommand(createTableSql, conn).ExecuteNonQuery();
+            }
+        }
+
+        // 插入数据
+        public void InsertBatchMessage(BatchRecordModel Message)
+        {
+            lock (locker)
+            {
+                using (var conn = new SQLiteConnection($"Data Source={DatabaseFile};Version=3;"))
+                {
+                    conn.Open();
+                    string sql = "INSERT INTO BatchMessage" +
+                        " (BatchNunber, MaterialCylinderVibrationTableSpeed, FilterVibrationTableSpeed,CountVibrationTableSpeed,BottingCount,BottingSpeed,RecordTime)" +
+                        " VALUES (@BatchNunber, @MaterialCylinderVibrationTableSpeed, @FilterVibrationTableSpeed,@CountVibrationTableSpeed, @BottingCount, @BottingSpeed,@RecordTime)";
+                    var cmd = new SQLiteCommand(sql, conn);
+                    cmd.Parameters.AddWithValue("@BatchNunber", Message.BatchNunber);
+                    cmd.Parameters.AddWithValue("@MaterialCylinderVibrationTableSpeed", Message.MaterialCylinderVibrationTableSpeed);
+                    cmd.Parameters.AddWithValue("@FilterVibrationTableSpeed", Message.FilterVibrationTableSpeed);
+                    cmd.Parameters.AddWithValue("@CountVibrationTableSpeed", Message.CountVibrationTableSpeed);
+                    cmd.Parameters.AddWithValue("@BottingCount", Message.BottingCount);
+                    cmd.Parameters.AddWithValue("@BottingSpeed", Message.BottingSpeed);
+                    cmd.Parameters.AddWithValue("@RecordTime", Message.RecordTime.ToString("yyyy-MM-dd HH:mm:ss.fff"));
+                    cmd.ExecuteNonQuery();
+                }
+            }
+        }
+
+        // 查询所有数据
+        public List<BatchRecordModel> GetAllBatchMessage()
+        {
+            var BatchS = new List<BatchRecordModel>();
+            using (var conn = new SQLiteConnection($"Data Source={DatabaseFile};Version=3;"))
+            {
+                conn.Open();
+                string sql = "SELECT * FROM BatchMessage";
+                var cmd = new SQLiteCommand(sql, conn);
+                using (SQLiteDataReader reader = cmd.ExecuteReader())
+                {
+                    while (reader.Read())
+                    {
+                        BatchS.Add(new BatchRecordModel
+                        {
+                            BatchNunber = reader["BatchNunber"].ToString(),
+                            MaterialCylinderVibrationTableSpeed = Convert.ToUInt16(reader["MaterialCylinderVibrationTableSpeed"]),
+                            FilterVibrationTableSpeed = Convert.ToUInt16(reader["FilterVibrationTableSpeed"]),
+                            CountVibrationTableSpeed = Convert.ToUInt16(reader["CountVibrationTableSpeed"]),
+                            BottingCount = Convert.ToInt32(reader["BottingCount"]),
+                            BottingSpeed = Convert.ToUInt16(reader["BottingSpeed"]),
+                            RecordTime = DateTime.Parse(reader["RecordTime"].ToString())
+                        });
+                    }
+                }
+            }
+            return BatchS;
+        }
+    }
+}

+ 17 - 13
TestWork.DLL/SqlDataClass/ErrorMesSqliteDataClass.cs

@@ -13,6 +13,8 @@ namespace CCDCount.DLL.SqlDataClass
     {
         private readonly string _dbPath;
 
+        private object locker = new object();
+
         public ErrorMesSqliteDataClass(string dbPath)
         {
             _dbPath = dbPath;
@@ -57,18 +59,21 @@ namespace CCDCount.DLL.SqlDataClass
         // 插入数据
         public void InsertErrMessage(ErroeMesDataModelClass Message)
         {
-            using (var conn = new SQLiteConnection($"Data Source={_dbPath};Version=3;"))
+            lock (locker)
             {
-                conn.Open();
-                string sql = "INSERT INTO ErrMessage (Number, Category, MessageType,Message,DateTime,UserID) VALUES (@Number, @Category, @MessageType,@Message, @DateTime, @UserID)";
-                var cmd = new SQLiteCommand(sql, conn);
-                cmd.Parameters.AddWithValue("@Number", Message.Number);
-                cmd.Parameters.AddWithValue("@Category", Message.Category);
-                cmd.Parameters.AddWithValue("@MessageType", Message.MessageType);
-                cmd.Parameters.AddWithValue("@Message", Message.Message);
-                cmd.Parameters.AddWithValue("@DateTime", Message.DateTime.ToString("yyyy-MM-dd HH:mm:ss.fff")); // 格式化为字符串
-                cmd.Parameters.AddWithValue("@UserID", Message.UserID);
-                cmd.ExecuteNonQuery();
+                using (var conn = new SQLiteConnection($"Data Source={_dbPath};Version=3;"))
+                {
+                    conn.Open();
+                    string sql = "INSERT INTO ErrMessage (Number, Category, MessageType,Message,DateTime,UserID) VALUES (@Number, @Category, @MessageType,@Message, @DateTime, @UserID)";
+                    var cmd = new SQLiteCommand(sql, conn);
+                    cmd.Parameters.AddWithValue("@Number", Message.Number);
+                    cmd.Parameters.AddWithValue("@Category", Message.Category);
+                    cmd.Parameters.AddWithValue("@MessageType", Message.MessageType);
+                    cmd.Parameters.AddWithValue("@Message", Message.Message);
+                    cmd.Parameters.AddWithValue("@DateTime", Message.DateTime.ToString("yyyy-MM-dd HH:mm:ss.fff")); // 格式化为字符串
+                    cmd.Parameters.AddWithValue("@UserID", Message.UserID);
+                    cmd.ExecuteNonQuery();
+                }
             }
         }
 
@@ -111,9 +116,8 @@ namespace CCDCount.DLL.SqlDataClass
             using (var conn = new SQLiteConnection($"Data Source={_dbPath};Version=3;"))
             {
                 conn.Open();
-                string sql = "SELECT * FROM ErrMessage WHERE MessageType = @MessageType";
+                string sql = "SELECT * FROM ErrMessage WHERE MessageType = '值变更'";
                 var cmd = new SQLiteCommand(sql, conn);
-                cmd.Parameters.AddWithValue("@MessageType", "值改变");
                 using (SQLiteDataReader reader = cmd.ExecuteReader())
                 {
                     while (reader.Read())

+ 35 - 31
TestWork.DLL/Tools/ModbusClass.cs

@@ -1,4 +1,4 @@
-using LogClass;
+ using LogClass;
 using NModbus;
 using System;
 using System.Net.Sockets;
@@ -77,7 +77,7 @@ namespace CCDCount.DLL.Tools
             bool result = false;
             if (_modbusMaster == null)
             {
-                FaultLog.RecordErrorMessage($"MainThreadClass-ReadCoilsRegister failed:未连接到服务器");
+                //FaultLog.RecordErrorMessage($"MainThreadClass-ReadCoilsRegister failed:未连接到服务器");
                 return false;
             }
             try
@@ -88,7 +88,7 @@ namespace CCDCount.DLL.Tools
             catch (Exception ex)
             {
                 Console.WriteLine($"读取线圈失败: {ex.Message}");
-                FaultLog.RecordErrorMessage($"MainThreadClass-ReadCoilsRegister-ReadCoilsRegister failed:{ex.Message}");
+                //FaultLog.RecordErrorMessage($"MainThreadClass-ReadCoilsRegister-ReadCoilsRegister failed:{ex.Message}");
                 result = false;
             }
             return result;
@@ -103,23 +103,27 @@ namespace CCDCount.DLL.Tools
         /// <param name="numRegisters"></param>
         /// <returns></returns>
         /// <exception cref="InvalidOperationException"></exception>
-        public ushort[] ReadHoldingRegisters(byte slaveId, ushort startAddress, ushort numRegisters)
+        public bool ReadHoldingRegisters(byte slaveId, ushort startAddress, ushort numRegisters,out ushort[] returnValue)
         {
+            bool result = false;
+            returnValue = null;
             if (_modbusMaster == null)
             {
-                FaultLog.RecordErrorMessage($"MainThreadClass-ReadHoldingRegistersAsReal failed:未连接到服务器");
-                return null;
+                //FaultLog.RecordErrorMessage($"MainThreadClass-ReadHoldingRegistersAsReal failed:未连接到服务器");
+                return false;
             }
             try
             {
-                return _modbusMaster.ReadHoldingRegisters(slaveId, startAddress, numRegisters);
+                returnValue = _modbusMaster.ReadHoldingRegisters(slaveId, startAddress, numRegisters);
+                result = true;
             }
             catch (Exception ex)
             {
                 Console.WriteLine($"读取保持寄存器失败: {ex.Message}");
-                FaultLog.RecordErrorMessage($"MainThreadClass-ReadHoldingRegisters-ReadHoldingRegisters failed:{ex.Message}");
-                return null;
+                //FaultLog.RecordErrorMessage($"MainThreadClass-ReadHoldingRegisters-ReadHoldingRegisters failed:{ex.Message}");
+                result = false;
             }
+            return result;
         }
 
         /// <summary>
@@ -133,7 +137,7 @@ namespace CCDCount.DLL.Tools
         {
             if (_modbusMaster == null) 
             {
-                FaultLog.RecordErrorMessage($"MainThreadClass-ReadHoldingRegistersAsReal failed:未连接到服务器");
+                //FaultLog.RecordErrorMessage($"MainThreadClass-ReadHoldingRegistersAsReal failed:未连接到服务器");
                 return null;
             }
 
@@ -165,7 +169,7 @@ namespace CCDCount.DLL.Tools
             catch (Exception ex)
             {
                 Console.WriteLine($"读取REAL值失败: {ex.Message}");
-                FaultLog.RecordErrorMessage($"MainThreadClass-ReadHoldingRegistersAsReal failed:{ex.Message}");
+                //FaultLog.RecordErrorMessage($"MainThreadClass-ReadHoldingRegistersAsReal failed:{ex.Message}");
                 return null;
             }
         }
@@ -182,7 +186,7 @@ namespace CCDCount.DLL.Tools
         {
             if (_modbusMaster == null)
             {
-                FaultLog.RecordErrorMessage($"MainThreadClass-ReadHoldingRegistersAsReal failed:未连接到服务器");
+                //FaultLog.RecordErrorMessage($"MainThreadClass-ReadHoldingRegistersAsReal failed:未连接到服务器");
                 return null;
             }
 
@@ -206,7 +210,7 @@ namespace CCDCount.DLL.Tools
             catch (Exception ex)
             {
                 Console.WriteLine($"读取REAL值失败: {ex.Message}");
-                FaultLog.RecordErrorMessage($"MainThreadClass-ReadHoldingRegistersAsReal failed:{ex.Message}");
+                //FaultLog.RecordErrorMessage($"MainThreadClass-ReadHoldingRegistersAsReal failed:{ex.Message}");
                 return null;
             }
         }
@@ -222,7 +226,7 @@ namespace CCDCount.DLL.Tools
         {
             if (_modbusMaster == null)
             {
-                FaultLog.RecordErrorMessage($"MainThreadClass-ReadHoldingRegistersAsInt32 failed:未连接到服务器");
+                //FaultLog.RecordErrorMessage($"MainThreadClass-ReadHoldingRegistersAsInt32 failed:未连接到服务器");
                 return null;
             }
 
@@ -249,7 +253,7 @@ namespace CCDCount.DLL.Tools
             }
             catch (Exception ex)
             {
-                Console.WriteLine($"读取Int32值失败: {ex.Message}");
+                //Console.WriteLine($"读取Int32值失败: {ex.Message}");
                 return null;
             }
         }
@@ -266,7 +270,7 @@ namespace CCDCount.DLL.Tools
             bool result = false;
             if (_modbusMaster == null)
             {
-                FaultLog.RecordErrorMessage($"MainThreadClass-WriteCoilsRegister failed:未连接到服务器");
+                //FaultLog.RecordErrorMessage($"MainThreadClass-WriteCoilsRegister failed:未连接到服务器");
                 result = false;
             }
             try
@@ -276,8 +280,8 @@ namespace CCDCount.DLL.Tools
             }
             catch (Exception ex)
             {
-                Console.WriteLine($"写入线圈失败: {ex.Message}");
-                FaultLog.RecordErrorMessage($"MainThreadClass-WriteCoilsRegister-WriteCoilsRegister failed:{ex.Message}");
+                //Console.WriteLine($"写入线圈失败: {ex.Message}");
+                //FaultLog.RecordErrorMessage($"MainThreadClass-WriteCoilsRegister-WriteCoilsRegister failed:{ex.Message}");
                 result = false;
             }
             return result;
@@ -295,7 +299,7 @@ namespace CCDCount.DLL.Tools
             bool result = false;
             if (_modbusMaster == null)
             {
-                FaultLog.RecordErrorMessage($"MainThreadClass-WriteSingleRegister failed:未连接到服务器");
+                //FaultLog.RecordErrorMessage($"MainThreadClass-WriteSingleRegister failed:未连接到服务器");
                 result = false;
                 return result;
             }
@@ -306,8 +310,8 @@ namespace CCDCount.DLL.Tools
             }
             catch (Exception ex)
             {
-                Console.WriteLine($"写入单个寄存器失败: {ex.Message}");
-                FaultLog.RecordErrorMessage($"MainThreadClass-WriteSingleRegister-WriteSingleRegister failed:{ex.Message}");
+                //Console.WriteLine($"写入单个寄存器失败: {ex.Message}");
+                //FaultLog.RecordErrorMessage($"MainThreadClass-WriteSingleRegister-WriteSingleRegister failed:{ex.Message}");
                 result = false;
             }
             return result;
@@ -325,7 +329,7 @@ namespace CCDCount.DLL.Tools
             bool result = false;
             if (_modbusMaster == null)
             {
-                FaultLog.RecordErrorMessage($"MainThreadClass-WriteMultipleRegisters failed:未连接到服务器");
+                //FaultLog.RecordErrorMessage($"MainThreadClass-WriteMultipleRegisters failed:未连接到服务器");
                 return false;
             }
             try
@@ -335,8 +339,8 @@ namespace CCDCount.DLL.Tools
             }
             catch (Exception ex)
             {
-                Console.WriteLine($"写入多个寄存器失败: {ex.Message}");
-                FaultLog.RecordErrorMessage($"MainThreadClass-WriteMultipleRegisters-WriteMultipleRegisters failed:{ex.Message}");
+                //Console.WriteLine($"写入多个寄存器失败: {ex.Message}");
+                //FaultLog.RecordErrorMessage($"MainThreadClass-WriteMultipleRegisters-WriteMultipleRegisters failed:{ex.Message}");
                 result = false;
             }
             return result;
@@ -354,7 +358,7 @@ namespace CCDCount.DLL.Tools
             bool result = false;
             if (_modbusMaster == null)
             {
-                FaultLog.RecordErrorMessage($"MainThreadClass-WriteSingleReal failed:未连接到服务器");
+                //FaultLog.RecordErrorMessage($"MainThreadClass-WriteSingleReal failed:未连接到服务器");
                 return false;
             }
             try
@@ -370,8 +374,8 @@ namespace CCDCount.DLL.Tools
             }
             catch (Exception ex)
             {
-                Console.WriteLine($"写入REAL值失败: {ex.Message}");
-                FaultLog.RecordErrorMessage($"MainThreadClass-WriteSingleReal failed:{ex.Message}");
+                //Console.WriteLine($"写入REAL值失败: {ex.Message}");
+                //FaultLog.RecordErrorMessage($"MainThreadClass-WriteSingleReal failed:{ex.Message}");
                 result = false;
             }
             return result;
@@ -389,12 +393,12 @@ namespace CCDCount.DLL.Tools
             bool result = false;
             if (_modbusMaster == null)
             {
-                FaultLog.RecordErrorMessage($"MainThreadClass-WriteMultipleReals failed:未连接到服务器");
+                //FaultLog.RecordErrorMessage($"MainThreadClass-WriteMultipleReals failed:未连接到服务器");
                 return false;
             }
             if (values == null || values.Length == 0)
             {
-                FaultLog.RecordLogMessage("写入多个REAL值到保持寄存器-值数组不能为空",0);
+                //FaultLog.RecordLogMessage("写入多个REAL值到保持寄存器-值数组不能为空",0);
                 return false;
             }
 
@@ -422,8 +426,8 @@ namespace CCDCount.DLL.Tools
             }
             catch (Exception ex)
             {
-                Console.WriteLine($"写入多个REAL值失败: {ex.Message}");
-                FaultLog.RecordErrorMessage($"MainThreadClass-WriteMultipleReals failed:{ex.Message}");
+                //Console.WriteLine($"写入多个REAL值失败: {ex.Message}");
+                //FaultLog.RecordErrorMessage($"MainThreadClass-WriteMultipleReals failed:{ex.Message}");
                 result = false;
             }
             return result;

+ 243 - 0
TestWork.DLL/Tools/PDFGenerateTools.cs

@@ -130,6 +130,85 @@ namespace CCDCount.DLL.Tools
             }
         }
 
+        /// <summary>
+        /// 插入图片
+        /// </summary>
+        /// <param name="imagePath">图片路径</param>
+        public void InsertImage(byte[] imageBytes)
+        {
+            if (IsSave)
+            {
+                return;
+            }
+            Font FontValue = new Font(baseFont, 12);
+            // 插入图片
+            try
+            {
+                Image img = Image.GetInstance(imageBytes);
+                img.ScaleToFit(500, 300);
+                img.Alignment = Element.ALIGN_CENTER;
+                document.Add(img);
+            }
+            catch (Exception ex)
+            {
+                document.Add(new Paragraph("图片加载失败: " + ex.Message));
+            }
+        }
+
+        /// <summary>
+        /// 插入图片
+        /// </summary>
+        /// <param name="imagePath">图片路径</param>
+        /// <param name="width">图片宽度</param>
+        /// <param name="height">图片高度</param>
+        public void InsertImage(string imagePath,float width,float height)
+        {
+            if (IsSave)
+            {
+                return;
+            }
+            Font FontValue = new Font(baseFont, 12);
+            // 插入图片
+            try
+            {
+                Image img = Image.GetInstance(imagePath);
+                img.ScaleToFit(width, height);
+                img.Alignment = Element.ALIGN_CENTER;
+                document.Add(img);
+            }
+            catch (Exception ex)
+            {
+                document.Add(new Paragraph("图片加载失败: " + ex.Message));
+            }
+        }
+
+        /// <summary>
+        /// 插入图片
+        /// </summary>
+        /// <param name="imagePath">图片路径</param>
+        /// <param name="width">图片宽度</param>
+        /// <param name="height">图片高度</param>
+        public void InsertImage(byte[] imageBytes, float width, float height)
+        {
+            if (IsSave)
+            {
+                return;
+            }
+            Font FontValue = new Font(baseFont, 12);
+            // 插入图片
+            try
+            {
+                Image img = Image.GetInstance(imageBytes);
+                img.ScaleToFit(width, height);
+                img.Alignment = Element.ALIGN_CENTER;
+                document.Add(img);
+            }
+            catch (Exception ex)
+            {
+                document.Add(new Paragraph("图片加载失败: " + ex.Message));
+            }
+        }
+
         /// <summary>
         /// 插入表格
         /// </summary>
@@ -182,6 +261,170 @@ namespace CCDCount.DLL.Tools
             document.Add(table);
         }
 
+        /// <summary>
+        /// 插入表格
+        /// </summary>
+        /// <param name="dataList">数据列表</param>
+        /// <param name="tableName">表名</param>
+        public void InsertTable<T>(List<T> dataList,List<string> Colspan,string tableName = "表头") where T : class
+        {
+            if (IsSave)
+            {
+                return;
+            }
+
+            if (dataList == null || dataList.Count == 0)
+            {
+                return; // 如果数据为空则直接返回
+            }
+
+            Font FontValue = new Font(baseFont, 12);
+
+            // 使用反射获取类的属性作为列
+            var properties = typeof(T).GetProperties();
+            if(properties.Length != Colspan.Count) { return; }
+            PdfPTable table = new PdfPTable(Colspan.Count);
+            table.WidthPercentage = 100; // 表格宽度为页面宽度的100%
+
+            // 添加表名作为表头(跨所有列)
+            PdfPCell cell = new PdfPCell(new Phrase(tableName, FontValue));
+            cell.Colspan = Colspan.Count;
+            cell.HorizontalAlignment = Element.ALIGN_CENTER;
+            table.AddCell(cell);
+
+            // 添加属性名作为列标题
+            foreach (var prop in Colspan)
+            {
+                PdfPCell headerCell = new PdfPCell(new Phrase(prop, FontValue));
+                headerCell.HorizontalAlignment = Element.ALIGN_CENTER;
+                table.AddCell(headerCell);
+            }
+
+            // 添加数据行
+            foreach (var data in dataList)
+            {
+                foreach (var prop in properties)
+                {
+                    var value = prop.GetValue(data)?.ToString() ?? "";
+                    table.AddCell(new Phrase(value, FontValue));
+                }
+            }
+
+            // 将表格添加到文档
+            document.Add(table);
+        }
+
+        /// <summary>
+        /// 插入表格
+        /// </summary>
+        /// <param name="dataList">数据列表</param>
+        /// <param name="tableName">表名</param>
+        public void InsertTable<T>(T data, string tableName = "表头") where T : class
+        {
+            if (IsSave)
+            {
+                return;
+            }
+
+            if (data == null)
+            {
+                return; // 如果数据为空则直接返回
+            }
+
+            Font FontValue = new Font(baseFont, 12);
+
+            // 使用反射获取类的属性作为列
+            var properties = typeof(T).GetProperties();
+            PdfPTable table = new PdfPTable(2);
+            table.WidthPercentage = 100; // 表格宽度为页面宽度的100%
+
+            // 添加表名作为表头(跨所有列)
+            PdfPCell cell = new PdfPCell(new Phrase(tableName, FontValue));
+            cell.Colspan = 2;
+            cell.HorizontalAlignment = Element.ALIGN_CENTER;
+            table.AddCell(cell);
+
+            PdfPCell headerCell1 = new PdfPCell(new Phrase("参数名", FontValue));
+            headerCell1.HorizontalAlignment = Element.ALIGN_CENTER;
+            table.AddCell(headerCell1);
+            PdfPCell headerCell2 = new PdfPCell(new Phrase("参数值", FontValue));
+            headerCell2.HorizontalAlignment = Element.ALIGN_CENTER;
+            table.AddCell(headerCell2);
+
+            //// 添加属性名作为列标题
+            foreach (var prop in properties)
+            {
+                PdfPCell headerCell = new PdfPCell(new Phrase(prop.Name, FontValue));
+                headerCell.HorizontalAlignment = Element.ALIGN_CENTER;
+                table.AddCell(headerCell);
+
+                var value = prop.GetValue(data)?.ToString() ?? "";
+                PdfPCell RowValueCell = new PdfPCell(new Phrase(value, FontValue));
+                RowValueCell.HorizontalAlignment = Element.ALIGN_CENTER;
+                table.AddCell(RowValueCell);
+            }
+
+            // 将表格添加到文档
+            document.Add(table);
+        }
+
+        /// <summary>
+        /// 插入表格
+        /// </summary>
+        /// <param name="dataList">数据列表</param>
+        /// <param name="tableName">表名</param>
+        public bool InsertTable<T>(T data, List<string> Rowspan, string tableName = "表头") where T : class
+        {
+            bool Result = false;
+            if (IsSave)
+            {
+                return false;
+            }
+
+            if (data == null)
+            {
+                return false; // 如果数据为空则直接返回
+            }
+
+            Font FontValue = new Font(baseFont, 12);
+
+            // 使用反射获取类的属性作为列
+            var properties = typeof(T).GetProperties();
+            PdfPTable table = new PdfPTable(2);
+            table.WidthPercentage = 100; // 表格宽度为页面宽度的100%
+
+            // 添加表名作为表头(跨所有列)
+            PdfPCell cell = new PdfPCell(new Phrase(tableName, FontValue));
+            cell.Colspan = 2;
+            cell.HorizontalAlignment = Element.ALIGN_CENTER;
+            table.AddCell(cell);
+
+            PdfPCell headerCell1 = new PdfPCell(new Phrase("参数名", FontValue));
+            headerCell1.HorizontalAlignment = Element.ALIGN_CENTER;
+            table.AddCell(headerCell1);
+            PdfPCell headerCell2 = new PdfPCell(new Phrase("参数值", FontValue));
+            headerCell2.HorizontalAlignment = Element.ALIGN_CENTER;
+            table.AddCell(headerCell2);
+
+            if (Rowspan.Count != properties.Length) { return false; }
+            for (int i=0;i<properties.Length;i++)
+            {
+                PdfPCell RowNameCell = new PdfPCell(new Phrase(Rowspan[i], FontValue));
+                RowNameCell.HorizontalAlignment = Element.ALIGN_CENTER;
+                table.AddCell(RowNameCell);
+
+                var value = properties[i].GetValue(data)?.ToString() ?? "";
+                PdfPCell RowValueCell = new PdfPCell(new Phrase(value, FontValue));
+                RowValueCell.HorizontalAlignment = Element.ALIGN_CENTER;
+                table.AddCell(RowValueCell);
+            }
+
+            // 将表格添加到文档
+            document.Add(table);
+            Result = true;
+            return Result;
+        }
+
         /// <summary>
         /// 插入空白行
         /// </summary>

+ 2 - 7
TestWork.DLL/app.config

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <configuration>
   <configSections>
-    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
+    
     <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
   </configSections>
   <runtime>
@@ -18,10 +18,5 @@
       <provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
     </providers>
   </entityFramework>
-  <system.data>
-    <DbProviderFactories>
-      <remove invariant="System.Data.SQLite.EF6" />
-      <add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" />
-    <remove invariant="System.Data.SQLite" /><add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" /></DbProviderFactories>
-  </system.data>
+  
 </configuration>

+ 0 - 21
TestWork.DLL/packages.config

@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<packages>
-  <package id="BouncyCastle.Cryptography" version="2.4.0" targetFramework="net48" />
-  <package id="CsvHelper" version="33.0.1" targetFramework="net48" />
-  <package id="EntityFramework" version="6.4.4" targetFramework="net48" />
-  <package id="iTextSharp" version="5.5.13.4" targetFramework="net48" />
-  <package id="Microsoft.Bcl.AsyncInterfaces" version="8.0.0" targetFramework="net48" />
-  <package id="Microsoft.Bcl.HashCode" version="1.1.1" targetFramework="net48" />
-  <package id="Microsoft.CSharp" version="4.7.0" targetFramework="net48" />
-  <package id="NModbus" version="3.0.81" targetFramework="net48" />
-  <package id="Stub.System.Data.SQLite.Core.NetFramework" version="1.0.119.0" targetFramework="net48" />
-  <package id="System.Buffers" version="4.4.0" targetFramework="net48" />
-  <package id="System.Data.SQLite" version="1.0.119.0" targetFramework="net48" />
-  <package id="System.Data.SQLite.Core" version="1.0.119.0" targetFramework="net48" />
-  <package id="System.Data.SQLite.EF6" version="1.0.119.0" targetFramework="net48" />
-  <package id="System.Data.SQLite.Linq" version="1.0.119.0" targetFramework="net48" />
-  <package id="System.Memory" version="4.5.0" targetFramework="net48" />
-  <package id="System.Numerics.Vectors" version="4.4.0" targetFramework="net48" />
-  <package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net48" />
-  <package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net48" />
-</packages>

+ 37 - 0
TestWork.MODEL/AuditTrailModel/BatchRecordModel.cs

@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CCDCount.MODEL.AuditTrailModel
+{
+    public class BatchRecordModel
+    {
+        public string BatchNunber { get; set; } 
+        /// <summary>
+        /// 料筒震盘速度
+        /// </summary>
+        public ushort MaterialCylinderVibrationTableSpeed { get; set; }
+        /// <summary>
+        /// 过滤震台速度
+        /// </summary>
+        public ushort FilterVibrationTableSpeed { get; set; }
+        /// <summary>
+        /// 计数震台速度
+        /// </summary>
+        public ushort CountVibrationTableSpeed { get; set; }
+        /// <summary>
+        /// 装瓶数量
+        /// </summary>
+        public int BottingCount { get; set; }
+        /// <summary>
+        /// 装瓶速度
+        /// </summary>
+        public ushort BottingSpeed { get; set; }
+        /// <summary>
+        /// 记录时间
+        /// </summary>
+        public DateTime RecordTime { get; set; }
+    }
+}

+ 1 - 0
TestWork.MODEL/CCDCount.MODEL.csproj

@@ -60,6 +60,7 @@
     <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="AuditTrailModel\BatchRecordModel.cs" />
     <Compile Include="CameraClass\CameraImageSizeClass.cs" />
     <Compile Include="CameraClass\CameraInfoClass.cs" />
     <Compile Include="ConfigModel\CamerasConfig.cs" />