Migration to a ServiceWorker for most tasks.
Implementation of basic PatchComplianceTask. First real iteration, basic/raw asf.
This commit is contained in:
@@ -901,5 +901,121 @@ private async void RefreshButton_Click(object sender, RoutedEventArgs e)
|
||||
}
|
||||
}
|
||||
|
||||
// ============================
|
||||
// Service Tab Event Handlers
|
||||
// ============================
|
||||
|
||||
private void RefreshServiceStatus_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var serviceName = "PSG-Oversight";
|
||||
var service = System.ServiceProcess.ServiceController.GetServices()
|
||||
.FirstOrDefault(s => s.ServiceName == serviceName);
|
||||
|
||||
if (service != null)
|
||||
{
|
||||
ServiceStatusText.Text = service.Status.ToString();
|
||||
ServiceStatusText.Foreground = service.Status == System.ServiceProcess.ServiceControllerStatus.Running
|
||||
? new SolidColorBrush(Colors.Green)
|
||||
: new SolidColorBrush(Colors.Red);
|
||||
}
|
||||
else
|
||||
{
|
||||
ServiceStatusText.Text = "Not Installed";
|
||||
ServiceStatusText.Foreground = new SolidColorBrush(Colors.Orange);
|
||||
}
|
||||
|
||||
ServiceLastCheckText.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ServiceStatusText.Text = $"Error: {ex.Message}";
|
||||
ServiceStatusText.Foreground = new SolidColorBrush(Colors.Red);
|
||||
}
|
||||
}
|
||||
|
||||
private async void TestPatchCompliance_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ServiceLogOutput.Text = "Running Patch Compliance check...\n\n";
|
||||
|
||||
try
|
||||
{
|
||||
// Create instances of services
|
||||
var apiClient = new Services.ApiClient(_config);
|
||||
var patchTask = new Services.PatchComplianceTask(_config, apiClient);
|
||||
|
||||
// Execute the task
|
||||
await patchTask.ExecuteAsync();
|
||||
|
||||
ServiceLogOutput.Text += $"[{DateTime.Now}] Patch compliance check completed successfully.\n";
|
||||
ServiceLogOutput.Text += "Check %LOCALAPPDATA%\\PSG-Oversight\\patch_compliance.log for details.\n";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ServiceLogOutput.Text += $"[{DateTime.Now}] ERROR: {ex.Message}\n";
|
||||
ServiceLogOutput.Text += $"Stack Trace:\n{ex.StackTrace}\n";
|
||||
}
|
||||
}
|
||||
|
||||
private void ViewSchedulerState_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var stateFilePath = Path.Combine(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
|
||||
"PSG-Oversight",
|
||||
"task_scheduler_state.json"
|
||||
);
|
||||
|
||||
if (File.Exists(stateFilePath))
|
||||
{
|
||||
var json = File.ReadAllText(stateFilePath);
|
||||
var formatted = JsonConvert.SerializeObject(
|
||||
JsonConvert.DeserializeObject(json),
|
||||
Formatting.Indented
|
||||
);
|
||||
|
||||
ServiceLogOutput.Text = $"Task Scheduler State:\n\n{formatted}";
|
||||
}
|
||||
else
|
||||
{
|
||||
ServiceLogOutput.Text = "Task scheduler state file not found.\nThe service may not have run any tasks yet.";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ServiceLogOutput.Text = $"Error reading scheduler state:\n{ex.Message}";
|
||||
}
|
||||
}
|
||||
|
||||
private async void TestAPIConnection_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ServiceLogOutput.Text = "Testing API connection...\n\n";
|
||||
|
||||
try
|
||||
{
|
||||
var apiClient = new Services.ApiClient(_config);
|
||||
|
||||
// Test connectivity
|
||||
bool isConnected = await apiClient.CheckConnectivity();
|
||||
|
||||
if (isConnected)
|
||||
{
|
||||
ServiceLogOutput.Text += $"[{DateTime.Now}] ✅ API is reachable!\n";
|
||||
ServiceLogOutput.Text += $"Server URL: {_config.ServerUrl}\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
ServiceLogOutput.Text += $"[{DateTime.Now}] ❌ API is NOT reachable!\n";
|
||||
ServiceLogOutput.Text += $"Server URL: {_config.ServerUrl}\n";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ServiceLogOutput.Text += $"[{DateTime.Now}] ERROR: {ex.Message}\n";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user