private void testButton_Click(object sender, EventArgs e)
        {
            if (!Save()) //Will pop up a message box with appropriate error.
            {
                return;
            }
            try
            {
                string sessionModeMsg = null;
                string eventModeMsg   = null;

                if ((bool)Settings.Store.SessionMode)
                {
                    ILoggerMode mode = LoggerModeFactory.getLoggerMode(LoggerMode.SESSION);
                    sessionModeMsg = mode.TestTable();
                }

                if ((bool)Settings.Store.EventMode)
                {
                    ILoggerMode mode = LoggerModeFactory.getLoggerMode(LoggerMode.EVENT);
                    eventModeMsg = mode.TestTable();
                }

                //Show one or both messages
                if (sessionModeMsg != null && eventModeMsg != null)
                {
                    MessageBox.Show(String.Format("Event Mode Table: {0}\nSession Mode Table: {1}", eventModeMsg, sessionModeMsg));
                }
                else
                {
                    MessageBox.Show(sessionModeMsg ?? eventModeMsg);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format("The following error occurred: {0}", ex.Message));
            }

            //Since the server info may change, close the connection
            LoggerModeFactory.closeConnection();
        }
예제 #2
0
        public void SessionChange(System.ServiceProcess.SessionChangeDescription changeDescription, SessionProperties properties)
        {
            m_logger.DebugFormat("SessionChange({0}) - ID: {1}", changeDescription.Reason.ToString(), changeDescription.SessionId);

            //If SessionMode is enabled, send event to it.
            if ((bool)Settings.Store.SessionMode)
            {
                ILoggerMode mode = LoggerModeFactory.getLoggerMode(LoggerMode.SESSION);
                mode.Log(changeDescription, properties);
            }

            //If EventMode is enabled, send event to it.
            if ((bool)Settings.Store.EventMode)
            {
                ILoggerMode mode = LoggerModeFactory.getLoggerMode(LoggerMode.EVENT);
                mode.Log(changeDescription, properties);
            }

            //Close the connection if it's still open
            LoggerModeFactory.closeConnection();
        }