/// <summary>
        /// Handle the specified e.
        /// </summary>
        /// <param name='e'>
        /// Each event will be logged
        /// </param>
        /// <returns>
        /// <c>false</c>
        /// </returns>
        public override bool Handle(ISyncEvent e)
        {
            if(!(e is IRemoveFromLoggingEvent)) {
                Logger.Debug("Incomming Event: " + e.ToString());
            }

            return false;
        }
Exemple #2
0
        /// <summary>
        /// Handle the specified e.
        /// </summary>
        /// <param name='e'>
        /// Each event will be logged
        /// </param>
        /// <returns>
        /// <c>false</c>
        /// </returns>
        public override bool Handle(ISyncEvent e)
        {
            if (!(e is IRemoveFromLoggingEvent))
            {
                Logger.Debug("Incomming Event: " + e.ToString());
            }

            return(false);
        }
        /// <summary>
        /// Handle the specified event.
        /// </summary>
        /// <param name='e'>
        /// Event to handle.
        /// </param>
        public void Handle(ISyncEvent e) {
            for (int i = this.handler.Count - 1; i >= 0; i--) {
                var h = this.handler[i];
                if (h.Handle(e)) {
                    if (!(e is IRemoveFromLoggingEvent)) {
                        Logger.Debug(string.Format("Event {0} was handled by {1}", e.ToString(), h.GetType()));
                    }

                    return;
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// Handle the specified event.
        /// </summary>
        /// <param name='e'>
        /// Event to handle.
        /// </param>
        public void Handle(ISyncEvent e)
        {
            for (int i = this.handler.Count - 1; i >= 0; i--)
            {
                var h = this.handler[i];
                if (this.handler[i].Handle(e))
                {
                    if (!(e is IRemoveFromLoggingEvent))
                    {
                        Logger.Debug(string.Format("Event {0} was handled by {1}", e.ToString(), this.handler[i].GetType()));
                    }

                    return;
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// Adds the event to the queue.
        /// </summary>
        /// <param name="newEvent">New event.</param>
        /// <exception cref="InvalidOperationException">When Listener is already stopped</exception>
        public virtual void AddEvent(ISyncEvent newEvent)
        {
            if (this.alreadyDisposed)
            {
                Logger.Info(string.Format("Queue was already Disposed. Dropping Event: {0}", newEvent.ToString()));
                return;
            }

            if (this.IsStopped)
            {
                Logger.Info(string.Format("Queue was already Stopped. Dropping Event: {0}", newEvent.ToString()));
                return;
            }

            try {
                if (newEvent is ICountableEvent)
                {
                    var category = (newEvent as ICountableEvent).Category;
                    if (category != EventCategory.NoCategory)
                    {
                        lock (this.subscriberLock) {
                            this.categoryCounter.Increase(newEvent as ICountableEvent);
                            this.fullCounter.Increase(newEvent as ICountableEvent);
                        }
                    }
                }

                this.queue.Add(newEvent);
                if (!(newEvent is IRemoveFromLoggingEvent))
                {
                    Logger.Debug(string.Format("Added Event: {0}", newEvent.ToString()));
                }
            } catch (InvalidOperationException) {
                Logger.Info(string.Format("Queue was already Stopped. Dropping Event: {0}", newEvent.ToString()));
            }
        }
Exemple #6
0
        /// <summary>
        /// Adds the event to the queue.
        /// </summary>
        /// <param name="newEvent">New event.</param>
        /// <exception cref="InvalidOperationException">When Listener is already stopped</exception>
        public virtual void AddEvent(ISyncEvent newEvent)
        {
            if (this.alreadyDisposed)
            {
                Logger.Info(string.Format("Queue was already Disposed. Dropping Event: {0}", newEvent.ToString()));
                return;
            }

            if (this.IsStopped)
            {
                Logger.Info(string.Format("Queue was already Stopped. Dropping Event: {0}", newEvent.ToString()));
                return;
            }

            try {
                this.queue.Add(newEvent);
                if (!(newEvent is IRemoveFromLoggingEvent))
                {
                    Logger.Debug(string.Format("Added Event: {0}", newEvent.ToString()));
                }
            } catch (InvalidOperationException) {
                Logger.Info(string.Format("Queue was already Stopped. Dropping Event: {0}", newEvent.ToString()));
            }
        }
 /// <summary></summary>
 /// <param name="e"></param>
 /// <returns></returns>
 public override bool Handle(ISyncEvent e)
 {
     Logger.Debug("Incomming Event: " + e.ToString());
     return(false);
 }
Exemple #8
0
        private void Listen(BlockingCollection <ISyncEvent> queue, ISyncEventManager manager, WaitHandle waitHandle)
        {
            Logger.Debug("Starting to listen on SyncEventQueue");
            while (!queue.IsCompleted)
            {
                ISyncEvent syncEvent = null;

                // Blocks if number.Count == 0
                // IOE means that Take() was called on a completed collection.
                // Some other thread can call CompleteAdding after we pass the
                // IsCompleted check but before we call Take.
                // In this example, we can simply catch the exception since the
                // loop will break on the next iteration.
                try {
                    syncEvent = queue.Take();
                } catch (InvalidOperationException) {
                }

                if (syncEvent != null)
                {
                    try {
                        if (this.suspend)
                        {
                            Logger.Debug("Suspending sync");
                            waitHandle.WaitOne();
                            Logger.Debug("Continue sync");
                        }

                        manager.Handle(syncEvent);
                    } catch (CmisConnectionException connectionException) {
                        this.AddEvent(new CmisConnectionExceptionEvent(connectionException));
                    } catch (Exception e) {
                        Logger.Error(string.Format("Exception in EventHandler on Event {0}: ", syncEvent.ToString()), e);
                    }

                    if (syncEvent is ICountableEvent)
                    {
                        var category = (syncEvent as ICountableEvent).Category;
                        if (category != EventCategory.NoCategory)
                        {
                            lock (this.subscriberLock) {
                                this.fullCounter.Decrease(syncEvent as ICountableEvent);
                                this.categoryCounter.Decrease(syncEvent as ICountableEvent);
                            }
                        }
                    }
                }
            }

            Logger.Debug("Stopping to listen on SyncEventQueue");
        }
        /// <summary>
        /// Adds the event to the queue.
        /// </summary>
        /// <param name="newEvent">New event.</param>
        /// <exception cref="InvalidOperationException">When Listener is already stopped</exception>
        public virtual void AddEvent(ISyncEvent newEvent) {
            if (this.alreadyDisposed) {
                Logger.Info(string.Format("Queue was already Disposed. Dropping Event: {0}", newEvent.ToString()));
                return;
            }

            if (this.IsStopped) {
                Logger.Info(string.Format("Queue was already Stopped. Dropping Event: {0}", newEvent.ToString()));
                return;
            }

            try {
                if (newEvent is ICountableEvent) {
                    var category = (newEvent as ICountableEvent).Category;
                    if (category != EventCategory.NoCategory) {
                        lock (this.subscriberLock) {
                            this.categoryCounter.Increase(newEvent as ICountableEvent);
                            this.fullCounter.Increase(newEvent as ICountableEvent);
                        }
                    }
                }

                this.queue.Add(newEvent);
                if (!(newEvent is IRemoveFromLoggingEvent)) {
                    Logger.Debug(string.Format("Added Event: {0}", newEvent.ToString()));
                }
            } catch(InvalidOperationException) {
                Logger.Info(string.Format("Queue was already Stopped. Dropping Event: {0}", newEvent.ToString()));
            }
        }
Exemple #10
0
 public override bool Handle(ISyncEvent e)
 {
     Logger.Debug("Incomming Event: " + e.ToString());
     return false;
 }