protected internal virtual MigratingProcessElementInstance CreateMigratingEventScopeInstance(
            MigratingInstanceParseContext parseContext, EventSubscriptionEntity element)
        {
            var compensatingActivity =
                (ActivityImpl)parseContext.SourceProcessDefinition.FindActivity(element.ActivityId);

            var migrationInstruction = GetMigrationInstruction(parseContext, compensatingActivity);

            ActivityImpl eventSubscriptionTargetScope = null;

            if (migrationInstruction != null)
            {
                if (compensatingActivity.CompensationHandler)
                {
                    var targetEventScope =
                        (ActivityImpl)parseContext.GetTargetActivity(migrationInstruction).EventScope;
                    eventSubscriptionTargetScope = targetEventScope.findCompensationHandler();
                }
                else
                {
                    eventSubscriptionTargetScope = parseContext.GetTargetActivity(migrationInstruction);
                }
            }

            var eventScopeExecution   = CompensationUtil.GetCompensatingExecution(element);
            var eventScopeInstruction = parseContext.FindSingleMigrationInstruction(eventScopeExecution.ActivityId);
            var targetScope           = parseContext.GetTargetActivity(eventScopeInstruction);

            //var migratingCompensationInstance =
            //    parseContext.MigratingProcessInstance.addEventScopeInstance(eventScopeInstruction, eventScopeExecution,
            //        eventScopeExecution.getActivity(), targetScope, migrationInstruction, element, compensatingActivity,
            //        eventSubscriptionTargetScope);

            //parseContext.consume(element);
            //parseContext.submit(migratingCompensationInstance);

            //parseDependentEntities(parseContext, migratingCompensationInstance);

            //return migratingCompensationInstance;
            return(null);
        }
        protected internal virtual MigratingProcessElementInstance CreateMigratingEventSubscriptionInstance(
            MigratingInstanceParseContext parseContext, EventSubscriptionEntity element)
        {
            var compensationHandler =
                (ActivityImpl)parseContext.SourceProcessDefinition.FindActivity(element.ActivityId);

            var migrationInstruction = GetMigrationInstruction(parseContext, compensationHandler);

            ActivityImpl targetScope = null;

            if (migrationInstruction != null)
            {
                var targetEventScope = (ActivityImpl)parseContext.GetTargetActivity(migrationInstruction).EventScope;
                targetScope = targetEventScope.findCompensationHandler();
            }

            var migratingCompensationInstance =
                parseContext.MigratingProcessInstance.AddCompensationSubscriptionInstance(migrationInstruction, element,
                                                                                          compensationHandler, targetScope);

            parseContext.Consume(element);

            return(migratingCompensationInstance);
        }
示例#3
0
        public virtual void Handle(MigratingInstanceParseContext parseContext, MigratingActivityInstance owningInstance,
                                   IList <EventSubscriptionEntity> elements)
        {
            var targetDeclarations = GetDeclarationsByTriggeringActivity(owningInstance.TargetScope);

            foreach (var eventSubscription in elements)
            {
                if (!SupportedEventTypes.Contains(eventSubscription.EventType))
                {
                    continue;
                }

                var migrationInstruction = parseContext.FindSingleMigrationInstruction(eventSubscription.ActivityId);
                var targetActivity       = parseContext.GetTargetActivity(migrationInstruction);

                if ((targetActivity != null) && owningInstance.MigratesTo((ScopeImpl)targetActivity.EventScope))
                {
                    // the event subscription is migrated
                    //EventSubscriptionDeclaration targetDeclaration = targetDeclarations.Remove(targetActivity.Id);

                    //owningInstance.addMigratingDependentInstance(new MigratingEventSubscriptionInstance(eventSubscription, targetActivity, migrationInstruction.UpdateEventTrigger, targetDeclaration));
                }
                else
                {
                    // the event subscription will be removed
                    owningInstance.AddRemovingDependentInstance(new MigratingEventSubscriptionInstance(eventSubscription));
                }

                //parseContext.consume(eventSubscription);
            }

            if (owningInstance.Migrates())
            {
                AddEmergingEventSubscriptions(owningInstance, targetDeclarations.Values);
            }
        }