public virtual void handle(MigratingInstanceParseContext parseContext, MigratingActivityInstance activityInstance, IList <JobEntity> elements) { IDictionary <string, TimerDeclarationImpl> sourceTimerDeclarationsInEventScope = getTimerDeclarationsByTriggeringActivity(activityInstance.SourceScope); IDictionary <string, TimerDeclarationImpl> targetTimerDeclarationsInEventScope = getTimerDeclarationsByTriggeringActivity(activityInstance.TargetScope); foreach (JobEntity job in elements) { if (!isTimerJob(job)) { // skip non timer jobs continue; } MigrationInstruction migrationInstruction = parseContext.findSingleMigrationInstruction(job.ActivityId); ActivityImpl 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 = targetTimerDeclarationsInEventScope.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(parseContext, activityInstance, sourceTimerDeclarationsInEventScope, targetTimerDeclarationsInEventScope); } }
public virtual void handle(MigratingInstanceParseContext parseContext, MigratingActivityInstance owningInstance, IList <EventSubscriptionEntity> elements) { IDictionary <string, EventSubscriptionDeclaration> targetDeclarations = getDeclarationsByTriggeringActivity(owningInstance.TargetScope); foreach (EventSubscriptionEntity eventSubscription in elements) { if (!SupportedEventTypes.Contains(eventSubscription.EventType)) { // ignore unsupported event subscriptions continue; } MigrationInstruction migrationInstruction = parseContext.findSingleMigrationInstruction(eventSubscription.ActivityId); ActivityImpl targetActivity = parseContext.getTargetActivity(migrationInstruction); if (targetActivity != null && owningInstance.migratesTo(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); } }