/// <summary>
 /// Stops the agent.
 /// </summary>
 public void StopSession()
 {
     if (queueManager != null)
     {
         queueManager.Dispose();
         queueManager = null;
     }
     state = BatchingLogAgentStates.Disabled;
 }
        /// <summary>
        /// Used to spin up the agent.
        /// </summary>
        /// <returns>Indicates success</returns>
        public bool StartSession()
        {
            if (state == BatchingLogAgentStates.Enabled)
            {
                throw new Exception("Session is already started");
            }

            // load the config file
            if (Configuration == null)
            {
                LoadConfig();
            }

            try
            {
                if (Configuration.LoggingEnabled)
                {
                    // initialize new queue manager
                    queueManager = new QueueManager(this);
                    queueManager.BatchSending     += queueManager_BatchSending;
                    queueManager.BatchSendSuccess += queueManager_BatchSendSuccess;
                    queueManager.BatchSendFailed  += queueManager_BatchSendFailed;

                    // set SessionId & StartTime
                    SessionId        = Guid.NewGuid();
                    SessionStartTime = DateTime.Now;

                    // enable logging
                    state = BatchingLogAgentStates.Enabled;
                }
                else
                {
                    state = BatchingLogAgentStates.Disabled;
                }

                return(true);
            }
            catch (Exception ex)
            {
                BroadcastException(ex);
                state = BatchingLogAgentStates.Disabled;
                return(false);
            }
        }
        private BatchingLogAgent(Uri configUri, bool LoadConfigImmediately)
            : this()
        {
            try
            {
                ConfigUri = configUri;

                // load the config file
                if (LoadConfigImmediately)
                {
                    LoadConfig();
                }
            }
            catch (Exception ex)
            {
                state = BatchingLogAgentStates.Failed;
                BroadcastException(ex);
            }
        }
        /// <summary>
        /// Used to spin up the agent.
        /// </summary>
        /// <returns>Indicates success</returns>
        public bool StartSession()
        {
            if (state == BatchingLogAgentStates.Enabled)
                throw new Exception("Session is already started");

            try
            {
                if (Configuration.LoggingEnabled)
                {
                    // initialize new queue manager
                    queueManager = new QueueManager(this);
                    queueManager.BatchSending += queueManager_BatchSending;
                    queueManager.BatchSendSuccess += queueManager_BatchSendSuccess;
                    queueManager.BatchSendFailed += queueManager_BatchSendFailed;

                    // set SessionId & StartTime
                    SessionId = Guid.NewGuid();
                    SessionStartTime = DateTimeOffset.Now;

                    // enable logging
                    state = BatchingLogAgentStates.Enabled;
                }
                else
                    state = BatchingLogAgentStates.Disabled;

                return true;
            }
            catch (Exception ex)
            {
                BroadcastException(ex);
                state = BatchingLogAgentStates.Disabled;
                return false;
            }
        }
        internal BatchingLogAgent()
        {
            queue = new Queue<ILog>();

            state = BatchingLogAgentStates.Disabled;
        }
 /// <summary>
 /// Stops the agent.
 /// </summary>
 public void StopSession()
 {
     if (queueManager != null)
     {
         queueManager.Dispose();
         queueManager = null;
     }
     state = BatchingLogAgentStates.Disabled;
 }
        internal BatchingLogAgent()
        {
            queue = new Queue <ILog>();

            state = BatchingLogAgentStates.Disabled;
        }
        protected BatchingLogAgent()
        {
            queue = new Queue <Log>();

            state = BatchingLogAgentStates.NotInitialized;
        }
        private BatchingLogAgent(Uri configUri, bool LoadConfigImmediately)
            : this()
        {
            try
            {
                ConfigUri = configUri;

                // load the config file
                if (LoadConfigImmediately)
                    LoadConfig();
            }
            catch (Exception ex)
            {
                state = BatchingLogAgentStates.Failed;
                BroadcastException(ex);
            }
        }
        protected BatchingLogAgent()
        {
            queue = new Queue<Log>();

            state = BatchingLogAgentStates.NotInitialized;
        }