Пример #1
0
 private void ExecuteHandlers(EventPublication publication)
 {
     foreach (var registration in GetSubscriptionsFor(publication))
     {
         registration.Invoke(publication);
     }
 }
Пример #2
0
        private void InvokeDeactivateAndClose(EventPublication originalPublication)
        {
            var pub = new EventPublication(ScreenEvents.Deactivate, new ScreenEventArgs(_parent));

            ExecuteHandlers(pub);
            InvokeClose(originalPublication);
        }
Пример #3
0
        public static Message FromPublication(EventPublication pub)
        {
            Message result = new Message();

            result.MessageType = MessageType.Publication;
            result.Content     = JsonConvert.SerializeObject(pub);
            return(result);
        }
Пример #4
0
        public async Task CreateUnpublishedEvent(EventPublication publication)
        {
            var persistable = publication.ToPersistable();
            var result      = Set <PersistedPublication>().Add(persistable);

            SaveChanges();
            Entry(persistable).State = EntityState.Detached;
        }
Пример #5
0
        internal static EventPublication ToEventPublication(this PersistedPublication instance)
        {
            EventPublication result = new EventPublication();

            result.Id         = instance.PublicationId;
            result.EventKey   = instance.EventKey;
            result.EventName  = instance.EventName;
            result.StepId     = instance.StepId;
            result.WorkflowId = instance.WorkflowId;
            result.EventData  = JsonConvert.DeserializeObject(instance.EventData, SerializerSettings);

            return(result);
        }
Пример #6
0
        private void ExecuteRequestCloseHandlers(EventPublication publication)
        {
            foreach (var registration in GetSubscriptionsFor(publication))
            {
                RequestCloseEventArgs args = (RequestCloseEventArgs)publication.Payload;

                if (!args.IsCloseAllowed)
                {
                    break;
                }

                registration.Invoke(publication);
            }
        }
Пример #7
0
        public async Task QueueForPublishing(EventPublication item)
        {
            if (_connection == null)
            {
                throw new Exception("RabbitMQ provider not running");
            }

            using (var channel = _connection.CreateModel())
            {
                channel.QueueDeclare(queue: "wfc.publish_queue", durable: true, exclusive: false, autoDelete: false, arguments: null);
                var body = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(item, SerializerSettings));
                channel.BasicPublish(exchange: "", routingKey: "wfc.publish_queue", basicProperties: null, body: body);
            }
        }
Пример #8
0
        public async Task PublishEvent(string eventName, string eventKey, object eventData)
        {
            if (_shutdown)
            {
                throw new Exception("Host is not running");
            }

            Logger.LogDebug("Publishing event {0} {1}", eventName, eventKey);
            var subs = await PersistenceStore.GetSubcriptions(eventName, eventKey);

            foreach (var sub in subs.ToList())
            {
                EventPublication pub = new EventPublication();
                pub.Id         = Guid.NewGuid();
                pub.EventData  = eventData;
                pub.EventKey   = eventKey;
                pub.EventName  = eventName;
                pub.StepId     = sub.StepId;
                pub.WorkflowId = sub.WorkflowId;
                await QueueProvider.QueueForPublishing(pub);

                await PersistenceStore.TerminateSubscription(sub.Id);
            }
        }
Пример #9
0
 public async Task CreateUnpublishedEvent(EventPublication publication)
 {
     _unpublishedEvents.Add(publication);
 }
Пример #10
0
 public async Task CreateUnpublishedEvent(EventPublication publication)
 {
     await UnpublishedEvents.InsertOneAsync(publication);
 }
 public async Task QueueForPublishing(EventPublication item)
 {
     _publishQueue.Enqueue(item);
 }
Пример #12
0
 public void Invoke(EventPublication publication)
 {
     TryInvokeCore((InitializeEventArgs)publication.Payload);
 }
Пример #13
0
 public bool Matches(EventPublication publication)
 {
     return(publication.Payload is InitializeEventArgs);
 }
Пример #14
0
 private IEnumerable <IEventSubscription> GetSubscriptionsFor(EventPublication publication)
 {
     return(_handlers
            .Where(s => s.Matches(publication))
            .OrderBy(h => h.ExecutionOrder));
 }
Пример #15
0
 public void RemoveEventPublication(EventPublication publication)
 {
     VerfifyAddinStarted();
     _addinFramework.EventBroker.RemoveEventPublication(publication);
 }
Пример #16
0
 public async Task QueueForPublishing(EventPublication item)
 {
     PushMessage(Message.FromPublication(item));
 }