Переглянути джерело

Fix Log Trace Performance Issue in HUGE data amount

Zixuan 4 днів тому
батько
коміт
027235c2f5

+ 6 - 10
HistoryUI/ViewModels/AlarmViewModel.cs

@@ -24,21 +24,17 @@ public partial class AlarmViewModel(Hardwares hardwares, IORM orm) : BaseViewMod
 
     private void QueryResult(List<DBWarning> results)
     {
+        results = [.. results.OrderBy(t => t.DateTime)];
         App.Current.Dispatcher?.Invoke(() =>
         {
-            base.Results ??= [];
-            base.Results?.Clear();
-        });
-        Task.Factory.StartNew(() =>
-        {
-            results = [.. results.OrderBy(t => t.DateTime)];
+            base.Results = null;
+            Dictionary<int, DBWarning> temp = [];
+
             for (int i = 1; i <= results.Count; i++)
             {
-                App.Current.Dispatcher?.Invoke(() =>
-                {
-                    base.Results!.Add(i, results[i - 1]);
-                });
+                temp.Add(i, results[i - 1]);
             }
+            base.Results = temp;
         });
     }
 }

+ 1 - 1
HistoryUI/ViewModels/BaseViewModel.cs

@@ -36,7 +36,7 @@ public partial class BaseViewModel<T_ResultType> : ObservableObject
     private Hardwares _Hardwares;
 
     [ObservableProperty]
-    private ObservableDictionary<int, T_ResultType>? _Results;
+    private Dictionary<int, T_ResultType>? _Results;
 
     [ObservableProperty]
     private KeyValuePair<byte, Mini8Data>? _SelectedMini8;

+ 4 - 3
HistoryUI/ViewModels/StatusViewModel.cs

@@ -265,10 +265,11 @@ public partial class StatusViewModel : BaseViewModel<DBFormat>
 
     private void RefreshDataTable(List<DBFormat> results)
     {
-        this.Results ??= [];
-        this.Results.Clear();
+        Dictionary<int, DBFormat> temp = [];
+        this.Results = null;
         for (int i = 0; i < results.Count; i++)
-            this.Results.Add(i, results[i]);
+            temp.Add(i, results[i]);
+        this.Results = temp;
     }
 
     private void RefreshPlot()

+ 8 - 8
HistoryUI/Views/MainWindow.xaml.cs

@@ -41,15 +41,15 @@ public partial class MainWindow : Window
             }
             else
             {
-                //this.Left = -1920;
-                //this.Top = 0;
-                //this.Width = System.Windows.SystemParameters.PrimaryScreenWidth;
-                //this.Height = System.Windows.SystemParameters.PrimaryScreenHeight;
+                this.Left = 0;
+                this.Top = 0;
+                this.Width = System.Windows.SystemParameters.PrimaryScreenWidth;
+                this.Height = System.Windows.SystemParameters.PrimaryScreenHeight;
 
-                this.Left = -1024;
-                this.Top = 0.0;
-                this.Width = 1024;
-                this.Height = 768;
+                //this.Left = -1024;
+                //this.Top = 0.0;
+                //this.Width = 1024;
+                //this.Height = 768;
             }
 
             this.Content = StartSetting.Content switch