Ejemplo n.º 1
0
        /// <summary>
        /// Handles the ExecuteCode event of the Prepare CodeActivity.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void Prepare_ExecuteCode(object sender, EventArgs e)
        {
            Logger.Instance.WriteMethodEntry(EventIdentifier.UpdateResourcesPrepareExecuteCode);

            try
            {
                // If advanced options were not specified,
                // clear any supplied advanced settings so they do not impact activity execution
                if (!this.Advanced)
                {
                    this.QueryResources = false;
                    this.ActivityExecutionCondition = null;
                    this.Iteration = null;
                    this.ActorType = ActorType.Service;
                    this.ApplyAuthorizationPolicy = false;
                }

                // If the activity is configured to query for resources,
                // convert the queries hash table to a list of definitions that will feed the activity responsible
                // for their execution
                if (this.QueryResources && this.QueriesTable != null && this.QueriesTable.Count > 0)
                {
                    DefinitionsConverter queriesConverter = new DefinitionsConverter(this.QueriesTable);
                    this.Queries = queriesConverter.Definitions;
                }

                // If the activity is configured for iteration or conditional execution, parse the associated expressions
                this.ActivityExpressionEvaluator.ParseIfExpression(this.Iteration);
                this.ActivityExpressionEvaluator.ParseIfExpression(this.ActivityExecutionCondition);

                // Definitions are supplied to the workflow activity in the form of a hash table
                // This is necessary due to deserialization issues with lists and custom classes
                // Convert the updates hash table to a list of definitions that is easier to work with
                DefinitionsConverter updatesConverter = new DefinitionsConverter(this.UpdatesTable);
                this.updates = updatesConverter.Definitions;

                // Load each source expression into the evaluator so associated lookups can be loaded into the cache for resolution
                // For updates, the left side of the definition represents the source expression
                foreach (Definition updateDefinition in this.updates)
                {
                    this.ActivityExpressionEvaluator.ParseExpression(updateDefinition.Left);
                }
            }
            finally
            {
                Logger.Instance.WriteMethodExit(EventIdentifier.UpdateResourcesPrepareExecuteCode);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Handles the ExecuteCode event of the ParseConditions CodeActivity.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void ParseConditions_ExecuteCode(object sender, EventArgs e)
        {
            Logger.Instance.WriteMethodEntry(EventIdentifier.VerifyRequestParseConditionsExecuteCode);

            try
            {
                // Definitions are supplied to the workflow activity in the form of a hash table
                // This is necessary due to deserialization issues with lists and custom classes
                // Convert the hash table to a list of definitions that is easier to work with
                DefinitionsConverter converter = new DefinitionsConverter(this.ConditionsTable);
                this.conditions = converter.Definitions;

                // Load each condition expression into the evaluator so associated lookups
                // can be loaded into the cache for resolution
                foreach (Definition conditionDefinition in this.conditions)
                {
                    this.ActivityExpressionEvaluator.ParseExpression(conditionDefinition.Left);
                }
            }
            finally
            {
                Logger.Instance.WriteMethodExit(EventIdentifier.VerifyRequestParseConditionsExecuteCode);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Handles the ExecuteCode event of the ParseExpressions CodeActivity.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void ParseExpressions_ExecuteCode(object sender, EventArgs e)
        {
            Logger.Instance.WriteMethodEntry(EventIdentifier.GenerateUniqueValueParseExpressionsExecuteCode);

            try
            {
                // If the activity is configured for conditional execution, parse the associated expression
                this.ActivityExpressionEvaluator.ParseIfExpression(this.ActivityExecutionCondition);

                // Load each value expression into the evaluator so associated lookups can be loaded into the cache for resolution
                // Before parsing the value expression, be sure to replace any instance of the [//UniquenessKey] lookup with
                // a random value to prevent it from being loaded to the cache
                // Standard resolution of this lookup would result in an exception
                foreach (string valueExpression in this.ValueExpressions)
                {
                    this.ActivityExpressionEvaluator.ParseExpression(this.ResolveUniquenessKey(valueExpression, 0, false));
                }

                // If the activity is configured to query LDAP for conflicts,
                // convert the LDAP queries hash table to a list of definitions and then parse each query
                if (!this.QueryLdap || this.LdapQueriesTable == null || this.LdapQueriesTable.Count <= 0)
                {
                    return;
                }

                DefinitionsConverter queriesConverter = new DefinitionsConverter(this.LdapQueriesTable);
                this.LdapQueries = queriesConverter.Definitions;

                // Parse the expressions in the LDAP Queries, if any
                for (int i = 0; i < this.LdapQueries.Count; ++i)
                {
                    this.ActivityExpressionEvaluator.ParseIfExpression(this.LdapQueries[i].Left);
                }
            }
            finally
            {
                Logger.Instance.WriteMethodExit(EventIdentifier.GenerateUniqueValueParseExpressionsExecuteCode);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Handles the ExecuteCode event of the Prepare CodeActivity.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void Prepare_ExecuteCode(object sender, EventArgs e)
        {
            Logger.Instance.WriteMethodEntry(EventIdentifier.RunPowerShellScriptPrepareExecuteCode);

            try
            {
                // If advanced options were not specified,
                // clear any supplied advanced settings so they do not impact activity execution
                if (!this.Advanced)
                {
                    this.ActivityExecutionCondition = null;
                    this.PowerShellUser = null;
                    this.PowerShellUserPassword = null;
                    this.ImpersonatePowerShellUser = false;
                    this.ImpersonatePowerShellUserLoadUserProfile = false;
                    this.ImpersonatePowerShellUserLogOnType = LogOnType.None;
                }

                // If the script needs to be resolved, parse the expression via the
                // expression evaluator to prepare for lookup resolution
                if (this.ScriptLocation == PowerShellScriptLocation.Resource)
                {
                    this.ActivityExpressionEvaluator.ParseExpression(this.Script);
                }

                // If the activity is configured for conditional execution, parse the associated expression
                this.ActivityExpressionEvaluator.ParseIfExpression(this.ActivityExecutionCondition);

                if (this.InputType == PowerShellInputType.Arguments &&
                    this.Arguments != null &&
                    this.Arguments.Count > 0)
                {
                    // If we're supplying arguments to the PowerShell script,
                    // parse each argument in the list to facilitate resolution
                    foreach (string s in this.Arguments)
                    {
                        this.ActivityExpressionEvaluator.ParseExpression(s);
                    }
                }
                else if (this.InputType == PowerShellInputType.Parameters &&
                         this.ParametersTable != null &&
                         this.ParametersTable.Count > 0)
                {
                    // If we're supplying named parameters ot the PowerShell script,
                    // parse the right side of the parameter listing which represents the value
                    DefinitionsConverter parametersConverter = new DefinitionsConverter(this.ParametersTable);
                    this.parameters = parametersConverter.Definitions;
                    foreach (Definition parameter in this.parameters)
                    {
                        this.ActivityExpressionEvaluator.ParseExpression(parameter.Right);
                    }
                }
            }
            finally
            {
                Logger.Instance.WriteMethodExit(EventIdentifier.RunPowerShellScriptPrepareExecuteCode);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Handles the ChildCompleted event of the ForEachIteration ReplicatorActivity.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="ReplicatorChildEventArgs"/> instance containing the event data.</param>
        private void ForEachIteration_ChildCompleted(object sender, ReplicatorChildEventArgs e)
        {
            Logger.Instance.WriteMethodEntry(EventIdentifier.UpdateResourcesForEachIterationChildCompleted, "Iteration: '{0}' of '{1}'. ", this.iterations, this.ForEachIteration.InitialChildData.Count);

            try
            {
                var variableCache = this.ActivityExpressionEvaluator.VariableCache;
                this.breakIteration = Convert.ToBoolean(variableCache[ExpressionEvaluator.ReservedVariableBreakIteration], CultureInfo.InvariantCulture);

                // Reset to the original update definitions as ResolveDynamicGrammar updates the working definitions.
                // The If check is really not needed.
                if (this.ResolveDynamicGrammar)
                {
                    DefinitionsConverter updatesConverter = new DefinitionsConverter(this.UpdatesTable);
                    this.updates = updatesConverter.Definitions;
                }
            }
            finally
            {
                Logger.Instance.WriteMethodExit(EventIdentifier.UpdateResourcesForEachIterationChildCompleted, "Iteration: '{0}' of '{1}'. Break Iteration '{2}'.", this.iterations, this.ForEachIteration.InitialChildData.Count, this.breakIteration);
            }
        }