/// <summary> /// Workflow instance constructor. /// </summary> /// <param name="runtime"></param> /// <param name="definition">The workflow definition.</param> /// <param name="metadata">The metadata which includes parameters etc.</param> /// <param name="pipelineInput">This is input coming from pipeline, which is added to the input stream.</param> /// <param name="job"></param> internal PSWorkflowApplicationInstance( PSWorkflowRuntime runtime, PSWorkflowDefinition definition, PSWorkflowContext metadata, PSDataCollection<PSObject> pipelineInput, PSWorkflowJob job) { Tracer.WriteMessage("Creating Workflow instance."); InitializePSWorkflowApplicationInstance(runtime); this._definition = definition; this._metadatas = metadata; this._streams = new PowerShellStreams<PSObject, PSObject>(pipelineInput); RegisterHandlersForDataAdding(_streams); this._timers = new PSWorkflowTimer(this); this.creationMode = WorkflowInstanceCreationMode.Normal; _job = job; _stores = Runtime.Configuration.CreatePSWorkflowInstanceStore(this); this._remoteActivityState = new PSWorkflowRemoteActivityState(_stores); }
/// <summary> /// Workflow instance constructor for shutdown or crashed workflows. /// </summary> /// <param name="runtime"></param> /// <param name="instanceId"></param> internal PSWorkflowApplicationInstance(PSWorkflowRuntime runtime, PSWorkflowId instanceId) { Tracer.WriteMessage("Creating Workflow instance after crash and shutdown workflow."); InitializePSWorkflowApplicationInstance(runtime); this._definition = null; this._metadatas = null; this._streams = null; this._timers = null; this.id = instanceId.Guid; this.creationMode = WorkflowInstanceCreationMode.AfterCrashOrShutdown; _stores = Runtime.Configuration.CreatePSWorkflowInstanceStore(this); this._remoteActivityState = null; }
protected override IEnumerable<object> DoLoad(IEnumerable<Type> componentTypes) { object pSWorkflowTimer; Collection<object> objs = new Collection<object>(); lock (this._syncLock) { foreach (Type componentType in componentTypes) { if ((JobState)componentType != typeof(JobState)) { if (componentType != typeof(Dictionary<string, object>)) { if (componentType != typeof(PSWorkflowDefinition)) { if (componentType != typeof(Exception)) { if (componentType != typeof(PSWorkflowContext)) { if (componentType != typeof(PowerShellStreams<PSObject, PSObject>)) { if (componentType != typeof(PSWorkflowTimer)) { continue; } object obj = this.DeserializeWorkflowTimerFromStore(); Collection<object> objs1 = objs; if (obj == null) { pSWorkflowTimer = new PSWorkflowTimer(base.PSWorkflowInstance); } else { pSWorkflowTimer = new PSWorkflowTimer(base.PSWorkflowInstance, obj); } objs1.Add(pSWorkflowTimer); } else { objs.Add(this.DeserializeWorkflowStreamsFromStore()); } } else { objs.Add(this.DeserializeWorkflowMetadataFromStore()); } } else { Exception exception = this.DeserializeWorkflowErrorExceptionFromStore(); if (exception == null) { continue; } objs.Add(exception); } } else { PSWorkflowDefinition pSWorkflowDefinition = this.DeserializeWorkflowDefinitionFromStore(); if (pSWorkflowDefinition == null) { continue; } objs.Add(pSWorkflowDefinition); } } else { Dictionary<string, object> strs = this.DeserializeContextFromStore(); if (strs == null) { continue; } objs.Add(strs); } } else { JobState? nullable = this.DeserializeWorkflowInstanceStateFromStore(); if (!nullable.HasValue) { continue; } JobState value = nullable.Value; if (value == JobState.Running || value == JobState.Suspended || value == JobState.Suspending || value == JobState.Stopping || value == JobState.NotStarted) { value = JobState.Suspended; } objs.Add(value); } } } return objs; }
private long LoadSerializedTimer(PSWorkflowTimer data) { this.serializedTimerData = this.Encrypt(this.SerializeObject(data.GetSerializedData())); long count = (long)this.serializedTimerData.Count; return count; }
internal PSWorkflowApplicationInstance(PSWorkflowRuntime runtime, PSWorkflowId instanceId) { this.Tracer = PowerShellTraceSourceFactory.GetTraceSource(); this.wfAppNeverLoaded = true; this.ReactivateSync = new object(); if (runtime != null) { this.Tracer.WriteMessage("Creating Workflow instance after crash and shutdown workflow."); this._definition = null; this._metadatas = null; this._streams = null; this._timers = null; this.id = instanceId.Guid; this.creationMode = WorkflowInstanceCreationMode.AfterCrashOrShutdown; this.PersistAfterNextPSActivity = false; this.suspendAtNextCheckpoint = false; base.Runtime = runtime; this._stores = base.Runtime.Configuration.CreatePSWorkflowInstanceStore(this); this.asyncExecutionCollection = new Dictionary<string, PSActivityContext>(); base.ForceDisableStartOrEndPersistence = false; return; } else { throw new ArgumentNullException("runtime"); } }
internal PSWorkflowApplicationInstance(PSWorkflowRuntime runtime, PSWorkflowDefinition definition, PSWorkflowContext metadata, PSDataCollection<PSObject> pipelineInput, PSWorkflowJob job) { this.Tracer = PowerShellTraceSourceFactory.GetTraceSource(); this.wfAppNeverLoaded = true; this.ReactivateSync = new object(); if (runtime != null) { this.Tracer.WriteMessage("Creating Workflow instance."); this._definition = definition; this._metadatas = metadata; this._streams = new PowerShellStreams<PSObject, PSObject>(pipelineInput); this.RegisterHandlersForDataAdding(this._streams); this._timers = new PSWorkflowTimer(this); this.creationMode = WorkflowInstanceCreationMode.Normal; this.PersistAfterNextPSActivity = false; this.suspendAtNextCheckpoint = false; this._job = job; base.Runtime = runtime; this._stores = base.Runtime.Configuration.CreatePSWorkflowInstanceStore(this); this.asyncExecutionCollection = new Dictionary<string, PSActivityContext>(); base.ForceDisableStartOrEndPersistence = false; return; } else { throw new ArgumentNullException("runtime"); } }