public override Activity GenerateActivityOnWorkflow(SequentialWorkflow workflow) { Logger.Instance.WriteMethodEntry(); try { // Create a new instance of the GenerateUniqueValue activity and assign // dependenty property values based on inputs to standard activity controls GenerateUniqueValue wfa = new GenerateUniqueValue { ActivityDisplayName = this.activityDisplayName.Value, ActivityExecutionCondition = this.activityExecutionCondition.Value, PublicationTarget = this.publicationTarget.Value, ConflictFilter = this.conflictFilter.Value, QueryLdap = this.queryLdap.Value, UniquenessSeed = this.uniquenessSeed.Value, ValueExpressions = this.FetchValueExpressions() }; DefinitionsConverter ldapQueriesConverter = new DefinitionsConverter(this.ldapQueries.DefinitionListings); wfa.LdapQueriesTable = ldapQueriesConverter.DefinitionsTable; return(wfa); } catch (Exception e) { Logger.Instance.ReportError(e); throw; } finally { Logger.Instance.WriteMethodExit(); } }
public override Activity GenerateActivityOnWorkflow(SequentialWorkflow workflow) { Logger.Instance.WriteMethodEntry(); try { // Generate a new instance of the Run PowerShell Script activity // and add properties based on specified values RunPowerShellScript wfa = new RunPowerShellScript { ActivityDisplayName = this.activityDisplayName.Value, Advanced = this.advanced.Value, ActivityExecutionCondition = this.activityExecutionCondition.Value, PowerShellUser = this.powerShellUser.Value, PowerShellUserPassword = this.powerShellUserPassword.Value, ImpersonatePowerShellUser = this.impersonatePowerShellUser.Value, ImpersonatePowerShellUserLoadUserProfile = this.loadUserProfile.Value, ImpersonatePowerShellUserLogOnType = this.impersonatePowerShellUser.Value ? GetImpersonationLogOnType(this.impersonationLogOnType.Value) : LogOnType.None, ScriptLocation = GetScriptLocation(this.scriptLocation.Value), Script = this.script.Value, FailOnMissing = this.failOnMissing.Value, InputType = GetInputType(this.inputType.Value), ReturnType = GetReturnType(this.returnType.Value), ReturnValueLookup = this.returnValueLookup.Value }; // Depending on the input type selection, // the activity will be configured with parameters or arguments, but not both switch (wfa.InputType) { case PowerShellInputType.Parameters: { DefinitionsConverter parametersConverter = new DefinitionsConverter(this.parameters.DefinitionListings); wfa.ParametersTable = parametersConverter.DefinitionsTable; } break; case PowerShellInputType.Arguments: { wfa.Arguments = this.FetchArguments(); } break; } return(wfa); } catch (Exception e) { Logger.Instance.ReportError(e); throw; } finally { Logger.Instance.WriteMethodExit(); } }
/// <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); } }
/// <summary> /// Handles the ExecuteCode event of the ParseDefinitions 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 ParseDefinitions_ExecuteCode(object sender, EventArgs e) { Logger.Instance.WriteMethodEntry(EventIdentifier.CreateResourceParseDefinitionsExecuteCode); 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.CreatedResourceIdTarget = null; this.CheckForConflict = false; this.ActivityExecutionCondition = null; this.Iteration = null; this.ActorType = ActorType.Service; this.ApplyAuthorizationPolicy = false; } // 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 attributes hash table to a list of definitions that is easier to work with DefinitionsConverter updatesConverter = new DefinitionsConverter(this.AttributesTable); this.attributes = updatesConverter.Definitions; // 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); // Load each source expression into the evaluator so associated lookups can be loaded into the cache for resolution // For attributes, the left side of the definition represents the source expression foreach (Definition attributeDefinition in this.attributes) { this.ActivityExpressionEvaluator.ParseExpression(attributeDefinition.Left); } } finally { Logger.Instance.WriteMethodExit(EventIdentifier.CreateResourceParseDefinitionsExecuteCode); } }
public override Activity GenerateActivityOnWorkflow(SequentialWorkflow workflow) { Logger.Instance.WriteMethodEntry(); try { // Create a new instance of the CreateResource activity and assign // dependency property values based on inputs to standard activity controls CreateResource wfa = new CreateResource { ActivityDisplayName = this.activityDisplayName.Value, ResourceType = this.resourceType.Value, Advanced = this.advanced.Value, QueryResources = this.queryResources.Value, ActivityExecutionCondition = this.activityExecutionCondition.Value, Iteration = this.iteration.Value, ActorType = GetActorType(this.actorType.Value), ActorString = this.actorString.Value, ApplyAuthorizationPolicy = this.applyAuthorizationPolicy.Value, CreatedResourceIdTarget = this.createdResourceIdTarget.Value, CheckForConflict = this.checkForConflict.Value, ConflictFilter = this.conflictFilter.Value, ConflictingResourceIdTarget = this.conflictingResourceIdTarget.Value, FailOnConflict = this.failOnConflict.Value }; // Convert the definition listings (web controls) to hash tables which can be serialized to the XOML workflow definition // A hash table is used due to issues with deserialization of lists and other structured data DefinitionsConverter queriesConverter = new DefinitionsConverter(this.queries.DefinitionListings); DefinitionsConverter attributesConverter = new DefinitionsConverter(this.attributes.DefinitionListings); wfa.QueriesTable = queriesConverter.DefinitionsTable; wfa.AttributesTable = attributesConverter.DefinitionsTable; return(wfa); } catch (Exception e) { Logger.Instance.ReportError(e); throw; } finally { Logger.Instance.WriteMethodExit(); } }
public override Activity GenerateActivityOnWorkflow(SequentialWorkflow workflow) { Logger.Instance.WriteMethodEntry(); try { // Create a new instance of the SendEmailNotification activity and assign // dependenty property values based on inputs to standard activity controls SendEmailNotification wfa = new SendEmailNotification { ActivityDisplayName = this.activityDisplayName.Value, QueryResources = this.queryResources.Value, Advanced = this.advanced.Value, ActivityExecutionCondition = this.activityExecutionCondition.Value, Iteration = this.iteration.Value, EmailTemplate = this.emailTemplate.Value, To = this.to.Value, CC = this.cc.Value, Bcc = this.bcc.Value, SuppressException = this.suppressException.Value, }; // Convert the definition listings (web controls) to hash tables which can be serialized to the XOML workflow definition // A hash table is used due to issues with deserialization of lists and other structured data DefinitionsConverter queriesConverter = new DefinitionsConverter(this.queries.DefinitionListings); DefinitionsConverter workflowDataVariablesConverter = new DefinitionsConverter(this.workflowDataVariables.DefinitionListings); wfa.QueriesTable = queriesConverter.DefinitionsTable; wfa.WorkflowDataVariablesTable = workflowDataVariablesConverter.DefinitionsTable; return(wfa); } catch (Exception e) { Logger.Instance.ReportError(e); throw; } finally { Logger.Instance.WriteMethodExit(); } }
/// <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); } }
/// <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); } }
public override Activity GenerateActivityOnWorkflow(SequentialWorkflow workflow) { Logger.Instance.WriteMethodEntry(); try { // Create a new instance of the VerifyRequest activity and assign // dependenty property values based on inputs to standard activity controls VerifyRequest wfa = new VerifyRequest { ActivityDisplayName = this.activityDisplayName.Value, Advanced = this.advanced.Value, ActivityExecutionCondition = this.activityExecutionCondition.Value, CheckForConflict = this.checkForConflict.Value, ConflictFilter = this.conflictFilter.Value, ConflictDenialMessage = this.conflictDenialMessage.Value, CheckForRequestConflict = this.checkForRequestConflict.Value, RequestConflictAdvancedFilter = this.requestConflictAdvancedFilter.Value, RequestConflictMatchCondition = this.requestConflictMatchCondition.Value, RequestConflictDenialMessage = this.requestConflictDenialMessage.Value }; // Convert the definition listings (web controls) to a hash table which can be serialized to the XOML workflow definition // A hash table is used due to issues with deserialization of lists and other structured data DefinitionsConverter converter = new DefinitionsConverter(this.conditions.DefinitionListings); wfa.ConditionsTable = converter.DefinitionsTable; return(wfa); } catch (Exception e) { Logger.Instance.ReportError(e); throw; } finally { Logger.Instance.WriteMethodExit(); } }
/// <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); } }