public virtual void Handle(MigratingInstanceParseContext parseContext,
                                   MigratingTransitionInstance transitionInstance, IList <JobEntity> elements)
        {
            foreach (var job in elements)
            {
                if (!IsAsyncContinuation(job))
                {
                    continue;
                }

                var targetScope = transitionInstance.TargetScope;
                if (targetScope != null)
                {
                    var targetJobDefinitionEntity =
                        parseContext.GetTargetJobDefinition(transitionInstance.TargetScope.Id, job.JobHandlerType);

                    var migratingJobInstance = new MigratingAsyncJobInstance(job, targetJobDefinitionEntity,
                                                                             transitionInstance.TargetScope);

                    transitionInstance.DependentJobInstance = migratingJobInstance;
                    parseContext.Submit(migratingJobInstance);
                }

                parseContext.Consume(job);
            }
        }
Пример #2
0
        public virtual void Handle(MigratingInstanceParseContext parseContext,
                                   MigratingProcessElementInstance owningInstance, IList <VariableInstanceEntity> variables)
        {
            var representativeExecution = owningInstance.ResolveRepresentativeExecution();

            foreach (var variable in variables)
            {
                parseContext.Consume(variable);
            }
        }
Пример #3
0
        protected internal virtual void HandleExternalTaskIncident(MigratingInstanceParseContext parseContext,
                                                                   IncidentEntity incident)
        {
            var owningInstance = parseContext.GetMigratingExternalTaskInstanceById(incident.Configuration);

            if (owningInstance != null)
            {
                parseContext.Consume(incident);
                var migratingIncident = new MigratingIncident(incident, owningInstance.TargetScope);
                owningInstance.AddMigratingDependentInstance(migratingIncident);
            }
        }
Пример #4
0
        public virtual void Handle(MigratingInstanceParseContext parseContext,
                                   MigratingActivityInstance activityInstance, IList <JobEntity> elements)
        {
            var timerDeclarationsInEventScope = GetTimerDeclarationsByTriggeringActivity(activityInstance.TargetScope);

            foreach (var job in elements)
            {
                if (!IsTimerJob(job))
                {
                    continue;
                }

                //var migrationInstruction = parseContext.findSingleMigrationInstruction(job.ActivityId);
                //var targetActivity = parseContext.getTargetActivity(migrationInstruction);

                //if (targetActivity != null && activityInstance.migratesTo(targetActivity.EventScope))
                //{
                //    // the timer job is migrated
                //    JobDefinitionEntity targetJobDefinitionEntity =
                //        parseContext.getTargetJobDefinition(targetActivity.ActivityId, job.JobHandlerType);

                //    TimerDeclarationImpl targetTimerDeclaration = timerDeclarationsInEventScope.Remove(targetActivity.Id);

                //    MigratingJobInstance migratingTimerJobInstance = new MigratingTimerJobInstance(job,
                //        targetJobDefinitionEntity, targetActivity, migrationInstruction.UpdateEventTrigger,
                //        targetTimerDeclaration);
                //    activityInstance.addMigratingDependentInstance(migratingTimerJobInstance);
                //    parseContext.submit(migratingTimerJobInstance);
                //}
                //else
                //{
                //    // the timer job is removed
                //    MigratingJobInstance removingJobInstance = new MigratingTimerJobInstance(job);
                //    activityInstance.addRemovingDependentInstance(removingJobInstance);
                //    parseContext.submit(removingJobInstance);
                //}

                parseContext.Consume(job);
            }

            if (activityInstance.Migrates())
            {
                AddEmergingTimerJobs(activityInstance, timerDeclarationsInEventScope.Values);
            }
        }
Пример #5
0
        protected internal virtual void HandleFailedJobIncident(MigratingInstanceParseContext parseContext,
                                                                IncidentEntity incident)
        {
            var owningInstance = parseContext.GetMigratingJobInstanceById(incident.Configuration);

            if (owningInstance != null)
            {
                parseContext.Consume(incident);
                if (owningInstance.Migrates())
                {
                    var migratingIncident         = new MigratingIncident(incident, owningInstance.TargetScope);
                    var targetJobDefinitionEntity = owningInstance.TargetJobDefinitionEntity;
                    if (targetJobDefinitionEntity != null)
                    {
                        migratingIncident.TargetJobDefinitionId = targetJobDefinitionEntity.Id;
                    }
                    owningInstance.AddMigratingDependentInstance(migratingIncident);
                }
            }
        }
        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);
        }