示例#1
0
 public void SaveEvent(IMessageContext eventContext, string subscriptionName,
                       IEnumerable <IMessageContext> commandContexts,
                       IEnumerable <IMessageContext> messageContexts)
 {
     lock (EventLock)
     {
         var @event = Events.Find(eventContext.MessageID);
         if (@event == null)
         {
             @event = BuildEvent(eventContext);
             Events.Add(@event);
         }
         HandledEvents.Add(new HandledEvent(@event.ID, subscriptionName, DateTime.Now));
         commandContexts.ForEach(commandContext =>
         {
             commandContext.CorrelationID = eventContext.MessageID;
             // don't save command here like event that would be published to other bounded context
             UnSentCommands.Add(new UnSentCommand(commandContext));
         });
         messageContexts.ForEach(messageContext => {
             messageContext.CorrelationID = eventContext.MessageID;
             Events.Add(BuildEvent(messageContext));
             UnPublishedEvents.Add(new UnPublishedEvent(messageContext));
         });
         SaveChanges();
     }
 }
示例#2
0
        /// <summary>
        /// Removes one event control from the displayed event controls
        /// </summary>
        /// <param name="control"></param>
        private void RemoveEventControl(EventControl control)
        {
            HandledEvents.Remove(control.ModelEvent);
            control.ModelEvent = null;
            control.Parent     = null;

            Controls.Remove(control);
            control.Dispose();
        }
示例#3
0
        /// <summary>
        /// Removes all event controls in the panel
        /// </summary>
        private void Clear()
        {
            EventsAtTime.Clear();
            List <EventControl> events = new List <EventControl>();

            events.AddRange(HandledEvents.Values);
            foreach (EventControl eventControl in events)
            {
                RemoveEventControl(eventControl);
            }
            HandledEvents.Clear();
        }
示例#4
0
        public void SaveFailHandledEvent(IMessageContext eventContext, string subscriptionName, Exception e,
                                         params IMessageContext[] messageContexts)
        {
            HandledEvents.Add(new FailHandledEvent(eventContext.MessageID, subscriptionName, DateTime.Now, e));

            messageContexts.ForEach(messageContext =>
            {
                messageContext.CorrelationID = eventContext.MessageID;
                //Events.Add(BuildEvent(messageContext));
                UnPublishedEvents.Add(new UnPublishedEvent(messageContext));
            });
            SaveChanges();
        }
示例#5
0
 public void SaveFailHandledEvent(IMessageContext eventContext, string subscriptionName, Exception e)
 {
     lock (EventLock)
     {
         var @event = Events.Find(eventContext.MessageID);
         if (@event == null)
         {
             @event = BuildEvent(eventContext);
             Events.Add(@event);
         }
         HandledEvents.Add(new FailHandledEvent(@event.ID, subscriptionName, DateTime.Now, e));
         SaveChanges();
     }
 }
示例#6
0
        public override Task SaveFailHandledEventAsync(IMessageContext eventContext,
                                                       string subscriptionName,
                                                       Exception e,
                                                       params IMessageContext[] messageContexts)
        {
            HandledEvents.Add(new FailHandledEvent(eventContext.MessageId, subscriptionName, eventContext.MessageOffset, DateTime.Now, e));

            messageContexts.ForEach(messageContext =>
            {
                messageContext.CorrelationId = eventContext.MessageId;
                Events.Add(BuildEvent(messageContext));
                UnPublishedEvents.Add(new UnPublishedEvent(messageContext));
            });
            return(SaveChangesAsync());
        }
            public void OnSystemEvent(SystemEvent @event)
            {
                if (SystemEventHandler != null)
                {
                    SystemEventHandler(@event);
                }
                else
                {
                    Action <IQuery> handler;
                    if (!HandledEvents.TryGetValue(@event.EventType, out handler))
                    {
                        return;
                    }

                    handler(@event.SystemQuery);
                }
            }
示例#8
0
 public override Task HandleEventAsync(IMessageContext eventContext,
                                       string subscriptionName,
                                       IEnumerable <IMessageContext> commandContexts,
                                       IEnumerable <IMessageContext> messageContexts)
 {
     HandledEvents.Add(new HandledEvent(eventContext.MessageId, subscriptionName, eventContext.MessageOffset, DateTime.Now));
     commandContexts.ForEach(commandContext =>
     {
         commandContext.CorrelationId = eventContext.MessageId;
         // don't save command here like event that would be published to other bounded context
         UnSentCommands.Add(new UnSentCommand(commandContext));
     });
     messageContexts.ForEach(messageContext =>
     {
         messageContext.CorrelationId = eventContext.MessageId;
         Events.Add(BuildEvent(messageContext));
         UnPublishedEvents.Add(new UnPublishedEvent(messageContext));
     });
     return(SaveChangesAsync());
 }
示例#9
0
        public void SaveFailHandledEvent(IMessageContext eventContext, string subscriptionName, Exception e, params IMessageContext[] messageContexts)
        {
            //lock (EventLock)
            {
                var @event = Events.Find(eventContext.MessageID);
                if (@event == null)
                {
                    @event = BuildEvent(eventContext);
                    Events.Add(@event);
                }
                HandledEvents.Add(new FailHandledEvent(@event.ID, subscriptionName, DateTime.Now, e));


                messageContexts.ForEach(messageContext =>
                {
                    messageContext.CorrelationID = eventContext.MessageID;
                    Events.Add(BuildEvent(messageContext));
                    UnPublishedEvents.Add(new UnPublishedEvent(messageContext));
                });
                SaveChanges();
            }
        }
示例#10
0
 public bool HasEventHandled(string eventId, string subscriptionName)
 {
     return(HandledEvents.Count(@event => @event.Id == eventId &&
                                @event.SubscriptionName == subscriptionName) > 0);
 }
示例#11
0
        /// <summary>
        /// Synchronizes the EventControls with the Events located in the time line
        /// Hyp : When removing an event at some time, all the events for the corresponding time are also removed
        /// </summary>
        private void SynchronizeWithTimeLine()
        {
            // Handles the existing EventControls : counts the ones that already exist
            // and remove the ones that should be removed
            EventsAtTime.Clear();
            List <EventControl> toBeRemoved = new List <EventControl>();

            foreach (EventControl eventControl in HandledEvents.Values)
            {
                if (TimeLine.Contains(eventControl.ModelEvent))
                {
                    // Counts the number of events at all given times
                    RegisterEventAtTime(eventControl);
                }
                else
                {
                    // Remove the events that no more exist in the time line
                    toBeRemoved.Add(eventControl);
                }
            }

            // Actually performs the removal
            foreach (EventControl eventControl in toBeRemoved)
            {
                RemoveEventControl(eventControl);
            }


            // Create new EventControl for each new Event in the time line
            if (TimeLine != null)
            {
                foreach (ModelEvent modelEvent in TimeLine.Events)
                {
                    // add a EventControl for this event
                    if (FilterConfiguration.VisibleEvent(modelEvent))
                    {
                        if (!HandledEvents.ContainsKey(modelEvent))
                        {
                            if (HandledEvents.Count <= MAX_NUMBER_OF_EVENTS)
                            {
                                EventControl eventControl = new EventControl(this, modelEvent);
                                eventControl.Top  = EventTop(modelEvent);
                                eventControl.Left = EventLeft(modelEvent);
                                SetPanelSize(eventControl);
                                Controls.Add(eventControl);

                                string msg = modelEvent.Message;
                                if (msg.Length > 1000)
                                {
                                    // Message is too big for tool tips, reduce it.
                                    msg = msg.Substring(0, 1000) + "...";
                                }
                                ToolTip.SetToolTip(eventControl, msg);

                                // TODO : I do not understand this one...
                                if (!HandledEvents.ContainsKey(modelEvent))
                                {
                                    HandledEvents[modelEvent] = eventControl;
                                }
                                RegisterEventAtTime(eventControl);

                                if (HandledEvents.Count == MAX_NUMBER_OF_EVENTS)
                                {
                                    MessageBox.Show("Too many events displayed.\nDisplaying only the " + MAX_NUMBER_OF_EVENTS + " first events.\nPlease consider filtering out events.", "Too many events", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                        }
                    }
                }
            }
        }
示例#12
0
 public void Consume(TEvent eventData)
 {
     HandledEvents.Add(eventData);
 }
示例#13
0
 public override Task <bool> HasEventHandledAsync(string eventId, string subscriptionName)
 {
     return(HandledEvents.AnyAsync(@event => @event.Id == eventId && @event.SubscriptionName == subscriptionName));
 }
示例#14
0
 public async Task <bool> HasEventHandledAsync(string eventId, string subscriptionName)
 {
     return(await HandledEvents.CountAsync(@event => @event.Id == eventId &&
                                           @event.SubscriptionName == subscriptionName)
            .ConfigureAwait(false) > 0);
 }
 public void Handle(IEventMessage <Event2> ev)
 {
     HandledEvents.Add(ev);
 }
 private void Handle(IEventMessage <Event2> ev)
 {
     HandledEvents.Add(ev);
 }