Initial commit: IT Nexus Web-App
This commit is contained in:
40
agent-cs/UI/LogWindow.xaml.cs
Normal file
40
agent-cs/UI/LogWindow.xaml.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
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 { }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user