Example #1
0
        protected override void OnPowerChange(PowerChangeEvent e)
        {
            ITerminalServicesSession consoleSession = this[null];

            string clientUser = consoleSession.GetClientUser();

            if (Context.DebugLog)
            {
                var sb = new StringBuilder();
                sb.Append($"PowerEvent: Status={e.Status} ");

                sb.Append("(");
                sb.Append($"Console: SessionId={consoleSession.SessionId}, ");
                if (clientUser.Length > 0)
                {
                    sb.Append($"User={clientUser}, ");
                }
                sb.Append($"State={consoleSession.ConnectionState}");
                if (consoleSession.ConnectionState == Cassia.ConnectionState.Active)
                {
                    sb.Append($"|{(ConsoleLocked ? "Locked" : "Unlocked")}");
                }
                sb.Append(")");

                EventLog.WriteEntry(sb.ToString(), EventLogEntryType.Information, 90);
            }
        }
Example #2
0
 protected override void OnPowerChange(PowerChangeEvent e)
 {
     if (e.Status == PowerBroadcastStatus.Suspend)
     {
         timer.Stop();
     }
 }