Example #1
0
        protected internal virtual void RemoveObsoleteEventSubscriptions(ESS.FW.Bpm.Engine.Persistence.Entity.ProcessDefinitionEntity processDefinition, ESS.FW.Bpm.Engine.Persistence.Entity.ProcessDefinitionEntity latestProcessDefinition)
        {
            // remove all subscriptions for the previous version
            if (latestProcessDefinition != null)
            {
                IEventSubscriptionManager eventSubscriptionManager = EventSubscriptionManager;

                IList <EventSubscriptionEntity> subscriptionsToDelete = new List <EventSubscriptionEntity>();

                IList <EventSubscriptionEntity> messageEventSubscriptions = eventSubscriptionManager.FindEventSubscriptionsByConfiguration(EventType.Message.Name, latestProcessDefinition.Id);
                ((List <EventSubscriptionEntity>)subscriptionsToDelete).AddRange(messageEventSubscriptions);

                IList <EventSubscriptionEntity> signalEventSubscriptions = eventSubscriptionManager.FindEventSubscriptionsByConfiguration(EventType.Signal.Name, latestProcessDefinition.Id);
                ((List <EventSubscriptionEntity>)subscriptionsToDelete).AddRange(signalEventSubscriptions);

                foreach (EventSubscriptionEntity eventSubscriptionEntity in subscriptionsToDelete)
                {
                    eventSubscriptionEntity.Delete();
                }
            }
        }