Пример #1
0
        void OnCheckRepositoryTimer(object sender, System.Timers.ElapsedEventArgs e)
        {
            repoProvider = AppData.SessionRepositoryProviderBase.GetProvider();

#if DEBUG
            if (debugDBDown)
            {
                repoProvider = AppData.SessionLocalRepositoryProvider.Instance;
            }
            else
            {
                repoProvider = new AppData.SessionDbProvider();
                repoProvider.MergeRepositories();
            }
#endif
        }
Пример #2
0
        public static SessionRepositoryProviderBase GetProvider()
        {
            SessionRepositoryProviderBase baseProvider = null;

            Utils.DatabaseUtils dbu = new Utils.DatabaseUtils(LogonTracerConfig.Instance.ConnectionString);

            if (dbu.CheckDbAvailability())
            {
                baseProvider = new SessionDbProvider();
                baseProvider.MergeRepositories();
            }
            else
            {
                baseProvider = SessionLocalRepositoryProvider.Instance;
            }

            return(baseProvider);
        }
Пример #3
0
        public void Initialize()
        {
            checkProgramActivityTimer           = new System.Timers.Timer();
            checkProgramActivityTimer.Interval  = TimeSpan.FromMinutes(1).TotalMilliseconds;
            checkProgramActivityTimer.AutoReset = true;
            checkProgramActivityTimer.Elapsed  += new System.Timers.ElapsedEventHandler(OnProgramActivityTimer);

            troubleShootingTimer           = new System.Timers.Timer();
            troubleShootingTimer.Interval  = TimeSpan.FromHours(12).TotalMilliseconds;
            troubleShootingTimer.AutoReset = true;
            troubleShootingTimer.Elapsed  += new System.Timers.ElapsedEventHandler(OnTroubleShootingTimer);

            manager = new TerminalServicesManager();

            if (LogonTracerConfig.Instance.MonitorMode == MonitorMode.Local)
            {
                LogonTracerConfig.Instance.ServersToTrace = new string[] { Environment.MachineName }
            }
            ;

            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            inputActivityTimer           = new System.Timers.Timer();
            inputActivityTimer.Interval  = LogonTracerConfig.Instance.InputActivityTimePeriod * TimeSpan.FromMinutes(1).TotalMilliseconds;
            inputActivityTimer.AutoReset = true;
            inputActivityTimer.Elapsed  += new System.Timers.ElapsedEventHandler(OnInputActivityTimer);

            sessionStateUpdateTimer           = new System.Timers.Timer();
            sessionStateUpdateTimer.Interval  = LogonTracerConfig.Instance.SessionSavePeriod * TimeSpan.FromSeconds(1).TotalMilliseconds;
            sessionStateUpdateTimer.AutoReset = true;
            sessionStateUpdateTimer.Elapsed  += new System.Timers.ElapsedEventHandler(OnSessionStateUpdateTimer);

            checkRepositoryTimer           = new System.Timers.Timer();
            checkRepositoryTimer.Interval  = LogonTracerConfig.Instance.CheckRepositoryTimePeriod * TimeSpan.FromMinutes(1).TotalMilliseconds;
            checkRepositoryTimer.AutoReset = true;
            checkRepositoryTimer.Elapsed  += new System.Timers.ElapsedEventHandler(OnCheckRepositoryTimer);

            repoProvider = AppData.SessionRepositoryProviderBase.GetProvider();
            debugDBDown  = false;
        }

        void OnTroubleShootingTimer(object sender, System.Timers.ElapsedEventArgs e)
        {
            logonTracerAdministration.FetchUnregisteredUsers();
            logonTracerAdministration.ClearOrphanedSessions();
        }

        void OnProgramActivityTimer(object sender, System.Timers.ElapsedEventArgs e)
        {
            if (!inputActivityTimer.Enabled && !sessionStateUpdateTimer.Enabled && !checkRepositoryTimer.Enabled)
            {
                RegisterSessions();
            }
        }

        void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            StopWatching();
            Exception ex = (Exception)e.ExceptionObject;

            LoggingUtils.DefaultLogger.AddLogMessage(this, MessageType.Error, "Unhandled Exception. Type:{0}. Message: {1}", ex.GetType(), ex.Message);
        }