Exemple #1
0
        public PSWorkflowRuntime GetPSWorkflowRuntime()
        {
            PSWorkflowRuntime pSWorkflowRuntime;

            if (this._runtime == null)
            {
                lock (this._syncObject)
                {
                    if (this._runtime == null)
                    {
                        this._runtime = PSWorkflowRuntime.Instance;
                        return(this._runtime);
                    }
                    else
                    {
                        pSWorkflowRuntime = this._runtime;
                    }
                }
                return(pSWorkflowRuntime);
            }
            else
            {
                return(this._runtime);
            }
        }
        static void Main(string[] args)
        {
            // Create a variable for the workflow path.
            string workflowFileName = "SampleWorkflow.xaml";

            // Read the XAML into the variable.
            string xaml = File.ReadAllText(workflowFileName);

            // Create a runtime to host the workflow, passing the custom configuration provider.
            PSWorkflowRuntime runtime = new PSWorkflowRuntime(new SampleConfigurationProvider());

            // Parameters to the workflow can be provided in this dictionary.
            Dictionary<string, object> parameters = new Dictionary<string, object>();

            // Pass the ID of the current process, which the sample workflow expects as an input parameter.
            parameters.Add("ProcessId", (new List<int>() { Process.GetCurrentProcess().Id }).ToArray());

            // Create the job, providing the XAML definition.
            PSWorkflowJob job = runtime.JobManager.CreateJob(Guid.NewGuid(), xaml, "Get-CurrentProcess", "SampleWorkflow", parameters);

            // Subscribe to the state change event before starting the job.
            AutoResetEvent wfEvent = new AutoResetEvent(false);
            job.StateChanged += delegate(object sender, JobStateEventArgs e)
            {
                switch (e.JobStateInfo.State)
                {
                    case JobState.Failed:
                    case JobState.Completed:
                        {
                            wfEvent.Set();
                        }
                        break;
                }
            };

            // Start the job.
            job.StartJob();

            // Wait for the state changes event.
            wfEvent.WaitOne();

            if (job.JobStateInfo.State == JobState.Completed)
            {
                Console.WriteLine("The job has completed successfully.");
                Console.WriteLine("Total processes found: " + job.PSWorkflowInstance.Streams.OutputStream.Count);
            }
            else
                Console.WriteLine("The job has Failed.");

            Console.WriteLine("Press <Enter> to continue...");
            Console.ReadLine();

        }
        internal PSOutOfProcessActivityController(PSWorkflowRuntime runtime)
            : base(runtime)
        {
            if (runtime == null)
            {
                throw new ArgumentNullException("runtime");
            }

            Debug.Assert(runtime.Configuration != null, "For now only expecting PSWorkflowConfigurationProvider");

            this._configuration = runtime.Configuration;
            InitializeActivityHostProcesses();
        }
        static void Main(string[] args)
        {
            // Set the path to the XAML workflow.
            string workflowFileName = "SampleWorkflow.xaml";

            // Read the XAML from the workflow into the variable
            string xaml = File.ReadAllText(workflowFileName);

            // Create a runtime to host the workflow, passing the custom configuration provider to the constructor.           
            PSWorkflowRuntime runtime = new PSWorkflowRuntime(new SampleConfigurationProvider());

            // Parameters for the workflow can be provided in this dictionary
            Dictionary<string, object>parameters = new Dictionary<string, object>();

            // Create the job. Because we are using the default file-based store, we need to provide the XAML worklfow definition.
            PSWorkflowJob job = runtime.JobManager.CreateJob(Guid.NewGuid(), xaml, "Get-CurrentProcess", "SampleWorkflow", parameters);

            // Subscribe to the state change event before starting the job.
            AutoResetEvent wfEvent = new AutoResetEvent(false);
            job.StateChanged += delegate(object sender, JobStateEventArgs e)
            {
                switch (e.JobStateInfo.State)
                {
                    case JobState.Failed:
                    case JobState.Completed:
                        {
                            wfEvent.Set();
                        }
                        break;
                }
            };

            // Start the job
            job.StartJob();

            // Wait for the state change event.
            wfEvent.WaitOne();

            if (job.JobStateInfo.State == JobState.Completed)
            {
                Console.WriteLine("The job has completed successfully.");
                Console.WriteLine("Total Commands found: " + job.PSWorkflowInstance.Streams.OutputStream.Count);
            }
            else
                Console.WriteLine("The job has Failed.");

            Console.WriteLine("Press <Enter> to continue...");
            Console.ReadLine();

        }
Exemple #5
0
 internal PSOutOfProcessActivityController(PSWorkflowRuntime runtime) : base(runtime)
 {
     this._hostProcesses    = new Collection <ActivityHostProcess>();
     this._requests         = new ConcurrentQueue <ActivityInvoker>();
     this._structuredTracer = new Tracer();
     this._failedRequests   = new ConcurrentQueue <ActivityInvoker>();
     if (runtime != null)
     {
         this._configuration = runtime.Configuration;
         this.InitializeActivityHostProcesses();
         return;
     }
     else
     {
         throw new ArgumentNullException("runtime");
     }
 }
		internal PSOutOfProcessActivityController(PSWorkflowRuntime runtime) : base(runtime)
		{
			this._hostProcesses = new Collection<ActivityHostProcess>();
			this._requests = new ConcurrentQueue<ActivityInvoker>();
			this._structuredTracer = new Tracer();
			this._failedRequests = new ConcurrentQueue<ActivityInvoker>();
			if (runtime != null)
			{
				this._configuration = runtime.Configuration;
				this.InitializeActivityHostProcesses();
				return;
			}
			else
			{
				throw new ArgumentNullException("runtime");
			}
		}
Exemple #7
0
        /// <summary>
        /// Begin for obtaining a runspace for the specified ConnectionInfo
        /// </summary>
        /// <param name="connectionInfo">connection info to be used for remote connections</param>
        /// <param name="retryCount">number of times to retry</param>
        /// <param name="callback">optional user defined callback</param>
        /// <param name="state">optional user specified state</param>
        /// <param name="retryInterval">time in milliseconds before the next retry has to be attempted</param>
        /// <returns>async result</returns>
        public override IAsyncResult BeginGetRunspace(WSManConnectionInfo connectionInfo, uint retryCount, uint retryInterval, AsyncCallback callback, object state)
        {
            if (connectionInfo != null)
            {
                throw new InvalidOperationException();
            }

            LocalRunspaceAsyncResult asyncResult = new LocalRunspaceAsyncResult(state, callback, Guid.Empty);

            // Get the source language mode from the activity arguments if available and pass to runspace fetching.
            PSLanguageMode?      sourceLanguageMode = null;
            RunCommandsArguments args = state as RunCommandsArguments;

            if (args != null)
            {
                PSWorkflowRuntime wfRuntime = args.WorkflowHost as PSWorkflowRuntime;
                if (wfRuntime != null)
                {
                    PSWorkflowJob wfJob = wfRuntime.JobManager.GetJob(args.PSActivityContext.JobInstanceId);
                    if (wfJob != null)
                    {
                        sourceLanguageMode = wfJob.SourceLanguageMode;
                    }
                }
            }

            Runspace runspace = AssignRunspaceIfPossible(sourceLanguageMode);

            if (runspace != null)
            {
                asyncResult.Runspace = runspace;
                asyncResult.CompletedSynchronously = true;
                asyncResult.SetAsCompleted(null);
            }
            else
            {
                // queue the request
                _requests.Enqueue(asyncResult);
                CheckAndStartRequestServicingThread();
            }

            return(asyncResult);
        }
Exemple #8
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="runtime"></param>
        /// <param name="command"></param>
        /// <param name="name"></param>
        /// <param name="instanceId"></param>
        internal PSWorkflowJob(PSWorkflowRuntime runtime, string command, string name, Guid instanceId)
            : base(command, name, instanceId)
        {
            Dbg.Assert(runtime != null, "runtime must not be null.");

            _runtime = runtime;
            CommonInit();
        }
 // Pass the  PSWorkflowRuntime as the parameter.
 // This resumes execution of the job.
 public SampleActivityController(PSWorkflowRuntime runtime)
     : base(runtime)
 {
     _runtime = runtime;
 }
Exemple #10
0
        /// <summary>
        /// Construct a PSWorkflowJob.
        /// </summary>
        /// <param name="runtime"></param>
        /// <param name="specification">JobInvocationInfo representing the command this job will invoke.</param>
        /// <param name="JobInstanceId"></param>
        /// <param name="creationContext"></param>
        internal PSWorkflowJob(PSWorkflowRuntime runtime, JobInvocationInfo specification, Guid JobInstanceId, Dictionary<string, object> creationContext)
            : base(Validate(specification).Command, specification.Definition.Name, JobInstanceId)
        {
            Dbg.Assert(runtime != null, "runtime must not be null.");
            // If specification is null, ArgumentNullException would be raised from
            // the static validate method.
            StartParameters = specification.Parameters;
            _definition = WorkflowJobDefinition.AsWorkflowJobDefinition(specification.Definition);
            _jobCreationContext = creationContext;

            _runtime = runtime;
            CommonInit();
        }
Exemple #11
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="runtime"></param>
        /// <param name="command"></param>
        /// <param name="name"></param>
        /// <param name="token"></param>
        internal PSWorkflowJob(PSWorkflowRuntime runtime, string command, string name, JobIdentifier token)
            : base(command, name, token)
        {
            Dbg.Assert(runtime != null, "runtime must not be null.");

            _runtime = runtime;
            CommonInit();
        }
Exemple #12
0
		internal PSWorkflowJob(PSWorkflowRuntime runtime, string command, string name, Guid instanceId) : base(command, name, instanceId)
		{
			this._tracer = PowerShellTraceSourceFactory.GetTraceSource();
			this._syncObject = new object();
			this._resumeErrorSyncObject = new object();
			this._statusMessage = string.Empty;
			this._location = string.Empty;
			this._resumeErrors = new Dictionary<Guid, Exception>();
			this._workflowParameters = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
			this._psWorkflowCommonParameters = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
			this._jobMetadata = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
			this._privateMetadata = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
			this.IsSuspendable = null;
			this.listOfLabels = new List<string>();
			this._runtime = runtime;
			this.CommonInit();
		}
Exemple #13
0
		internal PSWorkflowJob(PSWorkflowRuntime runtime, JobInvocationInfo specification, Guid JobInstanceId) : base(PSWorkflowJob.Validate(specification).Command, specification.Definition.Name, JobInstanceId)
		{
			this._tracer = PowerShellTraceSourceFactory.GetTraceSource();
			this._syncObject = new object();
			this._resumeErrorSyncObject = new object();
			this._statusMessage = string.Empty;
			this._location = string.Empty;
			this._resumeErrors = new Dictionary<Guid, Exception>();
			this._workflowParameters = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
			this._psWorkflowCommonParameters = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
			this._jobMetadata = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
			this._privateMetadata = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
			this.IsSuspendable = null;
			this.listOfLabels = new List<string>();
			base.StartParameters = specification.Parameters;
			this._definition = WorkflowJobDefinition.AsWorkflowJobDefinition(specification.Definition);
			this._runtime = runtime;
			this.CommonInit();
		}
Exemple #14
0
        private void InitializePSWorkflowApplicationInstance(PSWorkflowRuntime runtime)
        {
            if (runtime == null)
                throw new ArgumentNullException("runtime");

            this.PersistAfterNextPSActivity = false;
            this.suspendAtNextCheckpoint = false;
            Runtime = runtime;

            this.asyncExecutionCollection = new Dictionary<string, PSActivityContext>();
            this.ForceDisableStartOrEndPersistence = false;

            if (Runtime.Configuration.PSWorkflowApplicationPersistUnloadTimeoutSec > 0)
            {
                PersistUnloadTimer = new Timer(Convert.ToDouble(Runtime.Configuration.PSWorkflowApplicationPersistUnloadTimeoutSec * 1000));
                PersistUnloadTimer.Elapsed += new ElapsedEventHandler(PersistUnloadTimer_Elapsed);
                PersistUnloadTimer.AutoReset = false;
            }

            this._debugger = new PSWorkflowDebugger(this);
        }
Exemple #15
0
        /// <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);
        }
		protected PSResumableActivityHostController(PSWorkflowRuntime runtime) : base(runtime)
		{
		}
		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");
			}
		}
Exemple #19
0
        private Activity ValidateWorkflow(JobInvocationInfo invocationInfo, Activity activity, ref bool?isSuspendable)
        {
            bool flag = false;
            PSWorkflowRuntime     instance              = PSWorkflowRuntime.Instance;
            JobDefinition         definition            = invocationInfo.Definition;
            WorkflowJobDefinition workflowJobDefinition = WorkflowJobDefinition.AsWorkflowJobDefinition(definition);
            bool flag1 = true;

            if (activity == null)
            {
                activity = DefinitionCache.Instance.GetActivityFromCache(workflowJobDefinition, out flag);
                if (activity != null)
                {
                    flag1 = false;
                    if (flag)
                    {
                        return(activity);
                    }
                }
                else
                {
                    throw new InvalidOperationException();
                }
            }
            if (instance.Configuration.EnableValidation)
            {
                if (!flag1 || DefinitionCache.Instance.AllowExternalActivity)
                {
                    PSWorkflowValidationResults pSWorkflowValidationResult = this.GetWorkflowValidator().ValidateWorkflow(definition.InstanceId, activity, DefinitionCache.Instance.GetRuntimeAssemblyName(workflowJobDefinition));
                    if (pSWorkflowValidationResult.Results != null)
                    {
                        this.GetWorkflowValidator().ProcessValidationResults(pSWorkflowValidationResult.Results);
                    }
                    isSuspendable = new bool?(pSWorkflowValidationResult.IsWorkflowSuspendable);
                    return(activity);
                }
                else
                {
                    if (Validation.CustomHandler != null)
                    {
                        if (!Validation.CustomHandler(activity))
                        {
                            string displayName = activity.DisplayName;
                            if (string.IsNullOrEmpty(displayName))
                            {
                                displayName = base.GetType().Name;
                            }
                            object[] objArray = new object[1];
                            objArray[0] = displayName;
                            string str = string.Format(CultureInfo.CurrentCulture, Resources.InvalidActivity, objArray);
                            throw new ValidationException(str);
                        }
                        else
                        {
                            return(activity);
                        }
                    }
                    else
                    {
                        throw new InvalidOperationException();
                    }
                }
            }
            else
            {
                return(activity);
            }
        }
 /// <summary>
 /// Runtime should be provided for accessing the runtime activity mode
 /// </summary>
 protected PSActivityHostController(PSWorkflowRuntime runtime)
 {
     _runtime = runtime;
 }
		protected PSActivityHostController(PSWorkflowRuntime runtime)
		{
			this._inProcActivityLookup = new ConcurrentDictionary<string, bool>();
			this._runtime = runtime;
		}
        static void Main(string[] args)
        {
            // Creat a variable for the workflow path.
            string workflowFileName = "SampleWorkflow.xaml";
            // Specify the database server name and instace before executing this command.
            string dbServer = "ServerName\\InstanceName";
            string database = "M3PExtendedStore";

            // Read the XAML into the variable
            string xaml = File.ReadAllText(workflowFileName);

            string conString = GetConnectionString(dbServer, database);

            // Create a runtime to host the application, passing the custom configuration provider.
            PSWorkflowRuntime runtime = new PSWorkflowRuntime(new SampleConfigurationProvider(conString));

            // Parameters to the workflow can be provided in this dictionary
            Dictionary<string, object> parameters = new Dictionary<string, object>();

            // Create the job, providing the XAML definition.
            PSWorkflowJob job = runtime.JobManager.CreateJob(Guid.NewGuid(), xaml, "Get-CurrentProcess", "SampleWorkflow", parameters);

            // Subscribe to the state change event before starting the job.
            AutoResetEvent wfEvent = new AutoResetEvent(false);
            job.StateChanged += delegate(object sender, JobStateEventArgs e)
            {
                switch (e.JobStateInfo.State)
                {
                    case JobState.Failed:
                    case JobState.Completed:
                    case JobState.Suspended:
                        {
                            wfEvent.Set();
                        }
                        break;
                }
            };

            // Start the job
            job.StartJob();

            // Wait for the state changes event
            wfEvent.WaitOne();

            // Check whether the workflow is in the suspended state.
            if (job.JobStateInfo.State == JobState.Suspended)
            {
                Console.WriteLine("The job has suspended successfully.");
            }
            else
            {
                // If not, inform the user that the job was not suspended.
                Console.WriteLine("The job has not reached a desired state.");
                Console.ReadLine();
                return;
            }

            Console.WriteLine("Resuming the job.");
            // Resume
            job.ResumeJob();

            // Wait for the state changes event
            wfEvent.WaitOne();

            // The workfow should be completed
            if (job.JobStateInfo.State == JobState.Completed)
            {
                Console.WriteLine("The job has completed successfully.");
                Console.WriteLine("Total Process found: " + job.PSWorkflowInstance.Streams.OutputStream.Count);
            }
            else
                Console.WriteLine("The job has Failed.");

            Console.WriteLine("Press <Enter> to continue...");
            Console.ReadLine();
        }
Exemple #23
0
        /// <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;            
        }
Exemple #24
0
		public PSWorkflowJobManager(PSWorkflowRuntime runtime, int throttleLimit)
		{
			this.lockObjects = new LockObjectsCollection();
			this._pendingQueue = new ConcurrentQueue<Tuple<Action<object>, object, JobState>>();
			this._servicingThreadSyncObject = new object();
			this._needToStartServicingThread = true;
			PSWorkflowJobManager lazy = this;
			lazy._waitForJobs = new Lazy<AutoResetEvent>(() => new AutoResetEvent(false));
			this._wfJobTable = new ConcurrentDictionary<Guid, PSWorkflowJob>();
			if (runtime != null)
			{
				if (PSWorkflowJobManager.TestMode)
				{
					Interlocked.Increment(ref PSWorkflowJobManager.ObjectCounter);
				}
				this._runtime = runtime;
				this._throttleLimit = throttleLimit;
				return;
			}
			else
			{
				throw new ArgumentNullException("runtime");
			}
		}
        private Activity ValidateWorkflow(JobInvocationInfo invocationInfo, Activity activity, ref bool?isSuspendable)
        {
            PSWorkflowRuntime     runtime               = PSWorkflowRuntime.Instance;
            JobDefinition         definition            = invocationInfo.Definition;
            WorkflowJobDefinition workflowJobDefinition = WorkflowJobDefinition.AsWorkflowJobDefinition(definition);

            bool externalActivity = true;

            if (activity == null)
            {
                bool windowsWorkflow;
                activity = DefinitionCache.Instance.GetActivityFromCache(workflowJobDefinition, out windowsWorkflow);
                // Debug.Assert(activity != null, "WorkflowManager failed validation for a null activity");
                if (activity == null)
                {
                    throw new InvalidOperationException();
                }

                externalActivity = false;

                // skip validation if it is a windows workflow
                if (windowsWorkflow)
                {
                    return(activity);
                }
            }

            // If validation is disabled, just return the activity as is...
            if (!runtime.Configuration.EnableValidation)
            {
                return(activity);
            }

            if (externalActivity && !DefinitionCache.Instance.AllowExternalActivity)
            {
                // If there is a custom validator activity, then call it. If it returns true
                // then just return the activity.
                if (Validation.CustomHandler == null)
                {
                    throw new InvalidOperationException();
                }

                if (Validation.CustomHandler.Invoke(activity))
                {
                    return(activity);
                }

                string displayName = activity.DisplayName;

                if (string.IsNullOrEmpty(displayName))
                {
                    displayName = this.GetType().Name;
                }

                string message = string.Format(CultureInfo.CurrentCulture, Resources.InvalidActivity, displayName);
                throw new ValidationException(message);
            }
            PSWorkflowValidationResults validationResults = GetWorkflowValidator().ValidateWorkflow(
                definition.InstanceId, activity,
                DefinitionCache.Instance.GetRuntimeAssemblyName(workflowJobDefinition));

            if (validationResults.Results != null)
            {
                GetWorkflowValidator().ProcessValidationResults(validationResults.Results);
            }

            isSuspendable = validationResults.IsWorkflowSuspendable;

            return(activity);
        }
Exemple #26
0
        /// <summary>
        /// Construct a workflow manager
        /// </summary>
        /// <param name="runtime"></param>
        /// <param name="throttleLimit"></param>
        public PSWorkflowJobManager(PSWorkflowRuntime runtime, int throttleLimit)
        {
            if (runtime == null) 
            {
                throw new ArgumentNullException("runtime");
            }

            if (TestMode)
            {
                System.Threading.Interlocked.Increment(ref ObjectCounter);
            }
            
            _runtime = runtime;
            _throttleLimit = throttleLimit;

            if (PSWorkflowSessionConfiguration.IsWorkflowTypeEndpoint)
            {
                _shutdownTimer = new Timer(_runtime.Configuration.WSManPluginReportCompletionOnZeroActiveSessionsWaitIntervalMSec);
                _shutdownTimer.Elapsed += ShutdownWaitTimerElapsed;
                _shutdownTimer.AutoReset = false;

                WSManServerChannelEvents.ActiveSessionsChanged += OnWSManServerActiveSessionsChangedEvent;
            }
        }
Exemple #27
0
        internal PSOutOfProcessActivityController(PSWorkflowRuntime runtime)
            : base(runtime)
        {
            if (runtime == null)
                throw new ArgumentNullException("runtime");

            Debug.Assert(runtime.Configuration != null, "For now only expecting PSWorkflowConfigurationProvider");

            this._configuration = runtime.Configuration;
            InitializeActivityHostProcesses();
        }
Exemple #28
0
        /// <summary>
        /// Construct a PSWorkflowJob.
        /// </summary>
        /// <param name="runtime"></param>
        /// <param name="specification">JobInvocationInfo representing the command this job
        /// will invoke.</param>
        internal PSWorkflowJob(PSWorkflowRuntime runtime, JobInvocationInfo specification)
            : base(Validate(specification).Command)
        {
            Dbg.Assert(runtime != null, "runtime must not be null.");
            // If specification is null, ArgumentNullException would be raised from
            // the static validate method.
            StartParameters = specification.Parameters;
            _definition = WorkflowJobDefinition.AsWorkflowJobDefinition(specification.Definition);

            _runtime = runtime;
            CommonInit();
        }