Ejemplo n.º 1
0
        protected internal virtual MigratingProcessElementInstance createMigratingEventScopeInstance(MigratingInstanceParseContext parseContext, EventSubscriptionEntity element)
        {
            ActivityImpl compensatingActivity = parseContext.SourceProcessDefinition.findActivity(element.ActivityId);

            MigrationInstruction migrationInstruction = getMigrationInstruction(parseContext, compensatingActivity);

            ActivityImpl eventSubscriptionTargetScope = null;

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

            ExecutionEntity      eventScopeExecution   = CompensationUtil.getCompensatingExecution(element);
            MigrationInstruction eventScopeInstruction = parseContext.findSingleMigrationInstruction(eventScopeExecution.ActivityId);
            ActivityImpl         targetScope           = parseContext.getTargetActivity(eventScopeInstruction);

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

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

            parseDependentEntities(parseContext, migratingCompensationInstance);

            return(migratingCompensationInstance);
        }
Ejemplo n.º 2
0
        protected internal static bool HasCompensationEventSubprocess(ActivityImpl activity)
        {
            var compensationHandler = activity.findCompensationHandler();

            return((compensationHandler != null) && compensationHandler.SubProcessScope &&
                   compensationHandler.TriggeredByEvent);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     In the context when an event scope execution is created (i.e. a scope such as a subprocess has completed),
        ///     this method returns the compensation handler activity that is going to be executed when by the event scope
        ///     execution.
        ///     This method is not relevant when the scope has a boundary compensation handler.
        /// </summary>
        protected internal static ActivityImpl getEventScopeCompensationHandler(ExecutionEntity execution)
        {
            ActivityImpl activity = (ActivityImpl)execution.Activity;

            ActivityImpl compensationHandler = activity.findCompensationHandler();

            if (compensationHandler != null && compensationHandler.SubProcessScope)
            {
                // subprocess with inner compensation event subprocess
                return(compensationHandler);
            }
            else
            {
                // subprocess without compensation handler or
                // multi instance activity
                return(activity);
            }
        }
Ejemplo n.º 4
0
        protected internal virtual MigratingProcessElementInstance createMigratingEventSubscriptionInstance(MigratingInstanceParseContext parseContext, EventSubscriptionEntity element)
        {
            ActivityImpl compensationHandler = parseContext.SourceProcessDefinition.findActivity(element.ActivityId);

            MigrationInstruction migrationInstruction = getMigrationInstruction(parseContext, compensationHandler);

            ActivityImpl targetScope = null;

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

            MigratingCompensationEventSubscriptionInstance migratingCompensationInstance = parseContext.MigratingProcessInstance.addCompensationSubscriptionInstance(migrationInstruction, element, compensationHandler, targetScope);

            parseContext.consume(element);

            return(migratingCompensationInstance);
        }
Ejemplo n.º 5
0
        private static string GetSubscriptionActivityId(IActivityExecution execution, string activityRef)
        {
            ActivityImpl activityToCompensate = (ActivityImpl)((ExecutionEntity)execution).GetProcessDefinition().FindActivity(activityRef);

            if (activityToCompensate.MultiInstance)
            {
                ActivityImpl flowScope = (ActivityImpl)activityToCompensate.FlowScope;
                return(flowScope.ActivityId);
            }
            else
            {
                ActivityImpl compensationHandler = activityToCompensate.findCompensationHandler();
                if (compensationHandler != null)
                {
                    return(compensationHandler.ActivityId);
                }
                else
                {
                    // if activityRef = subprocess and subprocess has no compensation handler
                    return(activityRef);
                }
            }
        }