internal WorkflowInstance (Guid guid, WorkflowRuntime runtime, Activity root_activity) { this.guid = guid; this.runtime = runtime; this.root_activity = root_activity; subscription_collection = new TimerEventSubscriptionCollection (); queuing_service = new WorkflowQueuingService (); }
internal WorkflowInstance(Guid guid, WorkflowRuntime runtime, Activity root_activity) { this.guid = guid; this.runtime = runtime; this.root_activity = root_activity; subscription_collection = new TimerEventSubscriptionCollection(); queuing_service = new WorkflowQueuingService(); }
// Initialize for the root schedule internal void Initialize(Activity rootActivity, WorkflowExecutor invokerExec, string invokeActivityID, Guid instanceId, IDictionary<string, object> namedArguments, WorkflowInstance workflowInstance) { this.rootActivity = rootActivity; this.InstanceId = instanceId; // Set the persisted State properties this.rootActivity.SetValue(WorkflowExecutor.ContextIdProperty, 0); this.rootActivity.SetValue(WorkflowInstanceIdProperty, instanceId); this.WorkflowStatus = WorkflowStatus.Created; this.rootActivity.SetValue(Activity.ActivityExecutionContextInfoProperty, new ActivityExecutionContextInfo(this.rootActivity.QualifiedName, GetNewContextId(), instanceId, -1)); this.rootActivity.SetValue(Activity.ActivityContextGuidProperty, instanceId); this.rootActivity.SetValue(WorkflowExecutor.IsIdleProperty, true); this.isInstanceIdle = true; // set workflow executor this.rootActivity.SetValue(WorkflowExecutor.WorkflowExecutorProperty, this); // initialize the root activity RefreshWorkflowDefinition(); Activity workflowDefinition = this.WorkflowDefinition; if (workflowDefinition == null) throw new InvalidOperationException("workflowDefinition"); ((IDependencyObjectAccessor)this.rootActivity).InitializeActivatingInstanceForRuntime(null, this); this.rootActivity.FixUpMetaProperties(workflowDefinition); _runtime = workflowInstance.WorkflowRuntime; if (invokerExec != null) { List<string> calleeBase = new List<string>(); TrackingCallingState parentTCS = (TrackingCallingState)invokerExec.rootActivity.GetValue(WorkflowExecutor.TrackingCallingStateProperty); if ((parentTCS != null) && (parentTCS.CallerActivityPathProxy != null)) { foreach (string qualifiedID in parentTCS.CallerActivityPathProxy) calleeBase.Add(qualifiedID); } calleeBase.Add(invokeActivityID); // // This has been exec'd by another instance // Set up tracking info to allow linking instances Debug.Assert(invokeActivityID != null && invokeActivityID.Length > 0); TrackingCallingState trackingCallingState = new TrackingCallingState(); trackingCallingState.CallerActivityPathProxy = calleeBase; trackingCallingState.CallerWorkflowInstanceId = invokerExec.InstanceId; trackingCallingState.CallerContextGuid = ((ActivityExecutionContextInfo)ContextActivityUtils.ContextActivity(invokerExec.CurrentActivity).GetValue(Activity.ActivityExecutionContextInfoProperty)).ContextGuid; if (null == invokerExec.CurrentActivity.Parent) trackingCallingState.CallerParentContextGuid = trackingCallingState.CallerContextGuid; else trackingCallingState.CallerParentContextGuid = ((ActivityExecutionContextInfo)ContextActivityUtils.ContextActivity(invokerExec.CurrentActivity.Parent).GetValue(Activity.ActivityExecutionContextInfoProperty)).ContextGuid; this.rootActivity.SetValue(WorkflowExecutor.TrackingCallingStateProperty, trackingCallingState); } _setInArgsOnCompanion(namedArguments); this.schedulingContext = new Scheduler(this, true); this._schedulerLock = LockFactory.CreateWorkflowSchedulerLock(this.InstanceId); qService = new WorkflowQueuingService(this); _workflowInstance = workflowInstance; TimerQueue = new TimerEventSubscriptionCollection(this, this.InstanceId); // register the dynamic activity using (new ServiceEnvironment(this.rootActivity)) { using (SetCurrentActivity(this.rootActivity)) { this.RegisterDynamicActivity(this.rootActivity, false); } } }
public void Initialize(Activity definition, IDictionary<string, object> inputs, bool hasNameCollision) { this.rootActivity.SetValue(Activity.ActivityExecutionContextInfoProperty, new ActivityExecutionContextInfo(this.rootActivity.QualifiedName, this.GetNewContextActivityId(), instanceId, -1)); this.rootActivity.SetValue(Activity.ActivityContextGuidProperty, instanceId); SetInputParameters(definition, this.rootActivity, inputs, hasNameCollision); ((IDependencyObjectAccessor)this.rootActivity).InitializeActivatingInstanceForRuntime( null, this); this.rootActivity.FixUpMetaProperties(definition); TimerQueue = new TimerEventSubscriptionCollection(this, this.instanceId); using (new ServiceEnvironment(this.rootActivity)) { using (SetCurrentActivity(this.rootActivity)) { RegisterContextActivity(this.rootActivity); using (ActivityExecutionContext executionContext = new ActivityExecutionContext(this.rootActivity, true)) { executionContext.InitializeActivity(this.rootActivity); } } } }