protected static IList <ActivityBlockingUpdate> GetActivitiesBlockingUpdate(object deserializedRuntimeState, DynamicUpdateMap updateMap) { ActivityExecutor executor = deserializedRuntimeState as ActivityExecutor; if (executor == null) { throw FxTrace.Exception.Argument("deserializedRuntimeState", SR.InvalidRuntimeState); } if (updateMap == null) { throw FxTrace.Exception.ArgumentNull("updateMap"); } DynamicUpdateMap rootMap = updateMap; if (updateMap.IsForImplementation) { rootMap = updateMap.AsRootMap(); } IList <ActivityBlockingUpdate> result = executor.GetActivitiesBlockingUpdate(rootMap); if (result == null) { result = new List <ActivityBlockingUpdate>(); } return(result); }
protected void Initialize(object deserializedRuntimeState, DynamicUpdateMap updateMap) { ThrowIfAborted(); ThrowIfReadOnly(); this.executor = deserializedRuntimeState as ActivityExecutor; if (this.executor == null) { throw FxTrace.Exception.Argument("deserializedRuntimeState", SR.InvalidRuntimeState); } this.executor.ThrowIfNonSerializable(); EnsureDefinitionReady(); WorkflowIdentity originalDefinitionIdentity = this.executor.WorkflowIdentity; bool success = false; Collection <ActivityBlockingUpdate> updateErrors = null; try { if (updateMap != null) { // check if map is for implementaiton, if (updateMap.IsForImplementation) { // if so, the definition root must be an activity // with no public/imported children and no public/imported delegates. if (DynamicUpdateMap.CanUseImplementationMapAsRoot(this.WorkflowDefinition)) { updateMap = updateMap.AsRootMap(); } else { throw FxTrace.Exception.AsError(new InstanceUpdateException(SR.InvalidImplementationAsWorkflowRoot)); } } updateMap.ThrowIfInvalid(this.WorkflowDefinition); this.executor.WorkflowIdentity = this.DefinitionIdentity; this.executor.UpdateInstancePhase1(updateMap, this.WorkflowDefinition, ref updateErrors); ThrowIfDynamicUpdateErrorExists(updateErrors); } InitializeCore(null, null); if (updateMap != null) { this.executor.UpdateInstancePhase2(updateMap, ref updateErrors); ThrowIfDynamicUpdateErrorExists(updateErrors); // Track that dynamic update is successful if (this.Controller.TrackingEnabled) { this.Controller.Track(new WorkflowInstanceUpdatedRecord(this.Id, this.WorkflowDefinition.DisplayName, originalDefinitionIdentity, this.executor.WorkflowIdentity)); } } success = true; } catch (InstanceUpdateException updateException) { // Can't track through the controller because initialization failed if (this.HasTrackingParticipant && this.TrackingProvider.ShouldTrackWorkflowInstanceRecords) { IList <ActivityBlockingUpdate> blockingActivities = updateException.BlockingActivities; if (blockingActivities.Count == 0) { blockingActivities = new List <ActivityBlockingUpdate> { new ActivityBlockingUpdate(this.WorkflowDefinition, this.WorkflowDefinition.Id, updateException.Message) }.AsReadOnly(); } this.TrackingProvider.AddRecord(new WorkflowInstanceUpdatedRecord(this.Id, this.WorkflowDefinition.DisplayName, originalDefinitionIdentity, this.DefinitionIdentity, blockingActivities)); } throw; } finally { if (updateMap != null && !success) { executor.MakeNonSerializable(); } } }