public void SessionChange(int SessionId, System.ServiceProcess.SessionChangeReason Reason, SessionProperties properties) { if (properties == null) { return; } m_logger.DebugFormat("SessionChange({0}) - ID: {1}", Reason.ToString(), SessionId); //If SessionMode is enabled, send event to it. if ((bool)Settings.Store.SessionMode) { ILoggerMode mode = LoggerModeFactory.getLoggerMode(LoggerMode.SESSION); mode.Log(SessionId, Reason, properties); } //If EventMode is enabled, send event to it. if ((bool)Settings.Store.EventMode) { ILoggerMode mode = LoggerModeFactory.getLoggerMode(LoggerMode.EVENT); mode.Log(SessionId, Reason, properties); } //Close the connection if it's still open LoggerModeFactory.closeConnection(); }
//Logs the event if it's an event we track according to the registry. public bool Log(int SessionId, System.ServiceProcess.SessionChangeReason Reason, pGina.Shared.Types.SessionProperties properties) { //Get the logging message for this event. string msg = null; switch (Reason) { case System.ServiceProcess.SessionChangeReason.SessionLogon: msg = LogonEvent(SessionId, properties); break; case System.ServiceProcess.SessionChangeReason.SessionLogoff: msg = LogoffEvent(SessionId, properties); break; case System.ServiceProcess.SessionChangeReason.SessionLock: msg = SessionLockEvent(SessionId, properties); break; case System.ServiceProcess.SessionChangeReason.SessionUnlock: msg = SessionUnlockEvent(SessionId, properties); break; case System.ServiceProcess.SessionChangeReason.SessionRemoteControl: msg = SesionRemoteControlEvent(SessionId, properties); break; case System.ServiceProcess.SessionChangeReason.ConsoleConnect: msg = ConsoleConnectEvent(SessionId, properties); break; case System.ServiceProcess.SessionChangeReason.ConsoleDisconnect: msg = ConsoleDisconnectEvent(SessionId, properties); break; case System.ServiceProcess.SessionChangeReason.RemoteConnect: msg = RemoteConnectEvent(SessionId, properties); break; case System.ServiceProcess.SessionChangeReason.RemoteDisconnect: msg = RemoteDisconnectEvent(SessionId, properties); break; } m_logger.DebugFormat("SessionChange({0}) - Message: {1}", Reason.ToString(), msg); //Check if there is a message to log if (!string.IsNullOrEmpty(msg)) { if (m_conn == null) { throw new InvalidOperationException("No MySQL Connection present."); } //Send it to the server logToServer(msg); } return(true); //No msg to log }