41 lines
1.1 KiB
C#
41 lines
1.1 KiB
C#
using System.Windows;
|
|
using MessageBox = System.Windows.MessageBox;
|
|
|
|
namespace ITNexusAgent.UI;
|
|
|
|
public partial class LogWindow : Window
|
|
{
|
|
private const string LogPath = @"C:\ProgramData\IT Nexus Agent\agent.log";
|
|
|
|
public LogWindow()
|
|
{
|
|
InitializeComponent();
|
|
LoadLog();
|
|
}
|
|
|
|
private void LoadLog()
|
|
{
|
|
try
|
|
{
|
|
if (File.Exists(LogPath))
|
|
{
|
|
var lines = File.ReadAllLines(LogPath);
|
|
LogText.Text = string.Join(Environment.NewLine, lines.TakeLast(500));
|
|
LogText.ScrollToEnd();
|
|
}
|
|
else LogText.Text = "Log-Datei nicht gefunden.";
|
|
}
|
|
catch (Exception ex) { LogText.Text = $"Fehler: {ex.Message}"; }
|
|
}
|
|
|
|
private void Refresh_Click(object sender, RoutedEventArgs e) => LoadLog();
|
|
|
|
private void Clear_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
var r = MessageBox.Show("Log wirklich löschen?", "IT Nexus",
|
|
MessageBoxButton.YesNo, MessageBoxImage.Question);
|
|
if (r != MessageBoxResult.Yes) return;
|
|
try { File.WriteAllText(LogPath, ""); LoadLog(); } catch { }
|
|
}
|
|
}
|