浏览代码

20250919001 审计功能制作中,中途遇到了PDF预览问题,解决中,阶段性备份。

向羽 孟 7 月之前
父节点
当前提交
8aad74b85d

+ 28 - 0
CCDCount.sln

@@ -12,21 +12,49 @@ EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
+		Debug|x64 = Debug|x64
+		Debug|x86 = Debug|x86
 		Release|Any CPU = Release|Any CPU
+		Release|x64 = Release|x64
+		Release|x86 = Release|x86
 	EndGlobalSection
 	GlobalSection(ProjectConfigurationPlatforms) = postSolution
 		{E7F2647E-07D6-41F2-81FD-FA32DA6D2526}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{E7F2647E-07D6-41F2-81FD-FA32DA6D2526}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{E7F2647E-07D6-41F2-81FD-FA32DA6D2526}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{E7F2647E-07D6-41F2-81FD-FA32DA6D2526}.Debug|x64.Build.0 = Debug|Any CPU
+		{E7F2647E-07D6-41F2-81FD-FA32DA6D2526}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{E7F2647E-07D6-41F2-81FD-FA32DA6D2526}.Debug|x86.Build.0 = Debug|Any CPU
 		{E7F2647E-07D6-41F2-81FD-FA32DA6D2526}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{E7F2647E-07D6-41F2-81FD-FA32DA6D2526}.Release|Any CPU.Build.0 = Release|Any CPU
+		{E7F2647E-07D6-41F2-81FD-FA32DA6D2526}.Release|x64.ActiveCfg = Release|x64
+		{E7F2647E-07D6-41F2-81FD-FA32DA6D2526}.Release|x64.Build.0 = Release|x64
+		{E7F2647E-07D6-41F2-81FD-FA32DA6D2526}.Release|x86.ActiveCfg = Release|Any CPU
+		{E7F2647E-07D6-41F2-81FD-FA32DA6D2526}.Release|x86.Build.0 = Release|Any CPU
 		{C230B744-CABC-4B34-80BB-2CEE55A8B2B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{C230B744-CABC-4B34-80BB-2CEE55A8B2B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{C230B744-CABC-4B34-80BB-2CEE55A8B2B9}.Debug|x64.ActiveCfg = Debug|x64
+		{C230B744-CABC-4B34-80BB-2CEE55A8B2B9}.Debug|x64.Build.0 = Debug|x64
+		{C230B744-CABC-4B34-80BB-2CEE55A8B2B9}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{C230B744-CABC-4B34-80BB-2CEE55A8B2B9}.Debug|x86.Build.0 = Debug|Any CPU
 		{C230B744-CABC-4B34-80BB-2CEE55A8B2B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{C230B744-CABC-4B34-80BB-2CEE55A8B2B9}.Release|Any CPU.Build.0 = Release|Any CPU
+		{C230B744-CABC-4B34-80BB-2CEE55A8B2B9}.Release|x64.ActiveCfg = Release|x64
+		{C230B744-CABC-4B34-80BB-2CEE55A8B2B9}.Release|x64.Build.0 = Release|x64
+		{C230B744-CABC-4B34-80BB-2CEE55A8B2B9}.Release|x86.ActiveCfg = Release|Any CPU
+		{C230B744-CABC-4B34-80BB-2CEE55A8B2B9}.Release|x86.Build.0 = Release|Any CPU
 		{DCCBE504-5801-442E-A406-4A7099D46553}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{DCCBE504-5801-442E-A406-4A7099D46553}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{DCCBE504-5801-442E-A406-4A7099D46553}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{DCCBE504-5801-442E-A406-4A7099D46553}.Debug|x64.Build.0 = Debug|Any CPU
+		{DCCBE504-5801-442E-A406-4A7099D46553}.Debug|x86.ActiveCfg = Debug|x86
+		{DCCBE504-5801-442E-A406-4A7099D46553}.Debug|x86.Build.0 = Debug|x86
 		{DCCBE504-5801-442E-A406-4A7099D46553}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{DCCBE504-5801-442E-A406-4A7099D46553}.Release|Any CPU.Build.0 = Release|Any CPU
+		{DCCBE504-5801-442E-A406-4A7099D46553}.Release|x64.ActiveCfg = Release|Any CPU
+		{DCCBE504-5801-442E-A406-4A7099D46553}.Release|x64.Build.0 = Release|Any CPU
+		{DCCBE504-5801-442E-A406-4A7099D46553}.Release|x86.ActiveCfg = Release|x86
+		{DCCBE504-5801-442E-A406-4A7099D46553}.Release|x86.Build.0 = Release|x86
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

+ 29 - 0
CCDCountWpf/CCDCountWpf.csproj

@@ -41,6 +41,25 @@
   <PropertyGroup>
     <ApplicationIcon>23s6k-ono7l-001.ico</ApplicationIcon>
   </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
+    <DebugSymbols>true</DebugSymbols>
+    <OutputPath>bin\x86\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <DebugType>full</DebugType>
+    <PlatformTarget>x86</PlatformTarget>
+    <LangVersion>7.3</LangVersion>
+    <ErrorReport>prompt</ErrorReport>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
+    <OutputPath>bin\x86\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <Optimize>true</Optimize>
+    <DebugType>pdbonly</DebugType>
+    <PlatformTarget>x86</PlatformTarget>
+    <LangVersion>7.3</LangVersion>
+    <ErrorReport>prompt</ErrorReport>
+    <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>
@@ -101,6 +120,9 @@
     <Compile Include="WpfFrom\UserLoginWindow.xaml.cs">
       <DependentUpon>UserLoginWindow.xaml</DependentUpon>
     </Compile>
+    <Compile Include="WpfPage\AuditTrailPage.xaml.cs">
+      <DependentUpon>AuditTrailPage.xaml</DependentUpon>
+    </Compile>
     <Compile Include="WpfPage\HistoryDataPage.xaml.cs">
       <DependentUpon>HistoryDataPage.xaml</DependentUpon>
     </Compile>
@@ -135,6 +157,10 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="WpfPage\AuditTrailPage.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="WpfPage\HistoryDataPage.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
@@ -292,6 +318,9 @@
   <ItemGroup>
     <Resource Include="23s6k-ono7l-001.ico" />
   </ItemGroup>
+  <ItemGroup>
+    <Resource Include="FromImage\审计信息审计_白.png" />
+  </ItemGroup>
   <ItemGroup>
     <Resource Include="FromImage\操作_白.png" />
   </ItemGroup>

二进制
CCDCountWpf/FromImage/审计信息审计_白.png


二进制
CCDCountWpf/FromImage/操作_白.png


+ 2 - 0
CCDCountWpf/ShowBindingClass.cs

@@ -418,6 +418,8 @@ namespace CCDCountWpf
 
         public ObservableCollection<string> FormulationItems { get; } = new ObservableCollection<string>();
 
+        public ObservableCollection<string> BatchItems { get; } = new ObservableCollection<string>();
+
         /// <summary>
         /// 当前选择的相机SN
         /// </summary>

+ 6 - 0
CCDCountWpf/WpfFrom/MainWindow.xaml

@@ -64,6 +64,12 @@
                         <TextBlock Text="故障页面" FontSize="10" FontWeight="Bold" Margin="0,0,0,0" HorizontalAlignment="Center" Foreground="White" />
                     </StackPanel>
                 </Button>
+                <Button x:Name="AuditTrailShowBtn" HorizontalAlignment="Left" Height="60" Width="60" Background="{x:Null}" Click="AuditTrailShowBtn_Click">
+                    <StackPanel Orientation="Vertical" HorizontalAlignment="Center">
+                        <Image  Source="/FromImage/审计信息审计_白.png" Width="36" Height="36" />
+                        <TextBlock Text="审计追踪" FontSize="10" FontWeight="Bold" Margin="0,0,0,0" HorizontalAlignment="Center" Foreground="White" />
+                    </StackPanel>
+                </Button>
                 <Button x:Name="UserMessageBtn" HorizontalAlignment="Left" Height="60" Width="60" Background="{x:Null}" Click="UserMessageBtn_Click">
                     <StackPanel Orientation="Vertical" HorizontalAlignment="Center">
                         <Image  Source="/FromImage/用户管理_白.png" Width="32" Height="32" />

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

@@ -629,5 +629,11 @@ namespace CCDCountWpf
                 }
             }
         }
+
+        private void AuditTrailShowBtn_Click(object sender, RoutedEventArgs e)
+        {
+            ShowUri = new Uri("WpfPage\\AuditTrailPage.xaml", UriKind.Relative);
+            ShowFrame.Navigate(ShowUri);
+        }
     }
 }

+ 43 - 0
CCDCountWpf/WpfPage/AuditTrailPage.xaml

@@ -0,0 +1,43 @@
+<Page x:Class="CCDCountWpf.WpfPage.AuditTrailPage"
+      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+      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"
+      mc:Ignorable="d" 
+      d:DesignHeight="450" d:DesignWidth="800"
+      Title="AuditTrailPage">
+
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="40" />
+            <RowDefinition Height="*" />
+        </Grid.RowDefinitions>
+        <Grid Grid.Row="0">
+            <Grid.ColumnDefinitions>
+                <ColumnDefinition Width="*" />
+                <ColumnDefinition Width="*" />
+                <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>
+        </Grid>
+        <Grid Grid.Row="1">
+            <Grid x:Name="BatchRecordGrid" Visibility="Visible">
+                <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"/>
+            </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>

+ 197 - 0
CCDCountWpf/WpfPage/AuditTrailPage.xaml.cs

@@ -0,0 +1,197 @@
+using CCDCount.DLL.Tools;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Windows.Controls;
+
+
+namespace CCDCountWpf.WpfPage
+{
+    /// <summary>
+    /// AuditTrailPage.xaml 的交互逻辑
+    /// </summary>
+    public partial class AuditTrailPage : Page
+    {
+        public AuditTrailPage()
+        {
+            InitializeComponent();
+            this.Height = Double.NaN;
+            this.Width = Double.NaN;
+            DataContext = ShowMessageBus.ShowBinding;
+            InitBatchItems();
+            test();
+            string patch = $"{AppDomain.CurrentDomain.BaseDirectory}PDF\\report_with_images.pdf";
+            //BatchRecordWebBrowser.Navigate(new Uri(patch));
+        }
+        /// <summary>
+        /// 初始化配方列表
+        /// </summary>
+        private void InitBatchItems()
+        {
+            string folderPath = $"{AppDomain.CurrentDomain.BaseDirectory}DATA\\ActiveObjectData\\Cam{MessageBus.MainThreadS[0].cameraConfig.CamerNo}";
+            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.BatchItems.Clear();
+                foreach (FileInfo file in sortedFiles)
+                {
+                    ShowMessageBus.ShowBinding.BatchItems.Add(Path.GetFileNameWithoutExtension(file.Name).Split('_')[1]);
+                }
+                BatchNumComBox.SelectedIndex = 0;
+            }
+            catch
+            { }
+        }
+
+        /// <summary>
+        /// 初始化配方列表
+        /// </summary>
+        private void InitBatchItems(DateTime Mintime,DateTime MaxTime)
+        {
+            string folderPath = $"{AppDomain.CurrentDomain.BaseDirectory}DATA\\ActiveObjectData\\Cam{MessageBus.MainThreadS[0].cameraConfig.CamerNo}";
+            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.BatchItems.Clear();
+                foreach (FileInfo file in sortedFiles)
+                {
+                    ShowMessageBus.ShowBinding.BatchItems.Add(Path.GetFileNameWithoutExtension(file.Name).Split('_')[1]);
+                }
+                BatchNumComBox.SelectedIndex = 0;
+            }
+            catch
+            { }
+        }
+
+        /// <summary>
+        /// 初始化配方列表
+        /// </summary>
+        private void InitBatchItemsByMinTime(DateTime Mintime)
+        {
+            string folderPath = $"{AppDomain.CurrentDomain.BaseDirectory}DATA\\ActiveObjectData\\Cam{MessageBus.MainThreadS[0].cameraConfig.CamerNo}";
+            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.BatchItems.Clear();
+                foreach (FileInfo file in sortedFiles)
+                {
+                    ShowMessageBus.ShowBinding.BatchItems.Add(Path.GetFileNameWithoutExtension(file.Name).Split('_')[1]);
+                }
+                BatchNumComBox.SelectedIndex = 0;
+            }
+            catch
+            { }
+        }
+
+        /// <summary>
+        /// 初始化配方列表
+        /// </summary>
+        private void InitBatchItemsByMaxTime(DateTime MaxTime)
+        {
+            string folderPath = $"{AppDomain.CurrentDomain.BaseDirectory}DATA\\ActiveObjectData\\Cam{MessageBus.MainThreadS[0].cameraConfig.CamerNo}";
+            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.BatchItems.Clear();
+                foreach (FileInfo file in sortedFiles)
+                {
+                    ShowMessageBus.ShowBinding.BatchItems.Add(Path.GetFileNameWithoutExtension(file.Name).Split('_')[1]);
+                }
+                BatchNumComBox.SelectedIndex = 0;
+            }
+            catch
+            { }
+        }
+
+        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);
+                }
+            }
+        }
+
+        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);
+                }
+            }
+        }
+
+        private void test()
+        {
+            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();
+        }
+    }
+}

+ 1 - 1
CCDCountWpf/WpfPage/HistoryDataPage.xaml.cs

@@ -35,7 +35,7 @@ namespace CCDCountWpf.WpfPage
         {
             InitializeComponent();
             DataContext = ShowMessageBus.ShowBinding;
-            actionMesSqliteDataClass = new ActionMesSqliteDataClass($"{AppDomain.CurrentDomain.BaseDirectory}DATA\\ActiveObjectData\\Cam{MessageBus.MainThreadS[0].cameraConfig.CamerNo}\\ActiveObjectData{DateTime.Now:yyyyMMdd}.db");
+            actionMesSqliteDataClass = new ActionMesSqliteDataClass($"{AppDomain.CurrentDomain.BaseDirectory}DATA\\ActiveObjectData\\Cam{MessageBus.MainThreadS[0].cameraConfig.CamerNo}\\ActiveObjectData_{MessageBus.MainThreadS[0].BatchNumber}.db");
             //actionMesSqliteDataClass = new ActionMesSqliteDataClass($"{AppDomain.CurrentDomain.BaseDirectory}DATA\\ActiveObjectData\\Cam{MessageBus.MainThreadS[0].cameraConfig.CamerNo}\\ActiveObjectData20250827.db");
             actionMesSqliteDataClass.GetAllActionMinStartMaxEndLine(out int num, out int StartLine, out int EndLine);
             ShowMessageBus.ShowBinding.HistoryImageCount = (EndLine - StartLine)/PageHeight;

+ 26 - 0
TestWork.DLL/CCDCount.DLL.csproj

@@ -34,7 +34,29 @@
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+    <DebugSymbols>true</DebugSymbols>
+    <OutputPath>bin\x64\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <WarningLevel>5</WarningLevel>
+    <DebugType>full</DebugType>
+    <PlatformTarget>x64</PlatformTarget>
+    <LangVersion>7.3</LangVersion>
+    <ErrorReport>prompt</ErrorReport>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+    <OutputPath>bin\x64\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <Optimize>true</Optimize>
+    <DebugType>pdbonly</DebugType>
+    <PlatformTarget>x64</PlatformTarget>
+    <LangVersion>7.3</LangVersion>
+    <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>
@@ -44,6 +66,9 @@
     <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>
@@ -119,6 +144,7 @@
     <Compile Include="Tools\ModbusClass.cs" />
     <Compile Include="SqlDataClass\ErrorMesSqliteDataClass.cs" />
     <Compile Include="Tools\OnScreenKeyboardClass.cs" />
+    <Compile Include="Tools\PDFGenerateTools.cs" />
     <Compile Include="Tools\SystemMonitorClass.cs" />
     <Compile Include="Tools\XMLFileClass.cs" />
     <Compile Include="ZhengYunDong\Zmcaux.cs" />

+ 11 - 6
TestWork.DLL/MainThreadClass.cs

@@ -115,11 +115,6 @@ namespace CCDCount.DLL
 
             _IsOpenLoadThread = cameraConfig.IsOpenLoad;
             ThisCamerNo = cameraConfig.CamerNo;
-            actionMesSqliteDataClass = new ActionMesSqliteDataClass($"{AppDomain.CurrentDomain.BaseDirectory}DATA\\ActiveObjectData\\Cam{cameraConfig.CamerNo}\\ActiveObjectData{DateTime.Now:yyyyMMdd}.db");
-            //actionMesSqliteDataClass = new ActionMesSqliteDataClass($"{AppDomain.CurrentDomain.BaseDirectory}DATA\\ActiveObjectData\\Cam{cameraConfig.CamerNo}\\ActiveObjectData20250827.db");
-            actionMesSqliteDataClass.GetAllActionMinStartMaxEndLine(out int num, out int StartLine, out int EndLine);
-            shuLiClass.InitCurrentLine(EndLine);
-            //shuLiClass.InitNum(num);
         }
 
         /// <summary>
@@ -183,8 +178,18 @@ namespace CCDCount.DLL
             bool result = false;
             try
             {
+                if(BatchNumber=="")
+                {
+                    FaultLog.RecordErrorMessage($"{cameraConfig.CamerNo}号相机没有批次号,启动失败");
+                    return result;
+                }
+                actionMesSqliteDataClass = new ActionMesSqliteDataClass($"{AppDomain.CurrentDomain.BaseDirectory}DATA\\ActiveObjectData\\Cam{cameraConfig.CamerNo}\\ActiveObjectData_{BatchNumber}.db");
+                //actionMesSqliteDataClass = new ActionMesSqliteDataClass($"{AppDomain.CurrentDomain.BaseDirectory}DATA\\ActiveObjectData\\Cam{cameraConfig.CamerNo}\\ActiveObjectData20250827.db");
+                actionMesSqliteDataClass.GetAllActionMinStartMaxEndLine(out int num, out int StartLine, out int EndLine);
+                shuLiClass.InitCurrentLine(EndLine);
+                //shuLiClass.InitNum(num);
                 // 取图线程开启
-                if(!cameraClass.StartCamera())
+                if (!cameraClass.StartCamera())
                 {
                     return result;
                 }

+ 68 - 0
TestWork.DLL/SqlDataClass/ActionMesSqliteDataClass.cs

@@ -238,6 +238,74 @@ namespace CCDCount.DLL.SqlDataClass
             }
         }
 
+        public List<string> GetAllBatchNumber()
+        {
+            List<string> BatchNumbers = new List<string>();
+            using (var conn = new SQLiteConnection(_connectionString))
+            {
+                conn.Open();
+                const string query = @"SELECT DISTINCT BatchNumber FROM ActiveObject";
+
+                using (var cmd = new SQLiteCommand(query, conn))
+                {
+                    using (var reader = cmd.ExecuteReader())
+                    {
+                        while (reader.Read())
+                        {
+                            BatchNumbers.Add(reader["BatchNumber"].ToString());
+                        }
+                    }
+                }
+            }
+            return BatchNumbers;
+        }
+
+        public List<ActiveObjectClass> GetActiveObjectByBatchNumber(string BatchNumber)
+        {
+            List<ActiveObjectClass> activeObjects = new List<ActiveObjectClass>();
+            using (var conn = new SQLiteConnection(_connectionString))
+            {
+                conn.Open();
+                const string query = @"SELECT * FROM ActiveObject WHERE BatchNumber == @BatchNumber ORDER BY Id";
+
+                using (var cmd = new SQLiteCommand(query, conn))
+                {
+                    cmd.Parameters.AddWithValue("@BatchNumber", BatchNumber);
+
+                    using (var reader = cmd.ExecuteReader())
+                    {
+                        while (reader.Read())
+                        {
+                            object value = reader["Id"];
+                            if (!Convert.IsDBNull(value))
+                            {
+                                activeObjects.Add(new ActiveObjectClass()
+                                {
+                                    Num = Convert.ToInt32(reader["Num"]),
+                                    MinStartCol = Convert.ToInt32(reader["MinStartCol"]),
+                                    MaxEndCol = Convert.ToInt32(reader["MaxEndCol"]),
+                                    LastSeenLineStartCol = Convert.ToInt32(reader["LastSeenLineStartCol"]),
+                                    LastSeenLineEndCol = Convert.ToInt32(reader["LastSeenLineEndCol"]),
+                                    StartLine = Convert.ToInt64(reader["StartLine"]),
+                                    LastSeenLine = Convert.ToInt64(reader["LastSeenLine"]),
+                                    StartCheckTime = DateTime.Parse(reader["StartCheckTime"].ToString()),
+                                    EndCheckTime = DateTime.Parse(reader["EndCheckTime"].ToString()),
+                                    Area = Convert.ToInt32(reader["Area"]),
+                                    MaxLength = Convert.ToDouble(reader["MaxLength"]),
+                                    ChannelNO = Convert.ToInt32(reader["ChannelNO"]),
+                                    ImageWidth = Convert.ToInt32(reader["ImageWidth"]),
+                                    StateCode = Convert.ToInt32(reader["StateCode"]),
+                                    BatchNumber = reader["BatchNumber"].ToString(),
+                                });
+                            }
+                        }
+                    }
+                }
+            }
+            return activeObjects;
+        }
+
+        // 按页码获取数据
         public List<ActiveObjectClass> GetActiveObjectForPage(int StartLine, int EndLine)
         {
             List<ActiveObjectClass> activeObjects = new List<ActiveObjectClass>();

+ 101 - 0
TestWork.DLL/SqlDataClass/ErrorMesSqliteDataClass.cs

@@ -100,5 +100,106 @@ namespace CCDCount.DLL.SqlDataClass
             }
             return persons;
         }
+
+        /// <summary>
+        /// 获取值改变信息
+        /// </summary>
+        /// <returns></returns>
+        public List<ErroeMesDataModelClass> GetValueChangeMessage()
+        {
+            var persons = new List<ErroeMesDataModelClass>();
+            using (var conn = new SQLiteConnection($"Data Source={_dbPath};Version=3;"))
+            {
+                conn.Open();
+                string sql = "SELECT * FROM ErrMessage WHERE MessageType = @MessageType";
+                var cmd = new SQLiteCommand(sql, conn);
+                cmd.Parameters.AddWithValue("@MessageType", "值改变");
+                using (SQLiteDataReader reader = cmd.ExecuteReader())
+                {
+                    while (reader.Read())
+                    {
+                        persons.Add(new ErroeMesDataModelClass
+                        {
+                            Number = Convert.ToInt32(reader["Number"]),
+                            Category = reader["Category"].ToString(),
+                            MessageType = reader["MessageType"].ToString(),
+                            Message = reader["Message"].ToString(),
+                            UserID = Convert.ToInt32(reader["UserID"]),
+                            // 解析时间字符串
+                            DateTime = DateTime.Parse(reader["DateTime"].ToString())
+                        });
+                    }
+                }
+            }
+            return persons;
+        }
+
+        /// <summary>
+        /// 获取值改变信息
+        /// </summary>
+        /// <param name="UserID">操作员ID</param>
+        /// <returns></returns>
+        public List<ErroeMesDataModelClass> GetValueChangeMessage(int UserID)
+        {
+            var persons = new List<ErroeMesDataModelClass>();
+            using (var conn = new SQLiteConnection($"Data Source={_dbPath};Version=3;"))
+            {
+                conn.Open();
+                string sql = "SELECT * FROM ErrMessage WHERE MessageType = @MessageType AND UserID = @UserID";
+                var cmd = new SQLiteCommand(sql, conn);
+                cmd.Parameters.AddWithValue("@MessageType", "值改变");
+                cmd.Parameters.AddWithValue("@UserID", UserID);
+                using (SQLiteDataReader reader = cmd.ExecuteReader())
+                {
+                    while (reader.Read())
+                    {
+                        persons.Add(new ErroeMesDataModelClass
+                        {
+                            Number = Convert.ToInt32(reader["Number"]),
+                            Category = reader["Category"].ToString(),
+                            MessageType = reader["MessageType"].ToString(),
+                            Message = reader["Message"].ToString(),
+                            UserID = Convert.ToInt32(reader["UserID"]),
+                            // 解析时间字符串
+                            DateTime = DateTime.Parse(reader["DateTime"].ToString())
+                        });
+                    }
+                }
+            }
+            return persons;
+        }
+
+        /// <summary>
+        /// 获取异常信息
+        /// </summary>
+        /// <returns></returns>
+        public List<ErroeMesDataModelClass> GetErrorMessage()
+        {
+            var persons = new List<ErroeMesDataModelClass>();
+            using (var conn = new SQLiteConnection($"Data Source={_dbPath};Version=3;"))
+            {
+                conn.Open();
+                string sql = "SELECT * FROM ErrMessage WHERE MessageType = @MessageType";
+                var cmd = new SQLiteCommand(sql, conn);
+                cmd.Parameters.AddWithValue("@MessageType", "异常");
+                using (SQLiteDataReader reader = cmd.ExecuteReader())
+                {
+                    while (reader.Read())
+                    {
+                        persons.Add(new ErroeMesDataModelClass
+                        {
+                            Number = Convert.ToInt32(reader["Number"]),
+                            Category = reader["Category"].ToString(),
+                            MessageType = reader["MessageType"].ToString(),
+                            Message = reader["Message"].ToString(),
+                            UserID = Convert.ToInt32(reader["UserID"]),
+                            // 解析时间字符串
+                            DateTime = DateTime.Parse(reader["DateTime"].ToString())
+                        });
+                    }
+                }
+            }
+            return persons;
+        }
     }
 }

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

@@ -0,0 +1,206 @@
+using iTextSharp.text;
+using iTextSharp.text.pdf;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CCDCount.DLL.Tools
+{
+    public class PDFGenerateTools
+    {
+        /// <summary>
+        /// 是否保存标志量
+        /// </summary>
+        public bool IsSave = false;
+        /// <summary>
+        /// 文档对象
+        /// </summary>
+        private Document document = new Document(PageSize.A4);
+        /// <summary>
+        /// 字体位置
+        /// </summary>
+        string fontPath = @"C:\Windows\Fonts\MSYH.ttc,0";  // 微软雅黑
+        /// <summary>
+        /// 字体实例
+        /// </summary>
+        BaseFont baseFont = null;
+
+        /// <summary>
+        /// 构造函数
+        /// </summary>
+        /// <param name="outputPath">PDF生成位置</param>
+        public PDFGenerateTools(string outputPath)
+        {
+            PdfWriter.GetInstance(document, new FileStream(outputPath, FileMode.Create));
+            document.Open();
+            baseFont = BaseFont.CreateFont(fontPath, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
+        }
+
+        /// <summary>
+        /// 插入文本
+        /// </summary>
+        /// <param name="StrText">插入的文本</param>
+        public void InsertText(string StrText)
+        {
+            if (IsSave)
+            {
+                return;
+            }
+            Font FontValue = new Font(baseFont, 12);
+            Paragraph TextValue = new Paragraph(StrText, FontValue);
+            TextValue.Alignment = Element.ALIGN_CENTER;
+            document.Add(TextValue);
+        }
+
+        /// <summary>
+        /// 插入文本
+        /// </summary>
+        /// <param name="StrText">插入的文本</param>
+        /// <param name="FontSize">字体的字号</param>
+        public void InsertText(string StrText, int FontSize)
+        {
+            if (IsSave)
+            {
+                return;
+            }
+            Font FontValue = new Font(baseFont, FontSize);
+            Paragraph TextValue = new Paragraph(StrText, FontValue);
+            TextValue.Alignment = Element.ALIGN_CENTER;
+            document.Add(TextValue);
+        }
+
+        /// <summary>
+        /// 插入文本
+        /// </summary>
+        /// <param name="StrText">插入的文本</param>
+        /// <param name="FontSize">字体的字号</param>
+        /// <param name="Alignment">对齐方式</param>
+        public void InsertText(string StrText, int FontSize, int Alignment)
+        {
+            if (IsSave)
+            {
+                return;
+            }
+            Font FontValue = new Font(baseFont, FontSize);
+            Paragraph TextValue = new Paragraph(StrText, FontValue);
+            if (Alignment == 1)
+            {
+                TextValue.Alignment = Element.ALIGN_LEFT;
+            }
+            else if (Alignment == 2)
+            {
+                TextValue.Alignment = Element.ALIGN_RIGHT;
+            }
+            else if (Alignment == 3)
+            {
+                TextValue.Alignment = Element.ALIGN_CENTER;
+            }
+            else
+            {
+                Console.WriteLine("未定义对齐方式");
+            }
+            document.Add(TextValue);
+        }
+
+        /// <summary>
+        /// 插入图片
+        /// </summary>
+        /// <param name="imagePath">图片路径</param>
+        public void InsertImage(string imagePath)
+        {
+            if (IsSave)
+            {
+                return;
+            }
+            Font FontValue = new Font(baseFont, 12);
+            // 插入图片
+            try
+            {
+                Image img = Image.GetInstance(imagePath);
+                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="dataList">数据列表</param>
+        /// <param name="tableName">表名</param>
+        public void InsertTable<T>(List<T> dataList, 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();
+            PdfPTable table = new PdfPTable(properties.Length);
+            table.WidthPercentage = 100; // 表格宽度为页面宽度的100%
+
+            // 添加表名作为表头(跨所有列)
+            PdfPCell cell = new PdfPCell(new Phrase(tableName, FontValue));
+            cell.Colspan = properties.Length;
+            cell.HorizontalAlignment = Element.ALIGN_CENTER;
+            table.AddCell(cell);
+
+            // 添加属性名作为列标题
+            foreach (var prop in properties)
+            {
+                PdfPCell headerCell = new PdfPCell(new Phrase(prop.Name, 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>
+        public void InsertNewLine()
+        {
+            if (IsSave)
+            {
+                return;
+            }
+            document.Add(Chunk.NEWLINE);
+        }
+
+        /// <summary>
+        /// 保存PDF文件
+        /// </summary>
+        public void SavePDF()
+        {
+            document.Close();
+            IsSave = true;
+        }
+    }
+}

+ 2 - 0
TestWork.DLL/packages.config

@@ -1,7 +1,9 @@
 <?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" />

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

@@ -31,6 +31,24 @@
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+    <DebugSymbols>true</DebugSymbols>
+    <OutputPath>bin\x64\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <DebugType>full</DebugType>
+    <PlatformTarget>x64</PlatformTarget>
+    <LangVersion>7.3</LangVersion>
+    <ErrorReport>prompt</ErrorReport>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+    <OutputPath>bin\x64\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <Optimize>true</Optimize>
+    <DebugType>pdbonly</DebugType>
+    <PlatformTarget>x64</PlatformTarget>
+    <LangVersion>7.3</LangVersion>
+    <ErrorReport>prompt</ErrorReport>
+  </PropertyGroup>
   <ItemGroup>
     <Reference Include="System" />
     <Reference Include="System.Core" />