// Class constructor. The reference to the PSWorkflowConfigurationProvider must be available to the class to access configuration properties.
        // The workflow instance reference provides access to the instance ID and properties during load and save operations.
        public SampleSqlInstanceStore(PSWorkflowConfigurationProvider configuration, PSWorkflowInstance instance, string connectionString)
            : base(instance)
        {
            _configuration         = configuration;
            this._connectionString = connectionString;

            this._psWorkflowStore = new SqlOperations(connectionString);
        }
예제 #2
0
        /// <summary>
        /// Constructs runtime based on configuration
        /// </summary>
        /// <param name="configuration"></param>
        public PSWorkflowRuntime(PSWorkflowConfigurationProvider configuration)
        {
            if (configuration == null)
                throw new ArgumentNullException("configuration");

            // Only allow FullLanguage or ConstraintLanguage or it can be null in that case system wide default will take an affect
            PSLanguageMode? langMode = configuration.LanguageMode;
            if (langMode != null && langMode.HasValue && (langMode.Value == PSLanguageMode.NoLanguage || langMode.Value == PSLanguageMode.RestrictedLanguage))
            {
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.NotSupportedLanguageMode, langMode.Value.ToString()));
            }

            _configuration = configuration;
            _configuration.Runtime = this;
        }
예제 #3
0
        /// <summary>
        /// Default constructor
        /// </summary>
        public PSWorkflowRuntime()
        {
            _configuration = new PSWorkflowConfigurationProvider();
            _configuration.Runtime = this;
            PSCounterSetRegistrar registrar = 
                new PSCounterSetRegistrar(
                    PSWorkflowPerformanceCounterSetInfo.ProviderId,
                    PSWorkflowPerformanceCounterSetInfo.CounterSetId,
                    PSWorkflowPerformanceCounterSetInfo.CounterSetType,
                    PSWorkflowPerformanceCounterSetInfo.CounterInfoArray);
            _psPerfCountersMgrInst.AddCounterSetInstance(registrar);

            // Enable caching module paths appdomain-wide.
            System.Management.Automation.PSModuleInfo.UseAppDomainLevelModuleCache = true;
        }
		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");
			}
		}
예제 #5
0
        private DefaultWorkflowHost()
        {
            try
            {
                this._serviceCore = Assembly.Load("Microsoft.PowerShell.Workflow.ServiceCore, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL");
            }
            catch (ArgumentNullException argumentNullException)
            {
            }
            catch (FileNotFoundException fileNotFoundException)
            {
            }
            catch (FileLoadException fileLoadException)
            {
            }
            catch (BadImageFormatException badImageFormatException)
            {
            }
            catch (SecurityException securityException)
            {
            }
            catch (ArgumentException argumentException)
            {
            }
            catch (PathTooLongException pathTooLongException)
            {
            }
            Type         type     = this._serviceCore.GetType("Microsoft.PowerShell.Workflow.PSWorkflowRuntime");
            PropertyInfo property = type.GetProperty("Instance", BindingFlags.Static | BindingFlags.NonPublic);
            object       value    = property.GetValue(null, null);

            property = value.GetType().GetProperty("Configuration");
            PSWorkflowConfigurationProvider pSWorkflowConfigurationProvider = (PSWorkflowConfigurationProvider)property.GetValue(value, null);

            pSWorkflowConfigurationProvider.Populate("\r\n                <PrivateData>\r\n                    <Param Name='AllowedActivity' Value='PSDefaultActivities' />\r\n                </PrivateData>\r\n", "Microsoft.PowerShell.Workflow");
            property = value.GetType().GetProperty("PSActivityHostController", BindingFlags.Instance | BindingFlags.Public);
            this._activityHostController = (PSActivityHostController)property.GetValue(value, null);
            property = value.GetType().GetProperty("RemoteRunspaceProvider", BindingFlags.Instance | BindingFlags.Public);
            this._runspaceProvider = (RunspaceProvider)property.GetValue(value, null);
            property = value.GetType().GetProperty("LocalRunspaceProvider", BindingFlags.Instance | BindingFlags.Public);
            this._localRunspaceProvider = (RunspaceProvider)property.GetValue(value, null);
        }
예제 #6
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();
        }
예제 #7
0
		public PSWorkflowRuntime(PSWorkflowConfigurationProvider configuration)
		{
			this._syncObject = new object();
			if (configuration != null)
			{
				PSLanguageMode? languageMode = configuration.LanguageMode;
				if (!languageMode.HasValue || !languageMode.HasValue || languageMode.Value != PSLanguageMode.NoLanguage && languageMode.Value != PSLanguageMode.RestrictedLanguage)
				{
					this._configuration = configuration;
					this._configuration.Runtime = this;
					return;
				}
				else
				{
					object[] str = new object[1];
					str[0] = languageMode.Value.ToString();
					throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.NotSupportedLanguageMode, str));
				}
			}
			else
			{
				throw new ArgumentNullException("configuration");
			}
		}
예제 #8
0
		public PSWorkflowRuntime()
		{
			this._syncObject = new object();
			this._configuration = new PSWorkflowConfigurationProvider();
			this._configuration.Runtime = this;
			PSCounterSetRegistrar pSCounterSetRegistrar = new PSCounterSetRegistrar(PSWorkflowPerformanceCounterSetInfo.ProviderId, PSWorkflowPerformanceCounterSetInfo.CounterSetId, PSWorkflowPerformanceCounterSetInfo.CounterSetType, PSWorkflowPerformanceCounterSetInfo.CounterInfoArray, null);
			PSWorkflowRuntime._psPerfCountersMgrInst.AddCounterSetInstance(pSCounterSetRegistrar);
			PSModuleInfo.UseAppDomainLevelModuleCache = true;
		}
예제 #9
0
        /// <summary>
        /// PSWorkflowValidator
        /// </summary>
        /// <param name="configuration"></param>
        public PSWorkflowValidator(PSWorkflowConfigurationProvider configuration)
        {
            if (configuration == null)
                throw new ArgumentNullException("configuration");

            if (TestMode)
            {
                System.Threading.Interlocked.Increment(ref ObjectCounter);
            }

            this.Configuration = configuration;
        }
예제 #10
0
		public PSWorkflowFileInstanceStore(PSWorkflowConfigurationProvider configuration, PSWorkflowInstance instance) : base(instance)
		{
			this.Tracer = PowerShellTraceSourceFactory.GetTraceSource();
			this.Streams = "Str";
			this.Error = "Err";
			this.Metadatas = "Meta";
			this.Definition = "Def";
			this.WorkflowState = "Stat";
			this.Version_xml = "V.xml";
			this.InputStream_xml = "IS.xml";
			this.OutputStream_xml = "OS.xml";
			this.ErrorStream_xml = "ES.xml";
			this.WarningStream_xml = "WS.xml";
			this.VerboseStream_xml = "VS.xml";
			this.ProgressStream_xml = "PS.xml";
			this.DebugStream_xml = "DS.xml";
			this.ErrorException_xml = "EE.xml";
			this.Input_xml = "I.xml";
			this.PSWorkflowCommonParameters_xml = "UI.xml";
			this.JobMetadata_xml = "JM.xml";
			this.PrivateMetadata_xml = "PM.xml";
			this.Timer_xml = "TI.xml";
			this.WorkflowInstanceState_xml = "WS.xml";
			this.WorkflowDefinition_xaml = "WD.xaml";
			this.RuntimeAssembly_dll = "RA.dll";
			this.State_xml = "S.xml";
			this._syncLock = new object();
			if (configuration != null)
			{
				if (PSWorkflowFileInstanceStore.TestMode)
				{
					Interlocked.Increment(ref PSWorkflowFileInstanceStore.ObjectCounter);
				}
				this._configuration = configuration;
				this.firstTimeStoringDefinition = true;
				this.SavedComponentLengths = new Dictionary<InternalStoreComponents, long>();
				bool flag = true;
				this._disablePersistenceLimits = true;
				if (PSSessionConfigurationData.IsServerManager)
				{
					flag = false;
					this._disablePersistenceLimits = false;
				}
				this._version = new PersistenceVersion(this._configuration.PersistWithEncryption, flag);
				Guid id = base.PSWorkflowInstance.Id;
				this._version.load(Path.Combine(this._configuration.InstanceStorePath, id.ToString(), this.Version_xml));
				return;
			}
			else
			{
				throw new ArgumentNullException("configuration");
			}
		}
 protected override PSSessionTypeOption ConstructObjectFromPrivateData(string privateData)
 {
     return(PSWorkflowConfigurationProvider.LoadConfig(privateData, null));
 }
예제 #12
0
		public PSWorkflowValidator(PSWorkflowConfigurationProvider configuration)
		{
			this._validationCache = new ConcurrentDictionary<Guid, PSWorkflowValidationResults>();
			if (configuration != null)
			{
				if (PSWorkflowValidator.TestMode)
				{
					Interlocked.Increment(ref PSWorkflowValidator.ObjectCounter);
				}
				this.Configuration = configuration;
				return;
			}
			else
			{
				throw new ArgumentNullException("configuration");
			}
		}