|
@@ -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();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|