- RdpActiveIndicatorWindow: TeamViewer-Style Overlay unten rechts, solange RDP-Capture läuft. Zeigt Dauer der Sitzung + pulsierenden roten Punkt - User kann per "Trennen"-Button selbst die Sitzung beenden (TCP-Signal an Service, cancelt Capture-Loop sofort — auch nach Screen-Wechsel) - Overlay läuft als separater User-Prozess via SessionSpawner, wird vom Service direkt gekillt wenn Sitzung endet (rdp_stop oder Disconnect) - Version: 2.5.0 → 2.6.0 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
96 lines
2.9 KiB
C#
96 lines
2.9 KiB
C#
using ITNexusAgent;
|
|
using ITNexusAgent.Models;
|
|
using ITNexusAgent.UI;
|
|
using Newtonsoft.Json;
|
|
using System.ServiceProcess;
|
|
|
|
internal class Program
|
|
{
|
|
[STAThread]
|
|
static void Main(string[] args)
|
|
{
|
|
var exePath = System.Diagnostics.Process.GetCurrentProcess().MainModule!.FileName;
|
|
|
|
if (args.Length > 0)
|
|
{
|
|
switch (args[0])
|
|
{
|
|
case "--notify":
|
|
RunNotification(args.Length > 1 ? args[1] : "");
|
|
return;
|
|
|
|
case "--rdp-consent":
|
|
ConsentModeRunner.Run(args.Length > 1 ? args[1] : "");
|
|
return;
|
|
|
|
case "--rdp-capture":
|
|
CaptureModeRunner.Run(
|
|
args.Length > 1 ? args[1] : "",
|
|
args.Length > 2 && int.TryParse(args[2], out var si) ? si : 0);
|
|
return;
|
|
|
|
case "--rdp-indicator":
|
|
IndicatorModeRunner.Run(args.Length > 1 ? args[1] : "");
|
|
return;
|
|
|
|
case "--dashboard":
|
|
RunDashboard();
|
|
return;
|
|
|
|
case "--install":
|
|
AgentService.MigrateFromOldAgent();
|
|
AgentService.Install(exePath);
|
|
return;
|
|
|
|
case "--uninstall":
|
|
AgentService.Uninstall();
|
|
return;
|
|
}
|
|
}
|
|
|
|
ServiceBase.Run(new AgentService());
|
|
}
|
|
|
|
static void RunNotification(string base64Json)
|
|
{
|
|
const string errorLog = @"C:\ProgramData\IT Nexus Agent\notify-error.log";
|
|
try
|
|
{
|
|
var json = Encoding.UTF8.GetString(Convert.FromBase64String(base64Json));
|
|
File.AppendAllText(errorLog, $"{DateTime.Now:yyyy-MM-dd HH:mm:ss} START json={json}\n");
|
|
|
|
var ann = JsonConvert.DeserializeObject<Announcement>(json);
|
|
if (ann == null)
|
|
{
|
|
File.AppendAllText(errorLog, $"{DateTime.Now:yyyy-MM-dd HH:mm:ss} ERROR: Deserialization returned null\n");
|
|
return;
|
|
}
|
|
|
|
var app = new System.Windows.Application();
|
|
app.ShutdownMode = System.Windows.ShutdownMode.OnMainWindowClose;
|
|
app.DispatcherUnhandledException += (s, e) =>
|
|
{
|
|
File.AppendAllText(errorLog, $"{DateTime.Now:yyyy-MM-dd HH:mm:ss} DISPATCHER ERROR: {e.Exception}\n");
|
|
e.Handled = true;
|
|
app.Shutdown();
|
|
};
|
|
|
|
var win = new NotificationWindow(ann);
|
|
win.Topmost = true;
|
|
win.Show();
|
|
win.Activate();
|
|
app.Run();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
File.AppendAllText(errorLog, $"{DateTime.Now:yyyy-MM-dd HH:mm:ss} ERROR: {ex}\n");
|
|
}
|
|
}
|
|
|
|
static void RunDashboard()
|
|
{
|
|
var app = new System.Windows.Application();
|
|
app.Run(new DashboardWindow());
|
|
}
|
|
}
|