LogWindow: Improve loading time
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				Test / Run tests (push) Successful in 1m46s
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	Test / Run tests (push) Successful in 1m46s
				
			This commit is contained in:
		| @@ -561,9 +561,7 @@ namespace Elwig.Helpers { | |||||||
|                 Log = "Application", |                 Log = "Application", | ||||||
|                 Source = ".NET Runtime", |                 Source = ".NET Runtime", | ||||||
|             }; |             }; | ||||||
|             return log.Entries.Cast<EventLogEntry>() |             return [.. log.Entries.OfType<EventLogEntry>().Where(e => e.InstanceId == 1026).Where(e => e.Message.StartsWith("Application: Elwig.exe"))]; | ||||||
|                 .Where(e => e.Message.StartsWith("Application: Elwig.exe")) |  | ||||||
|                 .ToList(); |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public static int GetEntityIdetifierForPk(params object?[] primaryKey) { |         public static int GetEntityIdetifierForPk(params object?[] primaryKey) { | ||||||
|   | |||||||
| @@ -1,7 +1,9 @@ | |||||||
| using Elwig.Helpers; | using Elwig.Helpers; | ||||||
| using System.Diagnostics; | using System.Diagnostics; | ||||||
| using System.Linq; | using System.Linq; | ||||||
|  | using System.Threading.Tasks; | ||||||
| using System.Windows; | using System.Windows; | ||||||
|  | using System.Windows.Input; | ||||||
|  |  | ||||||
| namespace Elwig.Windows { | namespace Elwig.Windows { | ||||||
|     public partial class LogWindow : Window { |     public partial class LogWindow : Window { | ||||||
| @@ -11,28 +13,34 @@ namespace Elwig.Windows { | |||||||
|             WindowState = WindowState.Maximized; |             WindowState = WindowState.Maximized; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         private void Window_Loaded(object sender, RoutedEventArgs evt) { |         private async void Window_Loaded(object sender, RoutedEventArgs evt) { | ||||||
|             var log = Utils.GetLogEntries(); |             Mouse.OverrideCursor = Cursors.Wait; | ||||||
|             EventList.ItemsSource = log |             await Task.Run(async () => { | ||||||
|                 .Select(e => new { |                 var list = Utils.GetLogEntries() | ||||||
|                     Event = e, |                   .Select(e => new { | ||||||
|                     Lines = e.Message.Split('\n').ToArray(), |                       Event = e, | ||||||
|                 }) |                       Lines = e.Message.Split('\n').ToArray(), | ||||||
|                 .Select(e => new { |                   }) | ||||||
|                     e.Event, |                   .Select(e => new { | ||||||
|                     Exception = e.Lines.FirstOrDefault(l => l.StartsWith("Exception Info: "))?[16..].Trim().Split(':', 2), |                       e.Event, | ||||||
|                     Location = e.Lines.FirstOrDefault(l => l.StartsWith("   at Elwig."))?[5..].Trim(), |                       Exception = e.Lines.FirstOrDefault(l => l.StartsWith("Exception Info: "))?[16..].Trim().Split(':', 2), | ||||||
|                 }) |                       Location = e.Lines.FirstOrDefault(l => l.StartsWith("   at Elwig."))?[5..].Trim(), | ||||||
|                 .Select(e => new { |                   }) | ||||||
|                     e.Event, |                   .Select(e => new { | ||||||
|                     e.Exception, |                       e.Event, | ||||||
|                     ExceptionName = e.Exception?[0].Trim(), |                       e.Exception, | ||||||
|                     ExceptionMessage = e.Exception?.Length >= 2 ? e.Exception?[1].Trim() : null, |                       ExceptionName = e.Exception?[0].Trim(), | ||||||
|                     e.Location, |                       ExceptionMessage = e.Exception?.Length >= 2 ? e.Exception?[1].Trim() : null, | ||||||
|                 }) |                       e.Location, | ||||||
|                 .OrderByDescending(e => e.Event.TimeGenerated) |                   }) | ||||||
|                 .ToList(); |                   .OrderByDescending(e => e.Event.TimeGenerated) | ||||||
|             EventList.SelectedIndex = 0; |                   .ToList(); | ||||||
|  |                 await App.MainDispatcher.BeginInvoke(() => { | ||||||
|  |                     EventList.ItemsSource = list; | ||||||
|  |                     EventList.SelectedIndex = 0; | ||||||
|  |                 }); | ||||||
|  |             }); | ||||||
|  |             Mouse.OverrideCursor = null; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         private void EventList_SelectionChanged(object sender, RoutedEventArgs evt) { |         private void EventList_SelectionChanged(object sender, RoutedEventArgs evt) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user