Пример #1
0
 static void TestConnection()
 {
     try
     {
         EventLog log = new EventLog();
         log.Date = DateTime.Now;
         log.Message = "Testing connection";
         log.UserName = string.Join(";", StoplichtService.SystemInfo.GetCurrentActiveUsers());
         Helper.WriteEvent(log);
         Console.WriteLine("Added 'Testing connection' to EventLog table.");
     }
     catch (Exception ex)
     {
         Console.WriteLine("Test failed: " + ex.Message);
     }
 }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
 /// <summary>
 /// Create a new EventLog object.
 /// </summary>
 /// <param name="id">Initial value of the id property.</param>
 public static EventLog CreateEventLog(global::System.Decimal id)
 {
     EventLog eventLog = new EventLog();
     eventLog.id = id;
     return eventLog;
 }
Пример #5
0
 /// <summary>
 /// Deprecated Method for adding a new object to the EventLog EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToEventLog(EventLog eventLog)
 {
     base.AddObject("EventLog", eventLog);
 }