Browse Source

Add datetime filter.

Justin 1 year ago
parent
commit
5f881e5787

+ 14 - 14
StationProbe/Database.cs

@@ -61,9 +61,9 @@ namespace StationProbe
             _db.Update(batchTask);
         }
 
-        public Exam[] GetExams(int batchTaskId, int page)
+        public Exam[] GetExams(int batchTaskId, int page, DateTime start, DateTime end)
         {
-            return _db.Table<Exam>().Where(x => x.BatchTaskId == batchTaskId && x.PageIndex == page).OrderBy(x => x.Id).ToArray();
+            return _db.Table<Exam>().Where(x => x.BatchTaskId == batchTaskId && x.PageIndex == page && x.CreateTime >= start && x.CreateTime <= end).OrderBy(x => x.Id).ToArray();
         }
 
         public Image[] GetImages(string examId)
@@ -71,16 +71,16 @@ namespace StationProbe
             return _db.Table<Image>().Where(x => x.ExamId == examId).OrderBy(x => x.ImageIndex).ToArray();
         }
 
-        public Exam? GetLastExam(int batchTaskId)
+        public Exam? GetLastExam(int batchTaskId, DateTime start, DateTime end)
         {
-            return _db.Table<Exam>().Where(x => x.BatchTaskId == batchTaskId).OrderByDescending(x => x.ExamIndex).FirstOrDefault();
+            return _db.Table<Exam>().Where(x => x.BatchTaskId == batchTaskId && x.CreateTime >= start && x.CreateTime <= end).OrderByDescending(x => x.ExamIndex).FirstOrDefault();
         }
 
-        public int GetPageCount(int batchTaskId, string part, string conclusion)
+        public int GetPageCount(int batchTaskId, string part, string conclusion, DateTime start, DateTime end)
         {
             if (!string.IsNullOrEmpty(part) && !string.IsNullOrEmpty(conclusion))
             {
-                var examCount = _db.Table<Exam>().Count(x => x.BatchTaskId == batchTaskId && x.Report.Contains(part) && x.Report.Contains(conclusion));
+                var examCount = _db.Table<Exam>().Count(x => x.BatchTaskId == batchTaskId && x.Report.Contains(part) && x.Report.Contains(conclusion) && x.CreateTime >= start && x.CreateTime <= end);
                 if(examCount < 15)
                 {
                     return 1;
@@ -95,7 +95,7 @@ namespace StationProbe
             }
             else if (!string.IsNullOrEmpty(part))
             {
-                var examCount = _db.Table<Exam>().Count(x => x.BatchTaskId == batchTaskId && x.Report.Contains(part));
+                var examCount = _db.Table<Exam>().Count(x => x.BatchTaskId == batchTaskId && x.Report.Contains(part) && x.CreateTime >= start && x.CreateTime <= end);
                 if (examCount < 15)
                 {
                     return 1;
@@ -111,7 +111,7 @@ namespace StationProbe
             }
             else if (!string.IsNullOrEmpty(conclusion))
             {
-                var examCount = _db.Table<Exam>().Count(x => x.BatchTaskId == batchTaskId && x.Report.Contains(conclusion));
+                var examCount = _db.Table<Exam>().Count(x => x.BatchTaskId == batchTaskId && x.Report.Contains(conclusion) && x.CreateTime >= start && x.CreateTime <= end);
                 if (examCount < 15)
                 {
                     return 1;
@@ -127,7 +127,7 @@ namespace StationProbe
             }
             else
             {
-                var lastExam = GetLastExam(batchTaskId);
+                var lastExam = GetLastExam(batchTaskId, start, end);
                 if(lastExam != null)
                 {
                     return lastExam.PageIndex + 1;
@@ -137,23 +137,23 @@ namespace StationProbe
         }
 
 
-        public Exam[] GetExams(int batchTaskId, int page, string part, string conclusion)
+        public Exam[] GetExams(int batchTaskId, int page, string part, string conclusion, DateTime start, DateTime end)
         {
             if (!string.IsNullOrEmpty(part) && !string.IsNullOrEmpty(conclusion))
             {
-                return _db.Table<Exam>().Where(x => x.BatchTaskId == batchTaskId && x.Report.Contains(part) && x.Report.Contains(conclusion)).OrderBy(x => x.Id).Skip(15 * page).Take(15).ToArray();
+                return _db.Table<Exam>().Where(x => x.BatchTaskId == batchTaskId && x.Report.Contains(part) && x.Report.Contains(conclusion) && x.CreateTime >= start && x.CreateTime <= end).OrderBy(x => x.Id).Skip(15 * page).Take(15).ToArray();
             }
             else if (!string.IsNullOrEmpty(part))
             {
-                return _db.Table<Exam>().Where(x => x.BatchTaskId == batchTaskId && x.Report.Contains(part)).OrderBy(x => x.Id).Skip(15 * page).Take(15).ToArray();
+                return _db.Table<Exam>().Where(x => x.BatchTaskId == batchTaskId && x.Report.Contains(part) && x.CreateTime >= start && x.CreateTime <= end).OrderBy(x => x.Id).Skip(15 * page).Take(15).ToArray();
             }
             else if (!string.IsNullOrEmpty(conclusion))
             {
-                return _db.Table<Exam>().Where(x => x.BatchTaskId == batchTaskId && x.Report.Contains(conclusion)).OrderBy(x => x.Id).Skip(15 * page).Take(15).ToArray();
+                return _db.Table<Exam>().Where(x => x.BatchTaskId == batchTaskId && x.Report.Contains(conclusion) && x.CreateTime >= start && x.CreateTime <= end).OrderBy(x => x.Id).Skip(15 * page).Take(15).ToArray();
             }
             else
             {
-                return GetExams(batchTaskId, page);
+                return GetExams(batchTaskId, page, start, end);
             }
         }
 

+ 1 - 1
StationProbe/Entities.cs

@@ -15,7 +15,7 @@ namespace StationProbe
         [Indexed]
         public int ImageIndex { get; set; }
 
-        public byte[] Data { get; set; } = new byte[0];
+        public byte[] Data { get; set; } = Array.Empty<byte>();
 
         public DateTime CreateTime { get; set; }
     }

+ 1 - 1
StationProbe/SuperImageTask.cs

@@ -24,7 +24,7 @@ namespace StationProbe
 
         public Exam? GetLastExam(int batchTaskId)
         {
-            return _db.GetLastExam(batchTaskId);
+            return _db.GetLastExam(batchTaskId, DateTime.MinValue, DateTime.MaxValue);
         }
 
         public void UpdateBatchTask(BatchTask batchTask)

+ 6 - 2
TestViewer/App.xaml

@@ -1,9 +1,13 @@
 <Application x:Class="TestViewer.App"
              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-             xmlns:local="clr-namespace:TestViewer"
              StartupUri="MainWindow.xaml">
     <Application.Resources>
-         
+        <ResourceDictionary>
+            <ResourceDictionary.MergedDictionaries>
+                <ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/SkinDefault.xaml"/>
+                <ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Theme.xaml"/>
+            </ResourceDictionary.MergedDictionaries>
+        </ResourceDictionary>
     </Application.Resources>
 </Application>

+ 2 - 6
TestViewer/Loading.cs

@@ -1,15 +1,11 @@
 using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
 using System.Threading.Tasks;
-using System.Windows.Threading;
 
 namespace TestViewer
 {
     internal class Loading
     {
-        public static event EventHandler<bool> LoadingChanged;
+        public static event EventHandler<bool>? LoadingChanged;
 
         public static void Run(Action action)
         {
@@ -24,7 +20,7 @@ namespace TestViewer
                 {
                     LoadingChanged?.Invoke(null, false);
                 }
-             });
+            });
         }
     }
 }

+ 21 - 16
TestViewer/MainWindow.xaml

@@ -3,6 +3,7 @@
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+        xmlns:stationProbe="clr-namespace:StationProbe"
         mc:Ignorable="d"
         Title="Exam Database TestViewer" Height="450" Width="800" WindowStartupLocation="CenterScreen" WindowState="Maximized">
     <Grid>
@@ -23,32 +24,32 @@
             <ComboBox Grid.Row="0" x:Name="BatchTaskList" VerticalContentAlignment="Center"/>
             <ListBox Grid.Row="1" x:Name="ExamList" HorizontalContentAlignment="Stretch">
                 <ListBox.ItemTemplate>
-                    <DataTemplate DataType="Exam">
+                    <DataTemplate DataType="{x:Type stationProbe:Exam}">
                         <Border Height="64" BorderBrush="Gray" Background="White" BorderThickness="1" CornerRadius="4">
                             <StackPanel Margin="8">
                                 <StackPanel Orientation="Horizontal">
                                     <StackPanel Orientation="Horizontal">
-                                        <TextBlock Text="姓名: " FontWeight="Bold"/>
+                                        <TextBlock Text="姓名: " FontWeight="Bold" Foreground="Black"/>
                                         <TextBlock Text="{Binding PatientName}" Foreground="Blue"/>
                                     </StackPanel>
                                     <TextBlock Text="   "/>
                                     <StackPanel Orientation="Horizontal">
-                                        <TextBlock Text="性别: " FontWeight="Bold"/>
-                                        <TextBlock Text="{Binding PatientSex}"/>
+                                        <TextBlock Text="性别: " FontWeight="Bold" Foreground="Black"/>
+                                        <TextBlock Text="{Binding PatientSex}" Foreground="Black"/>
                                     </StackPanel>
                                     <TextBlock Text="   "/>
                                     <StackPanel Orientation="Horizontal">
-                                        <TextBlock Text="年龄: " FontWeight="Bold"/>
-                                        <TextBlock Text="{Binding PatientAge}"/>
+                                        <TextBlock Text="年龄: " FontWeight="Bold" Foreground="Black"/>
+                                        <TextBlock Text="{Binding PatientAge}" Foreground="Black"/>
                                     </StackPanel>
                                 </StackPanel>
                                 <StackPanel Orientation="Horizontal">
-                                    <TextBlock Text="检查日期: " FontWeight="Bold"/>
-                                    <TextBlock Text="{Binding ExamDate,StringFormat='{} {0:yyyy-MM-dd HH:mm:ss}'}"/>
+                                    <TextBlock Text="检查日期: " FontWeight="Bold" Foreground="Black"/>
+                                    <TextBlock Text="{Binding ExamDate,StringFormat='{} {0:yyyy-MM-dd HH:mm:ss}'}" Foreground="Black"/>
                                 </StackPanel>
                                 <StackPanel Orientation="Horizontal">
-                                    <TextBlock Text="创建日期: " FontWeight="Bold"/>
-                                    <TextBlock Text="{Binding CreateTime,StringFormat='{} {0:yyyy-MM-dd HH:mm:ss}'}"/>
+                                    <TextBlock Text="创建日期: " FontWeight="Bold" Foreground="Black"/>
+                                    <TextBlock Text="{Binding CreateTime,StringFormat='{} {0:yyyy-MM-dd HH:mm:ss}'}" Foreground="Black"/>
                                 </StackPanel>
                             </StackPanel>
                         </Border>
@@ -56,12 +57,12 @@
                 </ListBox.ItemTemplate>
             </ListBox>
             <UniformGrid Grid.Row="2" Columns="3">
-                <Button Margin="2" Content="&lt;" Click="OnPreviousPageClick"/>
+                <Button Content="&lt;" Click="OnPreviousPageClick" HorizontalAlignment="Left" Width="48"/>
                 <TextBlock x:Name="PageIndex" Text="1" VerticalAlignment="Center" HorizontalAlignment="Center"/>
-                <Button Margin="2" Content=">" Click="OnNextPageClick"/>
+                <Button Content=">" Click="OnNextPageClick" HorizontalAlignment="Right" Width="48"/>
             </UniformGrid>
         </Grid>
-        <ScrollViewer x:Name="ExamControllScrollView" Grid.Column="1" >
+        <ScrollViewer x:Name="ExamScrollView" Grid.Row="0" Grid.Column="1" >
             <WrapPanel x:Name="ExamContent" Orientation="Horizontal"/>
         </ScrollViewer>
         <StackPanel Orientation="Horizontal" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2">
@@ -69,11 +70,15 @@
             <TextBox x:Name="PartKey" VerticalAlignment="Center" Width="128" FontSize="16"/>
             <TextBlock VerticalAlignment="Center" Margin="4" Text="结论:" Width="40" FontSize="16"/>
             <TextBox x:Name="ConclusionKey" VerticalAlignment="Center" Width="128" FontSize="16"/>
-            <Button Margin="4" VerticalAlignment="Center" Width="48" Content="查询" FontSize="16" Click="OnSearchClick"/>
-            <Button Margin="4" VerticalAlignment="Center" Width="48" Content="导出" FontSize="16" Click="OnExportClick"/>
+            <TextBlock VerticalAlignment="Center" Margin="4" Text="创建开始时间:" Width="100" FontSize="16"/>
+            <DatePicker x:Name="CreateStart" VerticalAlignment="Center" Width="140" FontSize="16" VerticalContentAlignment="Center"/>
+            <TextBlock VerticalAlignment="Center" Margin="4" Text="创建结束时间:" Width="100" FontSize="16"/>
+            <DatePicker x:Name="CreateEnd" VerticalAlignment="Center" Width="140" FontSize="16" VerticalContentAlignment="Center"/>
+            <Button Margin="4" VerticalAlignment="Center" Width="64" Content="查询" FontSize="14" Click="OnSearchClick"/>
+            <Button Margin="4" VerticalAlignment="Center" Width="64" Content="导出" FontSize="14" Click="OnExportClick"/>
         </StackPanel>
         <Border Height="1" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Top" Background="Gray"/>
-        <Grid x:Name="LoadingMask" Grid.Row="0" Grid.RowSpan="3" Grid.Column="0" Grid.ColumnSpan="2" Visibility="Collapsed">
+        <Grid x:Name="LoadingMask" Grid.Row="0" Grid.RowSpan="2" Grid.Column="0" Grid.ColumnSpan="2" Visibility="Collapsed">
             <Border Background="Gray" Opacity="0.5"/>
             <TextBlock Text="加载中..." FontSize="32" FontWeight="Bold" VerticalAlignment="Center" HorizontalAlignment="Center"/>
         </Grid>

+ 174 - 176
TestViewer/MainWindow.xaml.cs

@@ -6,35 +6,43 @@ using System.IO;
 using System.Text.Encodings.Web;
 using System.Text.Json;
 using System.Text.Unicode;
-using System.Threading;
 using System.Threading.Tasks;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Input;
 using System.Windows.Media;
 using System.Windows.Media.Imaging;
-using System.Windows.Threading;
 
 namespace TestViewer
 {
     /// <summary>
     /// Interaction logic for MainWindow.xaml
     /// </summary>
-    public partial class MainWindow : Window
+    public partial class MainWindow
     {
-        private readonly Database _db;
+        private readonly Database? _db;
+        private DateTime _startDate = new(2023, 1, 1);
+        private DateTime _endDate = DateTime.Now;
         private int _pageIndex = -1;
-        private int _pageCount = 0;
+        private int _pageCount;
         private string _partKey = string.Empty;
         private string _conclusionKey = string.Empty;
 
         public MainWindow()
         {
             InitializeComponent();
+            CreateStart.SelectedDate = _startDate;
+            CreateStart.DisplayDate = _startDate;
+            CreateEnd.SelectedDate = _endDate;
+            CreateEnd.DisplayDate = _endDate;
+            CreateStart.SelectedDateChanged += (_, _) => { _startDate = CreateStart.SelectedDate.Value.Date; };
+            CreateEnd.SelectedDateChanged += (_, _) => { _endDate = CreateEnd.SelectedDate.Value.Date.AddDays(1); };
             Loading.LoadingChanged += OnLoadingChanged;
-            var fileDialog = new OpenFileDialog();
-            fileDialog.Title = "Open database file";
-            fileDialog.Filter = "*.db|*.db";
+            var fileDialog = new OpenFileDialog
+            {
+                Title = "Open database file",
+                Filter = "*.db|*.db"
+            };
             if (fileDialog.ShowDialog() == true)
             {
                 _db = new Database(fileDialog.FileName);
@@ -67,14 +75,13 @@ namespace TestViewer
 
         private void OnBatchTaskSelectionChanged(object sender, SelectionChangedEventArgs e)
         {
-            var batchTask = BatchTaskList.SelectedValue as BatchTask;
-            if (batchTask != null)
+            if (BatchTaskList.SelectedValue is BatchTask batchTask)
             {
                 Loading.Run(() =>
                 {
                     _pageIndex = 0;
-                    _pageCount = _db.GetPageCount(batchTask.Id, _partKey, _conclusionKey);
-                    var exams = _db.GetExams(batchTask.Id, _pageIndex, _partKey, _conclusionKey);
+                    _pageCount = _db!.GetPageCount(batchTask.Id, _partKey, _conclusionKey,_startDate, _endDate);
+                    var exams = _db.GetExams(batchTask.Id, _pageIndex, _partKey, _conclusionKey, _startDate, _endDate);
                     Dispatcher.Invoke(() =>
                     {
                         foreach (var exam in exams)
@@ -89,171 +96,167 @@ namespace TestViewer
 
         private void OnExamSelectionChanged(object sender, SelectionChangedEventArgs e)
         {
-            ExamControllScrollView.ScrollToHome();
+            ExamScrollView.ScrollToHome();
             ExamContent.Children.Clear();
-            if (ExamList.SelectedValue != null)
+            if (ExamList.SelectedValue is Exam exam)
             {
-                var exam = ExamList.SelectedValue as Exam;
-                if (exam != null)
+                Dictionary<string, string>? reportContent;
+                try
                 {
-                    Dictionary<string, string>? reportContent = null;
-                    try
-                    {
-                        reportContent = JsonSerializer.Deserialize<Dictionary<string, string>>(exam.Report);
-                    }
-                    catch
+                    reportContent = JsonSerializer.Deserialize<Dictionary<string, string>>(exam.Report);
+                }
+                catch
+                {
+                    reportContent = null;
+                }
+                if (reportContent != null)
+                {
+                    var partStackPanel = new StackPanel() { Margin = new Thickness(16), Orientation = Orientation.Horizontal };
+                    partStackPanel.Children.Add(new TextBlock()
                     {
-                        reportContent = null;
-                    }
-                    if (reportContent != null)
+                        VerticalAlignment = VerticalAlignment.Center,
+                        Text = "部位: ",
+                        FontWeight = FontWeights.Bold,
+                        FontSize = 16,
+                    });
+                    partStackPanel.Children.Add(new TextBlock()
                     {
-                        var partStackPanel = new StackPanel() { Margin = new Thickness(16), Orientation = Orientation.Horizontal };
-                        partStackPanel.Children.Add(new TextBlock()
-                        {
-                            VerticalAlignment = VerticalAlignment.Center,
-                            Text = "部位: ",
-                            FontWeight = FontWeights.Bold,
-                            FontSize = 16,
-                        });
-                        partStackPanel.Children.Add(new TextBlock()
-                        {
-                            VerticalAlignment = VerticalAlignment.Center,
-                            Text = $"{reportContent["Part"]}",
-                            FontSize = 16,
-                        });
-                        ExamContent.Children.Add(partStackPanel);
+                        VerticalAlignment = VerticalAlignment.Center,
+                        Text = $"{reportContent["Part"]}",
+                        FontSize = 16,
+                    });
+                    ExamContent.Children.Add(partStackPanel);
 
-                        var deviceStackPanel = new StackPanel() { Margin = new Thickness(16), Orientation = Orientation.Horizontal };
-                        deviceStackPanel.Children.Add(new TextBlock()
-                        {
-                            VerticalAlignment = VerticalAlignment.Center,
-                            Text = "设备: ",
-                            FontWeight = FontWeights.Bold,
-                            FontSize = 16,
-                        });
-                        deviceStackPanel.Children.Add(new TextBlock()
-                        {
-                            VerticalAlignment = VerticalAlignment.Center,
-                            Text = $"{reportContent["Device"]}",
-                            FontSize = 16,
-                        });
-                        ExamContent.Children.Add(deviceStackPanel);
+                    var deviceStackPanel = new StackPanel() { Margin = new Thickness(16), Orientation = Orientation.Horizontal };
+                    deviceStackPanel.Children.Add(new TextBlock()
+                    {
+                        VerticalAlignment = VerticalAlignment.Center,
+                        Text = "设备: ",
+                        FontWeight = FontWeights.Bold,
+                        FontSize = 16,
+                    });
+                    deviceStackPanel.Children.Add(new TextBlock()
+                    {
+                        VerticalAlignment = VerticalAlignment.Center,
+                        Text = $"{reportContent["Device"]}",
+                        FontSize = 16,
+                    });
+                    ExamContent.Children.Add(deviceStackPanel);
 
-                        var conclusionStackPanel = new StackPanel() { Margin = new Thickness(16), Orientation = Orientation.Horizontal };
-                        conclusionStackPanel.Children.Add(new TextBlock()
-                        {
-                            VerticalAlignment = VerticalAlignment.Center,
-                            Text = "结论: ",
-                            FontWeight = FontWeights.Bold,
-                            FontSize = 16,
-                        });
-                        var conclusion = "无结论";
-                        if (!string.IsNullOrEmpty(reportContent["Conclusion"]))
-                        {
-                            conclusion = reportContent["Conclusion"];
-                        }
-                        conclusionStackPanel.Children.Add(new TextBlock()
-                        {
-                            VerticalAlignment = VerticalAlignment.Center,
-                            Text = conclusion,
-                            FontSize = 16,
-                        });
-                        ExamContent.Children.Add(conclusionStackPanel);
+                    var conclusionStackPanel = new StackPanel() { Margin = new Thickness(16), Orientation = Orientation.Horizontal };
+                    conclusionStackPanel.Children.Add(new TextBlock()
+                    {
+                        VerticalAlignment = VerticalAlignment.Center,
+                        Text = "结论: ",
+                        FontWeight = FontWeights.Bold,
+                        FontSize = 16,
+                    });
+                    var conclusion = "无结论";
+                    if (!string.IsNullOrEmpty(reportContent["Conclusion"]))
+                    {
+                        conclusion = reportContent["Conclusion"];
+                    }
+                    conclusionStackPanel.Children.Add(new TextBlock()
+                    {
+                        VerticalAlignment = VerticalAlignment.Center,
+                        Text = conclusion,
+                        FontSize = 16,
+                    });
+                    ExamContent.Children.Add(conclusionStackPanel);
 
-                        ExamContent.Children.Add(new Border() { Height = 1, Width = 2000, BorderBrush = Brushes.Gray, Background = Brushes.Gray });
+                    ExamContent.Children.Add(new Border() { Height = 1, Width = 2000, BorderBrush = Brushes.Gray, Background = Brushes.Gray });
 
-                        ExamContent.Children.Add(new TextBlock()
-                        {
-                            Width = 2000,
-                            Margin = new Thickness(16, 16, 16, 8),
-                            Text = $"超声所见:",
-                            FontSize = 16,
-                            FontWeight = FontWeights.Bold,
-                        });
+                    ExamContent.Children.Add(new TextBlock()
+                    {
+                        Width = 2000,
+                        Margin = new Thickness(16, 16, 16, 8),
+                        Text = "超声所见:",
+                        FontSize = 16,
+                        FontWeight = FontWeights.Bold,
+                    });
 
-                        ExamContent.Children.Add(new TextBlock()
-                        {
-                            Margin = new Thickness(16, 8, 16, 16),
-                            Text = reportContent["Summary"].Replace(@"\n", Environment.NewLine),
-                            FontSize = 16,
-                            TextWrapping = TextWrapping.Wrap,
-                        });
+                    ExamContent.Children.Add(new TextBlock()
+                    {
+                        Margin = new Thickness(16, 8, 16, 16),
+                        Text = reportContent["Summary"].Replace(@"\n", Environment.NewLine),
+                        FontSize = 16,
+                        TextWrapping = TextWrapping.Wrap,
+                    });
 
-                        ExamContent.Children.Add(new TextBlock()
-                        {
-                            Width = 2000,
-                            Margin = new Thickness(16, 16, 16, 8),
-                            Text = $"超声提示:",
-                            FontSize = 16,
-                            FontWeight = FontWeights.Bold,
-                        });
+                    ExamContent.Children.Add(new TextBlock()
+                    {
+                        Width = 2000,
+                        Margin = new Thickness(16, 16, 16, 8),
+                        Text = "超声提示:",
+                        FontSize = 16,
+                        FontWeight = FontWeights.Bold,
+                    });
 
-                        ExamContent.Children.Add(new TextBlock()
-                        {
-                            Margin = new Thickness(16, 8, 16, 16),
-                            Text = reportContent["Comment"].Replace(@"\n", Environment.NewLine),
-                            FontSize = 16,
-                            TextWrapping = TextWrapping.Wrap,
-                        });
-                    }
-                    else
+                    ExamContent.Children.Add(new TextBlock()
+                    {
+                        Margin = new Thickness(16, 8, 16, 16),
+                        Text = reportContent["Comment"].Replace(@"\n", Environment.NewLine),
+                        FontSize = 16,
+                        TextWrapping = TextWrapping.Wrap,
+                    });
+                }
+                else
+                {
+                    ExamContent.Children.Add(new TextBlock()
+                    {
+                        Margin = new Thickness(16),
+                        Text = exam.Report,
+                        FontSize = 20,
+                        TextWrapping = TextWrapping.Wrap,
+                    });
+                }
+                ExamContent.Children.Add(new Border() { Height = 1, Width = 2000, BorderBrush = Brushes.Gray, Background = Brushes.Gray });
+                var images = _db!.GetImages(exam.Id);
+                foreach (var image in images)
+                {
+                    var img = new BitmapImage();
+                    img.BeginInit();
+                    img.StreamSource = new MemoryStream(image.Data);
+                    img.EndInit();
+                    var imageBorder = new Border
                     {
-                        ExamContent.Children.Add(new TextBlock()
+                        Margin = new Thickness(16),
+                        Width = 200,
+                        Height = 200,
+                        Background = Brushes.Black,
+                        Child = new System.Windows.Controls.Image()
                         {
-                            Margin = new Thickness(16),
-                            Text = exam.Report,
-                            FontSize = 20,
-                            TextWrapping = TextWrapping.Wrap,
-                        });
-                    }
-                    ExamContent.Children.Add(new Border() { Height = 1, Width = 2000, BorderBrush = Brushes.Gray, Background = Brushes.Gray });
-                    var images = _db.GetImages(exam.Id);
-                    foreach (var image in images)
+                            Source = img
+                        },
+                        Cursor = Cursors.Hand
+
+                    };
+                    imageBorder.MouseDown += (_, _) =>
                     {
-                        var img = new BitmapImage();
-                        img.BeginInit();
-                        img.StreamSource = new MemoryStream(image.Data);
-                        img.EndInit();
-                        var imageBorder = new Border()
+                        var viewImageWindow = new Window
                         {
-                            Margin = new Thickness(16),
-                            Width = 200,
-                            Height = 200,
+                            Owner = this,
                             Background = Brushes.Black,
-                            Child = new System.Windows.Controls.Image()
-                            {
-                                Source = img
-                            },
-                            Cursor = Cursors.Hand
-
+                            WindowStartupLocation = WindowStartupLocation.CenterOwner
                         };
-                        imageBorder.MouseDown += (sender, e) =>
+                        var width = img.Width + 16;
+                        var height = img.Height + 16;
+                        if (width >= SystemParameters.PrimaryScreenWidth || height >= SystemParameters.PrimaryScreenHeight)
                         {
-                            var viewImageWindow = new Window
-                            {
-                                Owner = this,
-                                Background = Brushes.Black,
-                                WindowStartupLocation = WindowStartupLocation.CenterOwner
-                            };
-                            var width = img.Width + 16;
-                            var height = img.Height + 16;
-                            if (width >= SystemParameters.PrimaryScreenWidth || height >= SystemParameters.PrimaryScreenHeight)
-                            {
-                                viewImageWindow.WindowState = WindowState.Maximized;
-                            }
-                            else
-                            {
-                                viewImageWindow.Width = width;
-                                viewImageWindow.Height = height;
-                            }
-                            viewImageWindow.Content = new System.Windows.Controls.Image()
-                            {
-                                Source = img
-                            };
-                            viewImageWindow.ShowDialog();
+                            viewImageWindow.WindowState = WindowState.Maximized;
+                        }
+                        else
+                        {
+                            viewImageWindow.Width = width;
+                            viewImageWindow.Height = height;
+                        }
+                        viewImageWindow.Content = new System.Windows.Controls.Image()
+                        {
+                            Source = img
                         };
-                        ExamContent.Children.Add(imageBorder);
-                    }
+                        viewImageWindow.ShowDialog();
+                    };
+                    ExamContent.Children.Add(imageBorder);
                 }
             }
         }
@@ -262,14 +265,13 @@ namespace TestViewer
         {
             if (_pageIndex < _pageCount - 1)
             {
-                var batchTask = BatchTaskList.SelectedValue as BatchTask;
-                if (batchTask != null)
+                if (BatchTaskList.SelectedValue is BatchTask batchTask)
                 {
                     ExamList.Items.Clear();
                     _pageIndex++;
                     Loading.Run(() =>
                     {
-                        var exams = _db.GetExams(batchTask.Id, _pageIndex, _partKey, _conclusionKey);
+                        var exams = _db!.GetExams(batchTask.Id, _pageIndex, _partKey, _conclusionKey,_startDate, _endDate);
                         Dispatcher.Invoke(() =>
                         {
                             foreach (var exam in exams)
@@ -287,14 +289,13 @@ namespace TestViewer
         {
             if (_pageIndex > 0)
             {
-                var batchTask = BatchTaskList.SelectedValue as BatchTask;
-                if (batchTask != null)
+                if (BatchTaskList.SelectedValue is BatchTask batchTask)
                 {
                     ExamList.Items.Clear();
                     _pageIndex--;
                     Loading.Run(() =>
                     {
-                        var exams = _db.GetExams(batchTask.Id, _pageIndex, _partKey, _conclusionKey);
+                        var exams = _db!.GetExams(batchTask.Id, _pageIndex, _partKey, _conclusionKey, _startDate, _endDate);
                         Dispatcher.Invoke(() =>
                         {
                             foreach (var exam in exams)
@@ -312,16 +313,15 @@ namespace TestViewer
         {
             _partKey = PartKey.Text;
             _conclusionKey = ConclusionKey.Text;
-            var batchTask = BatchTaskList.SelectedValue as BatchTask;
-            if (batchTask != null)
+            if (BatchTaskList.SelectedValue is BatchTask batchTask)
             {
                 ExamList.Items.Clear();
-                Exam[]? exams = null;
+                Exam[]? exams;
                 Loading.Run(() =>
                 {
-                    _pageCount = _db.GetPageCount(batchTask.Id, _partKey, _conclusionKey);
+                    _pageCount = _db!.GetPageCount(batchTask.Id, _partKey, _conclusionKey, _startDate, _endDate);
                     _pageIndex = 0;
-                    exams = _db.GetExams(batchTask.Id, _pageIndex, _partKey, _conclusionKey);
+                    exams = _db.GetExams(batchTask.Id, _pageIndex, _partKey, _conclusionKey,_startDate, _endDate);
                     Dispatcher.Invoke(() =>
                     {
                         foreach (var exam in exams)
@@ -338,8 +338,7 @@ namespace TestViewer
         {
             var partKey = PartKey.Text;
             var conclusionKey = ConclusionKey.Text;
-            var batchTask = BatchTaskList.SelectedValue as BatchTask;
-            if (batchTask != null)
+            if (BatchTaskList.SelectedValue is BatchTask batchTask)
             {
                 FolderBrowserEx.FolderBrowserDialog dialog = new FolderBrowserEx.FolderBrowserDialog();
                 var result = dialog.ShowDialog();
@@ -367,7 +366,7 @@ namespace TestViewer
                         Owner = this
                     };
                     var canClose = false;
-                    progressWindow.Closing += (s, e) => { e.Cancel = !canClose; };
+                    progressWindow.Closing += (_, arg) => { arg.Cancel = !canClose; };
 
 
                     var progressBar = new ProgressBar
@@ -384,15 +383,14 @@ namespace TestViewer
                             WriteIndented = true,
                             Encoder = JavaScriptEncoder.Create(UnicodeRanges.All)
                         };
-                        var pageCount = _db.GetPageCount(batchTask.Id, partKey, conclusionKey);
+                        var pageCount = _db!.GetPageCount(batchTask.Id, partKey, conclusionKey,_startDate, _endDate);
                         if (pageCount > 0)
                         {
                             for (int i = 0; i < pageCount; i++)
                             {
-                                var exams = _db.GetExams(batchTask.Id, i, partKey, conclusionKey);
-                                for (var j = 0; j < exams.Length; j++)
+                                var exams = _db.GetExams(batchTask.Id, i, partKey, conclusionKey,_startDate, _endDate);
+                                foreach (var exam in exams)
                                 {
-                                    var exam = exams[j];
                                     var images = _db.GetImages(exam.Id);
                                     foreach (var image in images)
                                     {
@@ -406,7 +404,7 @@ namespace TestViewer
                                         { "PatientAge", exam.PatientAge },
                                         { "ExamDate", exam.ExamDate }
                                     };
-                                    Dictionary<string, string>? reportContent = null;
+                                    Dictionary<string, string>? reportContent;
                                     try
                                     {
                                         reportContent = JsonSerializer.Deserialize<Dictionary<string, string>>(exam.Report);

+ 1 - 0
TestViewer/TestViewer.csproj

@@ -14,6 +14,7 @@
 
   <ItemGroup>
     <PackageReference Include="FolderBrowserEx" Version="1.0.1" />
+    <PackageReference Include="HandyControl" Version="3.4.0" />
     <PackageReference Include="sqlite-net-pcl" Version="1.8.116" />
   </ItemGroup>