Added logging Tasks

This commit is contained in:
Jonny007-MKD 2015-11-04 11:23:26 +00:00
parent d0ca2edbfe
commit 0bc9b0a4d4
8 changed files with 687 additions and 7 deletions

View File

@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Trigger.Tasks.Plugins
{
/// <summary>
/// <para>Logs all events from command line</para>
/// </summary>
class LogCommandLineEvents : TaskPlugin
{
#region Properties
internal Main Main;
internal Log Log;
#endregion
#region Methods
public override bool Init(Main Main)
{
return Init(Main, new System.Diagnostics.Stopwatch());
}
public override bool Init(Main Main, System.Diagnostics.Stopwatch swInit)
{
this.Main = Main;
this.Log = Main.Log;
Main.CommandLineTrigger += new Events.EventPlugin.EventValue<int>(Main_CommandLineTrigger);
return true;
}
public override void Dispose()
{
Main.CommandLineTrigger -= new Events.EventPlugin.EventValue<int>(Main_CommandLineTrigger);
}
#endregion
#region Event handlers
private void Main_CommandLineTrigger(object sender, Events.EventArgsValue<int> e)
{
this.Log.LogLineDate("Trigger from command line: 0x" + e.Value.ToString("X4"), Trigger.Log.Type.CommandLineEvent);
}
#endregion
}
}

View File

@ -0,0 +1,93 @@
using System;
using System.Drawing;
using Microsoft.Win32;
using System.Windows.Forms;
using Trigger.Classes.Device;
namespace Trigger.Tasks
{
/// <summary>
/// <para>Logs all events from <see cref="Trigger.Events.Device"/></para>
/// </summary>
class LogDeviceEvents : TaskPlugin
{
#region Properties
internal Main Main;
internal Log Log;
#endregion
#region Methods
public override bool Init(Main Main)
{
return Init(Main, new System.Diagnostics.Stopwatch());
}
public override bool Init(Main Main, System.Diagnostics.Stopwatch swInit)
{
if (!Main.EventMgr.PluginExists<Events.Device>())
{
this.Log.LogLine("Task \"LogDeviceEvents\" is missing EventPlugin \"Device\"!", Log.Type.Error);
return false;
}
this.Main = Main;
this.Log = Main.Log;
swInit.Stop();
Events.Device deviceEvents = Main.EventMgr.GetPlugin<Events.Device>(new object[] {Main}, true);
swInit.Start();
deviceEvents.DeviceArrived += new Events.EventPlugin.EventValue<Device>(devEvents_DeviceArrived);
deviceEvents.DeviceQueryRemove += new Events.EventPlugin.EventValue<Device>(devEvents_DeviceQueryRemove);
deviceEvents.DeviceQueryRemoveFailed += new Events.EventPlugin.EventValue<Device>(devEvents_DeviceQueryRemoveFailed);
deviceEvents.DeviceRemoved += new Events.EventPlugin.EventValue<Device>(devEvents_DeviceRemoved);
deviceEvents.MediaInserted += new Events.EventPlugin.EventValue<Device>(devEvents_MediaInserted);
deviceEvents.NetworkVolumeArrived += new Events.EventPlugin.EventValue<Device>(devEvents_NetworkVolumeArrived);
return true;
}
public override void Dispose()
{
Events.Device devEvents = this.Main.EventMgr.GetPlugin<Events.Device>(new object[] {Main}, true);
devEvents.DeviceArrived -= new Events.EventPlugin.EventValue<Device>(devEvents_DeviceArrived);
devEvents.DeviceQueryRemove -= new Events.EventPlugin.EventValue<Device>(devEvents_DeviceQueryRemove);
devEvents.DeviceQueryRemoveFailed -= new Events.EventPlugin.EventValue<Device>(devEvents_DeviceQueryRemoveFailed);
devEvents.DeviceRemoved -= new Events.EventPlugin.EventValue<Device>(devEvents_DeviceRemoved);
devEvents.MediaInserted -= new Events.EventPlugin.EventValue<Device>(devEvents_MediaInserted);
devEvents.NetworkVolumeArrived -= new Events.EventPlugin.EventValue<Device>(devEvents_NetworkVolumeArrived);
}
#endregion
#region Event handlers
private void devEvents_DeviceArrived(object sender, Events.EventArgsValue<Device> e)
{
this.Log.LogLineDate("New device arrived: " + e.Value.Model, Trigger.Log.Type.DeviceEvent);
}
private void devEvents_DeviceQueryRemove(object sender, Events.EventArgsValue<Device> e)
{
this.Log.LogLineDate("Device is queried to be removed: " + e.Value.Model, Trigger.Log.Type.DeviceEvent);
}
private void devEvents_DeviceQueryRemoveFailed(object sender, Events.EventArgsValue<Device> e)
{
this.Log.LogLineDate("Device could not be removed: " + e.Value.Model, Trigger.Log.Type.DeviceEvent);
}
private void devEvents_DeviceRemoved(object sender, Events.EventArgsValue<Device> e)
{
this.Log.LogLineDate("A device was removed: " + e.Value.Model, Trigger.Log.Type.DeviceEvent);
}
private void devEvents_MediaInserted(object sender, Events.EventArgsValue<Device> e)
{
this.Log.LogLineDate("Media inserted in " + e.Value.Model, Trigger.Log.Type.DeviceEvent);
}
private void devEvents_NetworkVolumeArrived(object sender, Events.EventArgsValue<Device> e)
{
this.Log.LogLineDate("New network volume arrived: " + e.Value.Model, Trigger.Log.Type.DeviceEvent);
}
#endregion
}
}

View File

@ -0,0 +1,94 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;
using System.Text;
using System.Windows.Forms;
namespace Trigger.Tasks
{
/// <summary>
/// <para>Logs all events from <see cref="Trigger.Events.Network"/></para>
/// </summary>
class LogNetworkEvents : TaskPlugin
{
#region Properties
internal Main Main;
internal Log Log;
#endregion
#region Methods
public override bool Init(Main Main)
{
return Init(Main, new System.Diagnostics.Stopwatch());
}
public override bool Init(Main Main, System.Diagnostics.Stopwatch swInit)
{
if (!Main.EventMgr.PluginExists<Events.Network>())
{
this.Log.LogLine("Task \"LogNetworkEvents\" is missing EventPlugin \"Network\"!", Log.Type.Error);
return false;
}
this.Main = Main;
this.Log = Main.Log;
swInit.Stop();
Events.Network networkEvents = Main.EventMgr.GetPlugin<Events.Network>();
swInit.Start();
networkEvents.NetworkAvailabilityChanged += networkEvents_NetworkAvailabilityChanged;
networkEvents.NetworkInterfaceAdded += networkEvents_NetworkInterfaceAdded;
networkEvents.NetworkInterfaceRemoved += networkEvents_NetworkInterfaceRemoved;
networkEvents.IpAddressChanged += networkEvents_IpAddrChanged;
return true;
}
public override void Dispose()
{
Events.Network networkEvents = this.Main.EventMgr.GetPlugin<Events.Network>();
networkEvents.NetworkAvailabilityChanged -= networkEvents_NetworkAvailabilityChanged;
networkEvents.NetworkInterfaceAdded -= networkEvents_NetworkInterfaceAdded;
networkEvents.NetworkInterfaceRemoved -= networkEvents_NetworkInterfaceRemoved;
networkEvents.IpAddressChanged -= networkEvents_IpAddrChanged;
}
#endregion
#region Event handlers
private void networkEvents_IpAddrChanged(object sender, Events.EventArgsValues<NetworkInterface> e)
{
this.Log.LogLineDate("IP changed: " + e.OldValue.Name + ":", Log.Type.NetworkEvent);
UnicastIPAddressInformationCollection ipsOld = e.OldValue.GetIPProperties().UnicastAddresses;
UnicastIPAddressInformationCollection ipsNew = e.NewValue.GetIPProperties().UnicastAddresses;
for (int i = 0; i < Math.Max(ipsOld.Count, ipsNew.Count); i++)
{
if (ipsOld.Count > i)
this.Log.LogTextDate(ipsOld[i].Address.ToString().PadRight(40), Log.Type.NetworkEvent);
else
this.Log.LogTextDate(new String(' ', 40), Log.Type.NetworkEvent);
this.Log.LogText(" | ", Log.Type.NetworkEvent);
if (ipsNew.Count > i)
this.Log.LogText(ipsNew[i].Address.ToString(), Log.Type.NetworkEvent);
this.Log.Line(Log.Type.NetworkEvent);
}
}
private void networkEvents_NetworkInterfaceRemoved(object sender, Events.EventArgsValue<NetworkInterface> e)
{
this.Log.LogLineDate("Interface removed: " + e.Value.Name + "(" + e.Value.Id + ")", Log.Type.NetworkEvent);
}
private void networkEvents_NetworkInterfaceAdded(object sender, Events.EventArgsValue<NetworkInterface> e)
{
this.Log.LogLineDate("Interface added: " + e.Value.Name + "(" + e.Value.Id + ")", Log.Type.NetworkEvent);
}
private void networkEvents_NetworkAvailabilityChanged(object sender, Events.EventArgsValue<bool> e)
{
this.Log.LogLineDate("Network available: " + e.Value, Log.Type.NetworkEvent);
}
#endregion
}
}

View File

@ -0,0 +1,115 @@
using System;
using System.Drawing;
using Microsoft.Win32;
using System.Windows.Forms;
using Trigger.Classes.Power;
namespace Trigger.Tasks
{
/// <summary>
/// <para>Logs all events from <see cref="Trigger.Events.Power"/></para>
/// </summary>
class LogPowerEvents : TaskPlugin
{
#region Properties
internal Main Main;
internal Log Log;
#endregion
#region Methods
public override bool Init(Main Main)
{
return Init(Main, new System.Diagnostics.Stopwatch());
}
public override bool Init(Main Main, System.Diagnostics.Stopwatch swInit)
{
if (!Main.EventMgr.PluginExists<Events.Power>())
{
this.Log.LogLine("Task \"LogPowerEvents\" is missing EventPlugin \"Power\"!", Log.Type.Error);
return false;
}
this.Main = Main;
this.Log = Main.Log;
swInit.Stop();
Events.Power pwrEvents = Main.EventMgr.GetPlugin<Events.Power>(new object[] {Main}, true);
swInit.Start();
pwrEvents.PowerModeChanged += new Events.EventPlugin.EventValue<PowerModes>(pwrEvents_PowerModeChanged);
pwrEvents.Suspend += new Events.EventPlugin.Event(pwrEvents_Suspend);
pwrEvents.Resume += new Events.EventPlugin.Event(pwrEvents_Resume);
pwrEvents.PowerLineStatusChanged += new Events.EventPlugin.EventValues<PowerLineStatus>(pwrEvents_PowerLineStatusChanged);
pwrEvents.BatteryAvailabilityChanged += new Events.EventPlugin.EventValue<bool?>(pwrEvents_BatteryAvailabilityChanged);
pwrEvents.BatteryStatusChanged += new Events.EventPlugin.EventValues<BatteryChargeStatus>(pwrEvents_BatteryStatusChanged);
pwrEvents.PowerSchemeChanged += new Events.EventPlugin.EventValues<PowerScheme>(pwrEvents_PowerSchemeChanged);
return true;
}
public override void Dispose()
{
Events.Power pwrEvents = Main.EventMgr.GetPlugin<Events.Power>(new object[] {Main}, true);
pwrEvents.PowerModeChanged -= new Events.EventPlugin.EventValue<PowerModes>(pwrEvents_PowerModeChanged);
pwrEvents.Suspend -= new Events.EventPlugin.Event(pwrEvents_Suspend);
pwrEvents.Resume -= new Events.EventPlugin.Event(pwrEvents_Resume);
pwrEvents.PowerLineStatusChanged -= new Events.EventPlugin.EventValues<PowerLineStatus>(pwrEvents_PowerLineStatusChanged);
pwrEvents.BatteryAvailabilityChanged -= new Events.EventPlugin.EventValue<bool?>(pwrEvents_BatteryAvailabilityChanged);
pwrEvents.BatteryStatusChanged -= new Events.EventPlugin.EventValues<BatteryChargeStatus>(pwrEvents_BatteryStatusChanged);
pwrEvents.PowerSchemeChanged -= new Events.EventPlugin.EventValues<PowerScheme>(pwrEvents_PowerSchemeChanged);
}
#endregion
#region Event handlers
private void pwrEvents_PowerModeChanged(object sender, Events.EventArgsValue<PowerModes> e)
{
if (e.Value == PowerModes.StatusChange)
this.Log.LogLineDate("The PowerMode changed to: " + e.Value.ToString(), Log.Type.PowerEvent);
}
private void pwrEvents_Suspend(object sender, EventArgs e)
{
this.Log.LogLineDate("The system is being suspended", Log.Type.PowerEvent);
}
private void pwrEvents_Resume(object sender, EventArgs e)
{
this.Log.LogLineDate("The system is being resumed", Log.Type.PowerEvent);
}
private void pwrEvents_PowerLineStatusChanged(object sender, Events.EventArgsValues<PowerLineStatus> e)
{
if (e.NewValue == PowerLineStatus.Online)
this.Log.LogLineDate("The computer was connected to the power network", Trigger.Log.Type.PowerEvent);
else
this.Log.LogLineDate("The computer was disconnected from the power network", Trigger.Log.Type.PowerEvent);
}
private void pwrEvents_BatteryAvailabilityChanged(object sender, Events.EventArgsValue<bool?> e)
{
if (e.Value.Value == true)
this.Log.LogLineDate("A battery was connected", Trigger.Log.Type.PowerEvent);
else
this.Log.LogLineDate("A battery was disconnected", Trigger.Log.Type.PowerEvent);
}
private void pwrEvents_BatteryStatusChanged(object sender, Events.EventArgsValues<BatteryChargeStatus> e)
{
this.Log.LogLineDate("The status of the battery changed: " + e.OldValue.ToString() + " -> " + e.NewValue.ToString() + " (" + Status.Power.BatteryLifePercent.ToString() + "%)", Trigger.Log.Type.PowerEvent);
}
private void pwrEvents_PowerSchemeChanged(object sender, Events.EventArgsValues<PowerScheme> e)
{
this.Log.LogLineDate("Power scheme changed: " + e.OldValue.Name + " --> " + e.NewValue.Name, Trigger.Log.Type.PowerEvent);
}
#endregion
}
}

View File

@ -0,0 +1,65 @@
using System.Diagnostics;
using Trigger.Events;
namespace Trigger.Tasks
{
/// <summary>
/// <para>Logs all events from <see cref="Trigger.Events.Processes"/></para>
/// </summary>
// TODO: There is bug in here: Eine nicht behandelte Ausnahme des Typs "System.Runtime.InteropServices.InvalidComObjectException" ist in System.Management.dll aufgetreten. Ein COM-Objekt, das vom zugrunde liegenden RCW getrennt wurde, kann nicht verwendet werden.
class LogProcessesEvents : TaskPlugin
{
#region Properties
internal Main Main;
internal Log Log;
#endregion
#region Methods
public override bool Init(Main Main)
{
return Init(Main, new System.Diagnostics.Stopwatch());
}
public override bool Init(Main Main, System.Diagnostics.Stopwatch swInit)
{
if (!Main.EventMgr.PluginExists<Events.Processes>())
{
this.Log.LogLine("Task \"LogProcessStartedEvents\" is missing EventPlugin \"ProcessStarted\"!", Log.Type.Error);
return false;
}
this.Main = Main;
this.Log = Main.Log;
swInit.Stop();
Events.Processes procEvents = Main.EventMgr.GetPlugin<Events.Processes>();
swInit.Start();
procEvents.ProcessCreated += new Events.EventPlugin.EventValue<Process>(procEvents_ProcessCreated);
procEvents.ProcessExited += new EventPlugin.EventValue<Process>(procEvents_ProcessExited);
return true;
}
public override void Dispose()
{
Events.Processes procEvents = Main.EventMgr.GetPlugin<Events.Processes>();
procEvents.ProcessCreated -= new Events.EventPlugin.EventValue<Process>(procEvents_ProcessCreated);
procEvents.ProcessExited -= new EventPlugin.EventValue<Process>(procEvents_ProcessExited);
}
#endregion
#region Event handlers
private void procEvents_ProcessCreated(object sender, EventArgsValue<Process> e)
{
try { this.Log.LogLineDate("A new process was created: " + e.Value.ProcessName + " (" + e.Value.Id + ")", Trigger.Log.Type.ProcessesEvent); }
catch { this.Log.LogLineDate("A new process was created", Trigger.Log.Type.ProcessesEvent); };
}
private void procEvents_ProcessExited(object sender, EventArgsValue<Process> e)
{
string exitCode = "";
try { exitCode = " Code " + e.Value.ExitCode.ToString(); } catch { }
this.Log.LogLineDate("A process has exited: " + e.Value.ProcessName + " (" + e.Value.Id + ")" + exitCode, Trigger.Log.Type.ProcessesEvent);
}
#endregion
}
}

View File

@ -0,0 +1,106 @@
using System;
using System.Drawing;
using Microsoft.Win32;
using System.Windows.Forms;
using Trigger.Classes.Screen;
namespace Trigger.Tasks
{
/// <summary>
/// <para>Logs all events from <see cref="Trigger.Events.Screen"/></para>
/// </summary>
class LogScreenEvents : TaskPlugin
{
#region Properties
internal Main Main;
internal Log Log;
#endregion
#region Methods
public override bool Init(Main Main)
{
return Init(Main, new System.Diagnostics.Stopwatch());
}
public override bool Init(Main Main, System.Diagnostics.Stopwatch swInit)
{
if (!Main.EventMgr.PluginExists<Events.Screen>())
{
this.Log.LogLine("Task \"LogScreenEvents\" is missing EventPlugin \"Screen\"!", Log.Type.Error);
return false;
}
this.Main = Main;
this.Log = Main.Log;
swInit.Stop();
Events.Screen screenEvents = Main.EventMgr.GetPlugin<Events.Screen>();
swInit.Start();
screenEvents.ScreenAdded += new Events.EventPlugin.EventValue<ScreenEx>(screenEvents_ScreenAdded);
screenEvents.ScreenRemoved += new Events.EventPlugin.EventValue<ScreenEx>(screenEvents_ScreenRemoved);
screenEvents.ScreenColorDepthChanged += new Events.EventPlugin.EventValues<ScreenEx>(screenEvents_ScreenColorDepthChanged);
screenEvents.ScreenResolutionChanged += new Events.EventPlugin.EventValues<ScreenEx>(screenEvents_ScreenResolutionChanged);
screenEvents.PrimaryScreenChanged += new Events.EventPlugin.EventValues<ScreenEx>(screenEvents_PrimaryScreenChanged);
screenEvents.ScreenLocationChanged += new Events.EventPlugin.EventValues<ScreenEx>(screenEvents_ScreenLocationChanged);
screenEvents.ScreenOrientationChanged += new Events.EventPlugin.EventValues<ScreenEx>(screenEvents_ScreenOrientationChanged);
screenEvents.ScreenRefreshRateChanged += new Events.EventPlugin.EventValues<ScreenEx>(screenEvents_ScreenRefreshRateChanged);
return true;
}
public override void Dispose()
{
Events.Screen screenEvents = Main.EventMgr.GetPlugin<Events.Screen>();
screenEvents.ScreenAdded -= new Events.EventPlugin.EventValue<ScreenEx>(screenEvents_ScreenAdded);
screenEvents.ScreenRemoved -= new Events.EventPlugin.EventValue<ScreenEx>(screenEvents_ScreenRemoved);
screenEvents.ScreenColorDepthChanged -= new Events.EventPlugin.EventValues<ScreenEx>(screenEvents_ScreenColorDepthChanged);
screenEvents.ScreenResolutionChanged -= new Events.EventPlugin.EventValues<ScreenEx>(screenEvents_ScreenResolutionChanged);
screenEvents.PrimaryScreenChanged -= new Events.EventPlugin.EventValues<ScreenEx>(screenEvents_PrimaryScreenChanged);
screenEvents.ScreenLocationChanged -= new Events.EventPlugin.EventValues<ScreenEx>(screenEvents_ScreenLocationChanged);
screenEvents.ScreenOrientationChanged -= new Events.EventPlugin.EventValues<ScreenEx>(screenEvents_ScreenOrientationChanged);
screenEvents.ScreenRefreshRateChanged -= new Events.EventPlugin.EventValues<ScreenEx>(screenEvents_ScreenRefreshRateChanged);
}
#endregion
#region Event handlers
void screenEvents_ScreenAdded(object sender, Events.EventArgsValue<ScreenEx> e)
{
this.Log.LogLineDate("The screen \"" + e.Value.Name + "\" was added (" + e.Value.Bounds.Width + "x" + e.Value.Bounds.Height + " " + e.Value.BitsPerPixel + "bit)", Log.Type.ScreenEvent);
}
void screenEvents_ScreenRemoved(object sender, Events.EventArgsValue<ScreenEx> e)
{
this.Log.LogLineDate("The screen \"" + e.Value.Name + "\" was removed", Log.Type.ScreenEvent);
}
void screenEvents_ScreenColorDepthChanged(object sender, Events.EventArgsValues<ScreenEx> e)
{
this.Log.LogLineDate("The screen color depth of \"" + e.NewValue.Name + "\" has changed: " + e.OldValue.BitsPerPixel + "bit -> " + e.NewValue.BitsPerPixel + "bit", Log.Type.ScreenEvent);
}
void screenEvents_ScreenResolutionChanged(object sender, Events.EventArgsValues<ScreenEx> e)
{
this.Log.LogLineDate("The resolution of \"" + e.NewValue.Name + "\" has changed: " + e.OldValue.Bounds.Width + "x" + e.OldValue.Bounds.Height + " -> " + e.NewValue.Bounds.Width + "x" + e.NewValue.Bounds.Height, Log.Type.ScreenEvent);
}
void screenEvents_PrimaryScreenChanged(object sender, Events.EventArgsValues<ScreenEx> e)
{
this.Log.LogLineDate("The primary screen is not \"" + e.OldValue.Name + "\" anymore but now \"" + e.NewValue.Name + "\"", Log.Type.ScreenEvent);
}
void screenEvents_ScreenLocationChanged(object sender, Events.EventArgsValues<ScreenEx> e)
{
this.Log.LogLineDate("The Location of \"" + e.NewValue.Name + "\" has changed: " + e.OldValue.Bounds.X + "|" + e.OldValue.Bounds.Y + " -> " + e.NewValue.Bounds.X + "|" + e.NewValue.Bounds.Y, Log.Type.ScreenEvent);
}
void screenEvents_ScreenOrientationChanged(object sender, Events.EventArgsValues<ScreenEx> e)
{
this.Log.LogLineDate("The orientation of \"" + e.NewValue.Name + "\" has changed: " + e.OldValue.Orientation + " -> " + e.NewValue.Orientation, Log.Type.ScreenEvent);
}
void screenEvents_ScreenRefreshRateChanged(object sender, Events.EventArgsValues<ScreenEx> e)
{
this.Log.LogLineDate("The refresh rate of \"" + e.NewValue.Name + "\" has changed: " + e.OldValue.Frequency + "Hz -> " + e.NewValue.Frequency + "Hz", Log.Type.ScreenEvent);
}
#endregion
}
}

View File

@ -0,0 +1,160 @@
using System;
using System.Drawing;
using Microsoft.Win32;
using System.Windows.Forms;
namespace Trigger.Tasks
{
/// <summary>
/// <para>Logs all events from <see cref="Trigger.Events.System"/></para>
/// </summary>
class LogSystemEvents : TaskPlugin
{
#region Properties
internal Main Main;
internal Log Log;
#endregion
#region Methods
public override bool Init(Main Main)
{
return Init(Main, new System.Diagnostics.Stopwatch());
}
public override bool Init(Main Main, System.Diagnostics.Stopwatch swInit)
{
if (!Main.EventMgr.PluginExists<Events.System>())
{
this.Log.LogLine("Task \"LogSystemEvents\" is missing EventPlugin \"System\"!", Log.Type.Error);
return false;
}
this.Main = Main;
this.Log = Main.Log;
swInit.Stop();
Events.System sysEvents = Main.EventMgr.GetPlugin<Events.System>();
swInit.Start();
sysEvents.InstalledFontsChanged += new Events.EventPlugin.Event(sysEvents_InstalledFontsChanged);
sysEvents.FontAdded += new Events.EventPlugin.EventValue<FontFamily>(sysEvents_FontAdded);
sysEvents.FontRemoved += new Events.EventPlugin.EventValue<FontFamily>(sysEvents_FontRemoved);
sysEvents.Logoff += new Events.EventPlugin.Event(sysEvents_Logoff);
sysEvents.Shutdown += new Events.EventPlugin.Event(sysEvents_Shutdown);
sysEvents.ConsoleConnect += new Events.EventPlugin.Event(sysEvents_ConsoleConnect);
sysEvents.ConsoleDisconnect += new Events.EventPlugin.Event(sysEvents_ConsoleDisconnect);
sysEvents.RemoteConnect += new Events.EventPlugin.Event(sysEvents_RemoteConnect);
sysEvents.RemoteDisconnect += new Events.EventPlugin.Event(sysEvents_RemoteDisconnect);
sysEvents.SessionLock += new Events.EventPlugin.Event(sysEvents_SessionLock);
sysEvents.SessionLogoff += new Events.EventPlugin.Event(sysEvents_SessionLogoff);
sysEvents.SessionLogon += new Events.EventPlugin.Event(sysEvents_SessionLogon);
sysEvents.SessionRemoteControl += new Events.EventPlugin.Event(sysEvents_SessionRemoteControl);
sysEvents.SessionUnlock += new Events.EventPlugin.Event(sysEvents_SessionUnlock);
return true;
}
public override void Dispose()
{
Events.System sysEvents = Main.EventMgr.GetPlugin<Events.System>();
sysEvents.InstalledFontsChanged -= new Events.EventPlugin.Event(sysEvents_InstalledFontsChanged);
sysEvents.FontAdded -= new Events.EventPlugin.EventValue<FontFamily>(sysEvents_FontAdded);
sysEvents.FontRemoved -= new Events.EventPlugin.EventValue<FontFamily>(sysEvents_FontRemoved);
sysEvents.Logoff -= new Events.EventPlugin.Event(sysEvents_Logoff);
sysEvents.Shutdown -= new Events.EventPlugin.Event(sysEvents_Shutdown);
sysEvents.ConsoleConnect -= new Events.EventPlugin.Event(sysEvents_ConsoleConnect);
sysEvents.ConsoleDisconnect -= new Events.EventPlugin.Event(sysEvents_ConsoleDisconnect);
sysEvents.RemoteConnect -= new Events.EventPlugin.Event(sysEvents_RemoteConnect);
sysEvents.RemoteDisconnect -= new Events.EventPlugin.Event(sysEvents_RemoteDisconnect);
sysEvents.SessionLock -= new Events.EventPlugin.Event(sysEvents_SessionLock);
sysEvents.SessionLogoff -= new Events.EventPlugin.Event(sysEvents_SessionLogoff);
sysEvents.SessionLogon -= new Events.EventPlugin.Event(sysEvents_SessionLogon);
sysEvents.SessionRemoteControl -= new Events.EventPlugin.Event(sysEvents_SessionRemoteControl);
sysEvents.SessionUnlock -= new Events.EventPlugin.Event(sysEvents_SessionUnlock);
}
#endregion
#region Event handlers
void sysEvents_InstalledFontsChanged(object sender, EventArgs e)
{
this.Log.LogLineDate("Tthe user added (a) font(s) to or removes (a) font(s) from the system", Log.Type.SystemEvent);
}
void sysEvents_FontAdded(object sender, Events.EventArgsValue<FontFamily> e)
{
this.Log.LogLineDate("The Font \"" + e.Value.Name + "\" was installed", Log.Type.SystemEvent);
}
void sysEvents_FontRemoved(object sender, Events.EventArgsValue<FontFamily> e)
{
this.Log.LogLineDate("The Font \"" + e.Value.Name + "\" was removed", Log.Type.SystemEvent);
}
void sysEvents_Logoff(object sender, EventArgs e)
{
this.Log.LogLineDate("The user is trying to log off", Log.Type.SystemEvent);
}
void sysEvents_Shutdown(object sender, EventArgs e)
{
this.Log.LogLineDate("The user is trying to shutdown the system", Log.Type.SystemEvent);
}
void sysEvents_ConsoleConnect(object sender, EventArgs e)
{
this.Log.LogLineDate("A session has been connected from the console", Log.Type.SystemEvent);
}
void sysEvents_ConsoleDisconnect(object sender, EventArgs e)
{
this.Log.LogLineDate("A session has been disconnected from the console", Log.Type.SystemEvent);
}
void sysEvents_RemoteConnect(object sender, EventArgs e)
{
this.Log.LogLineDate("A session has been connected from a remote connection", Log.Type.SystemEvent);
}
void sysEvents_RemoteDisconnect(object sender, EventArgs e)
{
this.Log.LogLineDate("A session has been disconnected from a remote connection", Log.Type.SystemEvent);
}
void sysEvents_SessionLock(object sender, EventArgs e)
{
this.Log.LogLineDate("A session has been locked", Log.Type.SystemEvent);
}
void sysEvents_SessionLogoff(object sender, EventArgs e)
{
this.Log.LogLineDate("A user has logged off from a session", Log.Type.SystemEvent);
}
void sysEvents_SessionLogon(object sender, EventArgs e)
{
this.Log.LogLineDate("A user has logged on to a session", Log.Type.SystemEvent);
}
void sysEvents_SessionRemoteControl(object sender, EventArgs e)
{
this.Log.LogLineDate("A session has changed its status to or from remote controlled mode", Log.Type.SystemEvent);
}
void sysEvents_SessionUnlock(object sender, EventArgs e)
{
this.Log.LogLineDate("A session has been unlocked", Log.Type.SystemEvent);
}
#endregion
}
}

View File

@ -9,11 +9,11 @@ namespace Trigger.Tasks.Plugins
class OnHibernate : TaskPlugin
{
#region Properties
internal const string PathKeePass = @"P:\Program Files (x86)\KeePass\KeePass.exe";
internal const string PathThunderbird = @"P:\Programme\Mozilla Thunderbird\thunderbird.exe";
internal const string PathFirefox = @"P:\Program Files (x86)\Mozilla Firefox\firefox.exe";
internal const string PathTrueCrypt = @"P:\Programme\TrueCrypt\TrueCrypt.exe";
internal const string PathTrueCryptContainer = @"Z:\Sonstiges\proxy.pac";
internal const string PathKeePass = @"C:\Program Files (x86)\KeePass 2\KeePass.exe";
internal const string PathThunderbird = @"C:\Program Files (x86)\Mozilla Thunderbird\thunderbird.exe";
internal const string PathFirefox = @"C:\Program Files (x86)\Mozilla Firefox\firefox.exe";
internal const string PathTrueCrypt = @"C:\Program Files\TrueCrypt\TrueCrypt.exe";
//internal const string PathTrueCryptContainer = @"Z:\Sonstiges\proxy.pac";
internal Main Main;
internal Log Log;
@ -92,8 +92,9 @@ namespace Trigger.Tasks.Plugins
}
Process.Start(PathTrueCrypt, "/d /f /s /q"); // force dismount
this.Log.LogLineDate("--> TrueCrypt volumes dismounted", Trigger.Log.Type.Action);
Process tc = Process.Start(PathTrueCrypt, "/d /f /s /q"); // force dismount
tc.WaitForExit();
this.Log.LogLineDate("--> TrueCrypt volumes dismounted: " + tc.ExitCode, Trigger.Log.Type.Action);
}
private void sysEvent_Resume(object sender, EventArgs e)