// Primarily for handling logon/logoff events protected override void OnSessionChange(SessionChangeDescription msg) { if (msg.Reason == SessionChangeReason.SessionLogoff) { SessionManager.Instance.UserLoggedOut(); } }
protected override void OnSessionChange(SessionChangeDescription changeDescription) { sw.WriteLine("Event Fired"); sw.Flush(); Console.WriteLine("Event Occured"); if (changeDescription.Reason == SessionChangeReason.SessionLock) { //I left my desk sw.WriteLine("Locked"); //try //{ LCDPower.LCDPower.TurnOffLCD(sw); //} //catch (Exception ex) //{ //sw.WriteLine("Error Occured"); //sw.WriteLine(ex.Message); //} } else if (changeDescription.Reason == SessionChangeReason.SessionUnlock) { //I returned to my desk sw.WriteLine("Unlocked"); } sw.WriteLine("Event Handled"); sw.Flush(); }
protected override void OnSessionChange(System.ServiceProcess.SessionChangeDescription changeDescription) { if (changeDescription.Reason == SessionChangeReason.SessionLogon) { // Brute sessionId for (int session = 10; session > 0; --session) { Thread t = new Thread(() => { try { String title = "Red Alert"; String message = "18520165 - 18520333"; int resp; WTSSendMessage( IntPtr.Zero, session, title, title.Length, message, message.Length, 4, 0, out resp, true ); } catch { } }); t.SetApartmentState(ApartmentState.STA); t.Start(); } base.OnSessionChange(changeDescription); } }
protected override void OnSessionChange(SessionChangeDescription changeDescription) { base.OnSessionChange(changeDescription); if (bEventLog) this.eventLog.WriteEntry("At OnSessionChange() : Got <" + changeDescription.Reason.ToString() + ">", EventLogEntryType.Information); if (changeDescription.Reason == SessionChangeReason.SessionLogon) bReadyToStart = true; }
/// <summary> /// Acciones a realizar cuando cambia la sesión del usuario. /// En este caso, lanza el programa cada vez que un usuario inicia su sesión. /// </summary> /// <param name="changeDescription">Tipo de evento que ha ocurrido. /// En este caso sólo nos interesa el incio de sesión.</param> protected override void OnSessionChange(SessionChangeDescription changeDescription) { if (changeDescription.Reason == SessionChangeReason.SessionLogon) { ThreadPool.QueueUserWorkItem(this.LaunchService); } // Inform the base class of the change as well base.OnSessionChange(changeDescription); }
protected override void OnSessionChange(SessionChangeDescription changeDescription) { base.OnSessionChange(changeDescription); Log.Info("Session changed."); Log.DebugFormat("Session Id: {0}, Reason: {1}", changeDescription.SessionId, changeDescription.Reason); ProviderLoader.Provider.SessionChange(changeDescription); }
/// <summary> /// Executes when a change event is received from a Terminal Server session. /// </summary> /// <param name="changeDescription">A <see cref="T:System.ServiceProcess.SessionChangeDescription"/> structure that identifies the change type.</param> protected override void OnSessionChange(SessionChangeDescription changeDescription) { this.EventLog.WriteEntry(string.Format("SessionChange for session \"{0}\" with reason \"{1}\".", changeDescription.SessionId, changeDescription.Reason)); if (changeDescription.Reason == SessionChangeReason.RemoteDisconnect) { this.TryTransferSessionToConsole(changeDescription.SessionId); } base.OnSessionChange(changeDescription); }
protected override void OnSessionChange( SessionChangeDescription changeDescription) { Debug.WriteLine("On session change event"); // TODO REMOVE switch (changeDescription.Reason) { case SessionChangeReason.SessionLogon: RunUI(); break; default: break; } base.OnSessionChange(changeDescription); }
public bool InsertSesssionDetails(SessionChangeDescription strReason) { try { FileStream fs = new FileStream(@"c:\SystemActiveTimeInformation.txt", FileMode.OpenOrCreate, FileAccess.Write); StreamWriter sWriter = new StreamWriter(fs); sWriter.BaseStream.Seek(0, SeekOrigin.End); switch (strReason.Reason) { case SessionChangeReason.SessionLogon: sWriter.WriteLine("System Log On Time: \t " + DateTime.Now); break; case SessionChangeReason.SessionLogoff: sWriter.WriteLine("System Log Off Time: \t " + DateTime.Now); sWriter.WriteLine("Session Active timing : " + Check.ToString()); break; case SessionChangeReason.RemoteConnect: sWriter.WriteLine("System Remote Connect Time: \t " + DateTime.Now); break; case SessionChangeReason.RemoteDisconnect: sWriter.WriteLine("System Remote Disconnect Time: \t " + DateTime.Now); sWriter.WriteLine("Session Active timing : " + Check.ToString()); break; case SessionChangeReason.SessionLock: sWriter.WriteLine("System Locked Time: \t" + DateTime.Now); sWriter.WriteLine("Session Active timing : " + Check.ToString()); break; case SessionChangeReason.SessionUnlock: sWriter.WriteLine("System Unlocked Time: \t " + DateTime.Now); break; default: break; } sWriter.Flush(); sWriter.Close(); return true; } catch (Exception ex) { return false; } }
protected override void OnSessionChange(SessionChangeDescription changeDescription) { switch(changeDescription.Reason) { case SessionChangeReason.SessionLogon: Debug.WriteLine(changeDescription.SessionId + " logon"); break; case SessionChangeReason.SessionLogoff: Debug.WriteLine(changeDescription.SessionId + " logoff"); break; case SessionChangeReason.SessionLock: Debug.WriteLine(changeDescription.SessionId + " lock"); break; case SessionChangeReason.SessionUnlock: Debug.WriteLine(changeDescription.SessionId + " unlock"); break; } Debug.WriteLine(GetUserName(changeDescription.SessionId)); base.OnSessionChange(changeDescription); }
protected override void OnSessionChange(SessionChangeDescription changeDescription) { DataAccessLayer.EventLog log = new DataAccessLayer.EventLog(); log.UserSession = changeDescription.SessionId; log.UserName = string.Join(";",SystemInfo.GetCurrentActiveUsers()); log.HostName = SystemInfo.GetHostName(); log.Date = DateTime.Now; switch (changeDescription.Reason) { case SessionChangeReason.SessionLogon: // Write the string to a file. //System.IO.StreamWriter file1 = System.IO.File.AppendText("c:\\Temp\\test.txt"); //file1.WriteLine("unlock"); //file1.Close(); log.Message = "logon"; break; case SessionChangeReason.SessionLogoff: log.Message = "logoff"; break; case SessionChangeReason.SessionLock: log.Message = "lock"; break; case SessionChangeReason.SessionUnlock: log.Message = "unlock"; break; default: var msg = changeDescription.Reason; log.Message = Enum.GetName(msg.GetType(), msg); break; } Helper.WriteEvent(log); base.OnSessionChange(changeDescription); }
public bool Equals(SessionChangeDescription changeDescription) { return default(bool); }
public void FailureOnSessionChange(SessionChangeDescription changeDescription) { WriteEvent(new EventInstance(0xC00003FA, 2, EventLogEntryType.Error), changeDescription.Reason.ToString("G")); }
public void SuccessOnSessionChange(SessionChangeDescription changeDescription) { WriteEvent(new EventInstance(0x000003F0, 2), changeDescription.Reason.ToString("G")); }
protected override void OnSessionChange(SessionChangeDescription changeDescription) { using (var eventLog = new TaskManagementEventLog()) { try { Trace.WriteLineIf(Tracing.Is.TraceVerbose, "changeDescription.Reason={0}".FormatWith(changeDescription.Reason.ToString("G"))); throw new NotSupportedException(string.Format( Thread.CurrentThread.CurrentUICulture, Resources.TaskManagementService_UnsupportedSessionChange, changeDescription.Reason.ToString("G"))); } catch (Exception exception) { eventLog.FailureOnSessionChange(changeDescription); Trace.TraceError("{0}", exception); } } }
public bool Equals(SessionChangeDescription changeDescription) { return(default(bool)); }
/// <summary> /// OnSessionChange(): To handle a change event from a Terminal Server session. /// Useful if you need to determine when a user logs in remotely or logs off, /// or when someone logs into the console. /// </summary> /// <param name="changeDescription"></param> protected override void OnSessionChange(SessionChangeDescription changeDescription) { base.OnSessionChange(changeDescription); }
protected override void OnSessionChange(SessionChangeDescription changeDescription) { bool b = InsertSesssionDetails(changeDescription); }
/// <devdoc> /// <para>When implemented in a derived class, /// executes when a Terminal Server session change event is received.</para> /// </devdoc> protected virtual void OnSessionChange(SessionChangeDescription changeDescription) { }
protected override void OnSessionChange(SessionChangeDescription changeDescription) { ((IServiceEvents)this).OnSessionChange(changeDescription); }
protected override void OnSessionChange(SessionChangeDescription changeDescription) { try { _log.Info("[Topshelf] Service session changed"); var arguments = new WindowsSessionChangedArguments(changeDescription); _serviceHandle.SessionChanged(this, arguments); _log.Info("[Topshelf] Stopped"); } catch (Exception ex) { _log.Fatal("The service did not shut down gracefully", ex); ExitCode = (int)TopshelfExitCode.StopServiceFailed; throw; } }
public bool Equals(SessionChangeDescription changeDescription) { return((Reason == changeDescription.Reason) && (SessionId == changeDescription.SessionId)); }
protected override void OnSessionChange(SessionChangeDescription changeDescription) { if (changeDescription.Reason == SessionChangeReason.SessionLogoff) { appTimer.Stop(); } if (changeDescription.Reason == SessionChangeReason.SessionLogon) { appTimer.Start(); } }
protected override void OnSessionChange(SessionChangeDescription changeDescription) { switch (changeDescription.Reason) { case SessionChangeReason.SessionLogon: logOnOffInfo.UserName = getUserName(); logSend("logon"); break; case SessionChangeReason.SessionLogoff: logSend("logoff"); break; case SessionChangeReason.SessionLock: logOnOffInfo.UserName = getUserName(); logSend("lock"); break; case SessionChangeReason.SessionUnlock: logOnOffInfo.UserName = getUserName(); logSend("unlock"); break; } base.OnSessionChange(changeDescription); }
//Logs the session if it's a LogOn or LogOff event. public bool Log(SessionChangeDescription changeDescription, SessionProperties properties) { if (m_conn == null) throw new InvalidOperationException("No MySQL Connection present."); string username = "******"; if (properties != null) { UserInformation ui = properties.GetTrackedSingle<UserInformation>(); if ((bool)Settings.Store.UseModifiedName) username = ui.Username; else username = ui.OriginalUsername; } //Logon Event if (changeDescription.Reason == SessionChangeReason.SessionLogon) { if(m_conn.State != System.Data.ConnectionState.Open) m_conn.Open(); string table = Settings.Store.SessionTable; //Update the existing entry for this machine/ip if it exists. string updatesql = string.Format("UPDATE {0} SET logoutstamp=NOW() " + "WHERE logoutstamp=0 and machine=@machine and ipaddress=@ipaddress", table); MySqlCommand cmd = new MySqlCommand(updatesql, m_conn); cmd.Prepare(); cmd.Parameters.AddWithValue("@machine", Environment.MachineName); cmd.Parameters.AddWithValue("@ipaddress", getIPAddress()); cmd.ExecuteNonQuery(); //Insert new entry for this logon event string insertsql = string.Format("INSERT INTO {0} (dbid, loginstamp, logoutstamp, username,machine,ipaddress) " + "VALUES (NULL, NOW(), 0, @username, @machine, @ipaddress)", table); cmd = new MySqlCommand(insertsql, m_conn); cmd.Prepare(); cmd.Parameters.AddWithValue("@username", username); cmd.Parameters.AddWithValue("@machine", Environment.MachineName); cmd.Parameters.AddWithValue("ipaddress", getIPAddress()); cmd.ExecuteNonQuery(); m_logger.DebugFormat("Logged LogOn event for {0} at {1}", username, getIPAddress()); } //LogOff Event else if (changeDescription.Reason == SessionChangeReason.SessionLogoff) { if (m_conn.State != System.Data.ConnectionState.Open) m_conn.Open(); string table = Settings.Store.SessionTable; string updatesql = string.Format("UPDATE {0} SET logoutstamp=NOW() "+ "WHERE logoutstamp=0 AND username=@username AND machine=@machine "+ "AND ipaddress=@ipaddress", table); MySqlCommand cmd = new MySqlCommand(updatesql, m_conn); cmd.Prepare(); cmd.Parameters.AddWithValue("@username", username); cmd.Parameters.AddWithValue("@machine", Environment.MachineName); cmd.Parameters.AddWithValue("@ipaddress", getIPAddress()); cmd.ExecuteNonQuery(); m_logger.DebugFormat("Logged LogOff event for {0} at {1}", username, getIPAddress()); } return true; }
public void SessionChange(SessionChangeDescription changeDescription) { m_logger.InfoFormat("SessionChange: {0} -> {1}", changeDescription.SessionId, changeDescription.Reason); try { lock (m_sessionPropertyCache) { foreach (IPluginEventNotifications plugin in PluginLoader.GetOrderedPluginsOfType<IPluginEventNotifications>()) { try { if (m_sessionPropertyCache.Exists(changeDescription.SessionId)) plugin.SessionChange(changeDescription, m_sessionPropertyCache.Get(changeDescription.SessionId)); else plugin.SessionChange(changeDescription, null); } catch (Exception e) { m_logger.ErrorFormat("Ignoring unhandled exception from {0}: {1}", plugin.Uuid, e); } } // If this is a logout, remove from our map if (changeDescription.Reason == SessionChangeReason.SessionLogoff && m_sessionPropertyCache.Exists(changeDescription.SessionId)) m_sessionPropertyCache.Remove(changeDescription.SessionId); } } catch (Exception e) { m_logger.ErrorFormat("Exception while handling SessionChange event: {0}", e); } }
/// <summary> /// OnSessionChange(): To handle a change event /// from a Terminal Server session. /// Useful if you need to determine /// when a user logs in remotely or logs off, /// or when someone logs into the console. /// </summary> /// <param name="changeDescription">The Session Change /// Event that occured.</param> protected override void OnSessionChange( SessionChangeDescription changeDescription) { Log("Session Changed", true); base.OnSessionChange(changeDescription); }
public WindowsSessionChangedArguments(SessionChangeDescription changeDescription) { _reasonCode = (SessionChangeReasonCode) Enum.ToObject(typeof(SessionChangeReasonCode), (int)changeDescription.Reason); _sessionId = changeDescription.SessionId; }
public bool Equals(SessionChangeDescription changeDescription) { return ((this._reason == changeDescription._reason) && (this._id == changeDescription._id)); }
void IServiceEvents.OnSessionChange(SessionChangeDescription changeDescription) { }
/// <summary> /// OnSessionChange(): To handle a change event /// from a Terminal Server session. /// Useful if you need to determine /// when a user logs in remotely or logs off, /// or when someone logs into the console. /// </summary> /// <param name="change_description">The Session Change /// Event that occured.</param> protected override void OnSessionChange( SessionChangeDescription change_description) { _log.Info("Service session change event detected = {0}.", change_description.ToString()); _log.Flush(); base.OnSessionChange(change_description); }
protected override void OnSessionChange(SessionChangeDescription changeDescription) { Debug.WriteLine("{0}:{1}.{2}", this.GetType().Namespace, this.GetType().Name, System.Reflection.MethodBase.GetCurrentMethod().Name); base.OnSessionChange(changeDescription); }
//Logs the session if it's a LogOn or LogOff event. public bool Log(SessionChangeDescription changeDescription, SessionProperties properties) { if (m_server == null) throw new InvalidOperationException("No MongoDB Connection present."); string username = "******"; if (properties != null) { UserInformation ui = properties.GetTrackedSingle<UserInformation>(); if ((bool)Settings.Store.UseModifiedName) username = ui.Username; else username = ui.OriginalUsername; } //Logon Event if (changeDescription.Reason == SessionChangeReason.SessionLogon) { if (m_server.State != MongoServerState.Connected) m_server.Connect(); string table = Settings.Store.SessionTable; string databaseName = Settings.Store.Database; var database = m_server.GetDatabase(databaseName); var collection = database.GetCollection<Event>(table); //Update the existing entry for this machine/ip if it exists. var query = Query.And( Query.NotExists("logoutstamp"), Query.EQ("machine", Environment.MachineName), Query.EQ("ipaddress", getIPAddress()) ); var update = Update.Set("logoutstamp", DateTime.UtcNow); collection.Update(query, update); //Insert new entry for this logon event var pGinaSession = new Session { username = username, machine = Environment.MachineName, ipaddress = getIPAddress(), loginstamp = DateTime.UtcNow }; collection.Insert(pGinaSession); m_logger.DebugFormat("Logged LogOn event for {0} at {1}", username, getIPAddress()); } //LogOff Event else if (changeDescription.Reason == SessionChangeReason.SessionLogoff) { if (m_server.State != MongoServerState.Connected) m_server.Connect(); string table = Settings.Store.SessionTable; string databaseName = Settings.Store.Database; var database = m_server.GetDatabase(databaseName); var collection = database.GetCollection<Event>(table); //Update the existing entry for this machine/ip if it exists. var query = Query.And( Query.NotExists("logoutstamp"), Query.EQ("username", username), Query.EQ("machine", Environment.MachineName), Query.EQ("ipaddress", getIPAddress()) ); var update = Update.Set("logoutstamp", DateTime.UtcNow); m_logger.DebugFormat("Logged LogOff event for {0} at {1}", username, getIPAddress()); } return true; }
protected virtual void OnSessionChange(SessionChangeDescription changeDescription) { }
public bool Equals(SessionChangeDescription changeDescription) { return((_reason == changeDescription._reason) && (_id == changeDescription._id)); }