/// <summary> /// Initializes a new instance of the <see cref="DetermineActor"/> class. /// </summary> public DetermineActor() { Logger.Instance.WriteMethodEntry(EventIdentifier.DetermineActorConstructor); try { this.InitializeComponent(); if (this.ActivityExpressionEvaluator == null) { this.ActivityExpressionEvaluator = new ExpressionEvaluator(); } } finally { Logger.Instance.WriteMethodExit(EventIdentifier.DetermineActorConstructor); } }
/// <summary> /// Validates the inputs. Returns true if all of the UI controls contain valid values. Otherwise, returns false. /// </summary> /// <returns>true if all of the UI controls contain valid values. Otherwise, false.</returns> public override bool ValidateInputs() { Logger.Instance.WriteMethodEntry(); try { if (!this.controller.ValidateInputs()) { return false; } ExpressionEvaluator evaluator = new ExpressionEvaluator(); switch (GetInputType(this.inputType.Value)) { case PowerShellInputType.Parameters: foreach (DefinitionListing parameter in this.parameters.DefinitionListings.Where(parameter => parameter.Active)) { if (parameter.Definition == null) { // If a value is missing for parameter name or value expression, the definition // will be null and the listing fails validation this.controller.ValidationError = ActivitySettings.ScriptParameterDefintionValidationError; return false; } // Attempt to parse the value expression try { evaluator.ParseExpression(parameter.Definition.Right); } catch (WorkflowActivityLibraryException ex) { this.controller.ValidationError = ex.Message; return false; } } break; case PowerShellInputType.Arguments: foreach (DefinitionListing argument in this.arguments.DefinitionListings.Where(argument => argument.Active)) { if (string.IsNullOrEmpty(argument.State.Left)) { // If a value is missing for the expression, fail validation this.controller.ValidationError = ActivitySettings.ScriptArgumentValidationError; return false; } // Attempt to parse the value expression try { evaluator.ParseExpression(argument.State.Left); } catch (WorkflowActivityLibraryException ex) { this.controller.ValidationError = ex.Message; return false; } } break; } try { if (!string.IsNullOrEmpty(this.activityExecutionCondition.Value)) { evaluator.ParseExpression(this.activityExecutionCondition.Value); // Verify that the activity execution condition resolves to a Boolean value if (!evaluator.IsBooleanExpression(this.activityExecutionCondition.Value)) { this.controller.ValidationError = ActivitySettings.ActivityExecutionConditionValidationError; return false; } } } catch (WorkflowActivityLibraryException ex) { this.controller.ValidationError = ex.Message; return false; } if (this.impersonatePowerShellUser.Value) { if (string.IsNullOrEmpty(this.powerShellUser.Value) || string.IsNullOrEmpty(this.powerShellUserPassword.Value)) { this.controller.ValidationError = ActivitySettings.PowerShellImpersonationSettingsValidationError; return false; } } if (!string.IsNullOrEmpty(this.powerShellUser.Value)) { if (!this.powerShellUser.Value.Contains(@"\")) { this.controller.ValidationError = ActivitySettings.PowerShellUserFormatValidationError; return false; } if (string.IsNullOrEmpty(this.powerShellUserPassword.Value)) { this.controller.ValidationError = ActivitySettings.PowerShellImpersonationSettingsValidationError; return false; } try { ProtectedData.DecryptData(this.powerShellUserPassword.Value); } catch (WorkflowActivityLibraryException ex) { this.controller.ValidationError = ex.Message; return false; } } // If no errors were found, clear any validation error and return true this.controller.ValidationError = string.Empty; return true; } catch (Exception e) { Logger.Instance.ReportError(e); throw; } finally { Logger.Instance.WriteMethodExit(); } }
/// <summary> /// Initializes a new instance of the <see cref="SendEmailNotification"/> class. /// </summary> public SendEmailNotification() { Logger.Instance.WriteMethodEntry(EventIdentifier.SendEmailNotificationConstructor); try { this.InitializeComponent(); if (this.ActivityExpressionEvaluator == null) { this.ActivityExpressionEvaluator = new ExpressionEvaluator(); } } finally { Logger.Instance.WriteMethodExit(EventIdentifier.SendEmailNotificationConstructor); } }
/// <summary> /// Validates the inputs. Returns true if all of the UI controls contain valid values. Otherwise, returns false. /// </summary> /// <returns>true if all of the UI controls contain valid values. Otherwise, false.</returns> public override bool ValidateInputs() { Logger.Instance.WriteMethodEntry(); try { if (!this.controller.ValidateInputs()) { return false; } ExpressionEvaluator evaluator = new ExpressionEvaluator(); if (this.advanced.Value) { try { if (!string.IsNullOrEmpty(this.activityExecutionCondition.Value)) { evaluator.ParseExpression(this.activityExecutionCondition.Value); // Verify that the activity execution condition resolves to a Boolean value if (!evaluator.IsBooleanExpression(this.activityExecutionCondition.Value)) { this.controller.ValidationError = ActivitySettings.ActivityExecutionConditionValidationError; return false; } } if (!string.IsNullOrEmpty(this.iteration.Value)) { evaluator.ParseExpression(this.iteration.Value); } if (GetActorType(this.actorType.Value) == ActorType.Resolve) { evaluator.ParseExpression(this.actorString.Value); } } catch (WorkflowActivityLibraryException ex) { // If an exception was thrown while attempting to parse lookups, report the error this.controller.ValidationError = ex.Message; return false; } if (this.applyAuthorizationPolicy.Value && GetActorType(this.actorType.Value) == ActorType.Service) { this.controller.ValidationError = ActivitySettings.RequestActorValidationError; return false; } } if (this.targetType.Value == DeleteResourcesTargetType.ResolveTarget.ToString()) { if (!string.IsNullOrEmpty(this.targetExpression.Value)) { try { evaluator.ParseExpression(this.targetExpression.Value); } catch (WorkflowActivityLibraryException ex) { // If an exception was thrown while attempting to parse lookups, report the error this.controller.ValidationError = ex.Message; return false; } } else { this.controller.ValidationError = ActivitySettings.TargetLookupExpressionMissingValidationError; return false; } } else if (this.targetType.Value == DeleteResourcesTargetType.SearchForTarget.ToString()) { if (string.IsNullOrEmpty(this.targetExpression.Value)) { this.controller.ValidationError = ActivitySettings.TargetXPathExpressionMissingValidationError; return false; } } // Verify that no [//Query/...] or [//Value/...] expressions exist // if the query resources or iteration options are not enabled, respectively bool containsQueryExpressions = false; bool containsValueExpressions = false; foreach (LookupEvaluator lookup in evaluator.LookupCache.Keys.Select(key => new LookupEvaluator(key))) { if (lookup.Parameter == LookupParameter.Queries) { containsQueryExpressions = true; } if (lookup.Parameter == LookupParameter.Value) { containsValueExpressions = true; } } if (containsQueryExpressions) { this.controller.ValidationError = ActivitySettings.QueryResourcesValidationError; return false; } if (string.IsNullOrEmpty(this.iteration.Value) && containsValueExpressions) { this.controller.ValidationError = ActivitySettings.IterationValidationError; return false; } // If no errors were found, clear any validation error and return true this.controller.ValidationError = string.Empty; return true; } catch (Exception e) { Logger.Instance.ReportError(e); throw; } finally { Logger.Instance.WriteMethodExit(); } }
/// <summary> /// Initializes a new instance of the <see cref="UpdateResources"/> class. /// </summary> public UpdateResources() { Logger.Instance.WriteMethodEntry(EventIdentifier.UpdateResourcesConstructor); try { this.InitializeComponent(); if (this.ActivityExpressionEvaluator == null) { this.ActivityExpressionEvaluator = new ExpressionEvaluator(); } if (this.LookupUpdates == null) { this.LookupUpdates = new List<UpdateLookupDefinition>(); } if (this.Queries == null) { this.Queries = new List<Definition>(); } if (this.ValueExpressions == null) { this.ValueExpressions = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase); } } finally { Logger.Instance.WriteMethodExit(EventIdentifier.UpdateResourcesConstructor); } }
/// <summary> /// Validates the inputs. Returns true if all of the UI controls contain valid values. Otherwise, returns false. /// </summary> /// <returns>true if all of the UI controls contain valid values. Otherwise, false.</returns> public override bool ValidateInputs() { Logger.Instance.WriteMethodEntry(); try { // Use the controller to validate standard activity controls // and return false if a problem was identified if (!this.controller.ValidateInputs()) { return false; } try { // Verify that the target lookup is valid LookupEvaluator targetLookup = new LookupEvaluator(this.publicationTarget.Value); if (!targetLookup.IsValidTarget) { this.controller.ValidationError = string.Format(CultureInfo.CurrentUICulture, ActivitySettings.TargetLookupValidationError, this.publicationTarget.Value); return false; } } catch (WorkflowActivityLibraryException ex) { // If an exception was thrown while attempting to parse lookups, report the error this.controller.ValidationError = ex.Message; return false; } // Verify that the supplied conflict filter is a valid XPath query if (!ExpressionEvaluator.IsXPath(this.conflictFilter.Value)) { this.controller.ValidationError = ActivitySettings.ConflictFilterValidationError; return false; } // Verify that the supplied conflict filter contains the [//Value] lookup if (!this.conflictFilter.Value.ToUpperInvariant().Contains("[//VALUE]")) { this.controller.ValidationError = ActivitySettings.ConflictFilterValueLookupValidationError; return false; } ExpressionEvaluator evaluator = new ExpressionEvaluator(); if (this.queryLdap.Value) { // Loop through all active query listings and make sure they are valid foreach (DefinitionListing query in this.ldapQueries.DefinitionListings.Where(query => query.Active)) { // If a value is missing for key or query, the definition // will be null and the listing fails validation if (query.Definition == null) { this.controller.ValidationError = ActivitySettings.LdapQueryDefinitionValidationError; return false; } // Make sure that the specified XPath filter is properly formatted if (!query.Definition.Right.ToUpperInvariant().Contains("[//VALUE]")) { this.controller.ValidationError = ActivitySettings.LdapQueryDefinitionValueLookupValidationError; return false; } // If it's an expression, make sure it's properly formatted if (ExpressionEvaluator.IsExpression(query.Definition.Left)) { try { evaluator.ParseExpression(query.Definition.Left); } catch (WorkflowActivityLibraryException ex) { this.controller.ValidationError = ex.Message; return false; } } } } // Count the active value expressions int count = this.valueExpressions.DefinitionListings.Count(valueExpression => valueExpression.Active); // Loop through all active update listings and make sure they are valid int i = 1; foreach (DefinitionListing valueExpression in this.valueExpressions.DefinitionListings.Where(valueExpression => valueExpression.Active)) { if (string.IsNullOrEmpty(valueExpression.State.Left)) { // If a value is missing for the expression, fail validation this.controller.ValidationError = ActivitySettings.ValueExpressionValidationError; return false; } // Attempt to parse the value expression try { evaluator.ParseExpression(valueExpression.State.Left); } catch (WorkflowActivityLibraryException ex) { this.controller.ValidationError = ex.Message; return false; } // Verify that the [//UniquenessKey] lookup is only present in the last value expression bool containsKey = valueExpression.State.Left.ToUpperInvariant().Contains("[//UNIQUENESSKEY]"); if (i < count && containsKey) { this.controller.ValidationError = ActivitySettings.ValueExpressionUniquenessKeyValidationError; return false; } if (i == count && !containsKey) { this.controller.ValidationError = ActivitySettings.ValueExpressionMissingUniquenessKeyValidationError; return false; } i += 1; } try { if (!string.IsNullOrEmpty(this.activityExecutionCondition.Value)) { evaluator.ParseExpression(this.activityExecutionCondition.Value); // Verify that the activity execution condition resolves to a Boolean value if (!evaluator.IsBooleanExpression(this.activityExecutionCondition.Value)) { this.controller.ValidationError = ActivitySettings.ActivityExecutionConditionValidationError; return false; } } } catch (WorkflowActivityLibraryException ex) { this.controller.ValidationError = ex.Message; return false; } // If no errors were found, clear any validation error and return true this.controller.ValidationError = string.Empty; return true; } catch (Exception e) { Logger.Instance.ReportError(e); throw; } finally { Logger.Instance.WriteMethodExit(); } }
/// <summary> /// Validates the inputs. Returns true if all of the UI controls contain valid values. Otherwise, returns false. /// </summary> /// <returns>true if all of the UI controls contain valid values. Otherwise, false.</returns> public override bool ValidateInputs() { Logger.Instance.WriteMethodEntry(); try { // Use the controller to validate standard activity controls // and return false if a problem was identified if (!this.controller.ValidateInputs()) { return false; } // If standard activity controls are valid, // loop through all active definition listings and make sure they are valid ExpressionEvaluator evaluator = new ExpressionEvaluator(); foreach (DefinitionListing condition in this.conditions.DefinitionListings.Where(condition => condition.Active)) { if (condition.Definition == null) { // If a value is missing for the left or right listing fields, the definition // will be null and the listing fails validation // Because the activity allows for verification of uniqueness only without additional conditions, // we need to check if this is the only active listing for the form and, if so, // verify that all fields have been left blank before failing validation int countActive = this.conditions.DefinitionListings.Count(l => l.Active); if (countActive != 1 || !string.IsNullOrEmpty(condition.State.Left) || !string.IsNullOrEmpty(condition.State.Right)) { this.controller.ValidationError = ActivitySettings.ConditionDefinitionValidationError; return false; } } else { // Attempt to parse the condition and fail validation // if an exception is thrown by the expression evaluator try { evaluator.ParseExpression(condition.Definition.Left); } catch (WorkflowActivityLibraryException ex) { this.controller.ValidationError = ex.Message; return false; } // Verify that the condition resolves to a Boolean value bool parseBoolean; if (!evaluator.IsBooleanExpression(condition.Definition.Left) && !bool.TryParse(condition.Definition.Left, out parseBoolean)) { this.controller.ValidationError = ActivitySettings.ConditionEvaluationValidationError; return false; } } } try { if (this.advanced.Value) { if (!string.IsNullOrEmpty(this.activityExecutionCondition.Value)) { evaluator.ParseExpression(this.activityExecutionCondition.Value); // Verify that the activity execution condition resolves to a Boolean value if (!evaluator.IsBooleanExpression(this.activityExecutionCondition.Value)) { this.controller.ValidationError = ActivitySettings.ActivityExecutionConditionValidationError; return false; } } } } catch (WorkflowActivityLibraryException ex) { this.controller.ValidationError = ex.Message; return false; } // If no errors were found, clear any validation error and return true this.controller.ValidationError = string.Empty; return true; } catch (Exception e) { Logger.Instance.ReportError(e); throw; } finally { Logger.Instance.WriteMethodExit(); } }
/// <summary> /// Parses email template /// </summary> /// <param name="template">The XPath search filter or lookup expression for the email template</param> private static void ParseEmailTemplate(string template) { Logger.Instance.WriteMethodEntry(); ExpressionEvaluator evaluator = new ExpressionEvaluator(); try { if (ExpressionEvaluator.IsExpression(template)) { // Try to parse it as an expression evaluator.ParseExpression(template); } else if (ExpressionEvaluator.IsXPath(template)) { // nothing to check } else if (!string.IsNullOrEmpty(template)) { // must be a Guid try { Guid g = new Guid(template); } catch (Exception) { throw new WorkflowActivityLibraryException(ActivitySettings.RequestApprovalEmailTemplateValidationError); } } } finally { Logger.Instance.WriteMethodExit(); } }
/// <summary> /// Initializes a new instance of the <see cref="RunPowerShellScript"/> class. /// </summary> public RunPowerShellScript() { Logger.Instance.WriteMethodEntry(EventIdentifier.RunPowerShellScriptConstructor); try { this.InitializeComponent(); if (this.ActivityExpressionEvaluator == null) { this.ActivityExpressionEvaluator = new ExpressionEvaluator(); } } finally { Logger.Instance.WriteMethodExit(EventIdentifier.RunPowerShellScriptConstructor); } }
/// <summary> /// Validates the inputs. Returns true if all of the UI controls contain valid values. Otherwise, returns false. /// </summary> /// <returns>true if all of the UI controls contain valid values. Otherwise, false.</returns> public override bool ValidateInputs() { Logger.Instance.WriteMethodEntry(); try { // Use the controller to validate standard activity controls // and return false if a problem was identified if (!this.controller.ValidateInputs()) { return false; } ExpressionEvaluator evaluator = new ExpressionEvaluator(); if (this.advanced.Value) { if (this.queryResources.Value) { // Loop through all active query listings and make sure they are valid foreach (DefinitionListing query in this.queries.DefinitionListings.Where(query => query.Active)) { // If a value is missing for key or query, the definition // will be null and the listing fails validation if (query.Definition == null) { this.controller.ValidationError = ActivitySettings.QueryDefinitionValidationError; return false; } // Make sure that the specified query key is properly formatted if (!Regex.Match(query.Definition.Left, RegexPattern).Success) { this.controller.ValidationError = string.Format(CultureInfo.CurrentUICulture, ActivitySettings.QueryDefintionLeftValidationError, query.Definition.Left); return false; } // Make sure that the specified XPath filter is properly formatted if (!ExpressionEvaluator.IsXPath(query.Definition.Right)) { this.controller.ValidationError = string.Format(CultureInfo.CurrentUICulture, ActivitySettings.QueryDefintionRightValidationError, query.Definition.Left); return false; } } } try { if (!string.IsNullOrEmpty(this.activityExecutionCondition.Value)) { evaluator.ParseExpression(this.activityExecutionCondition.Value); // Verify that the activity execution condition resolves to a Boolean value if (!evaluator.IsBooleanExpression(this.activityExecutionCondition.Value)) { this.controller.ValidationError = ActivitySettings.ActivityExecutionConditionValidationError; return false; } } if (!string.IsNullOrEmpty(this.iteration.Value)) { evaluator.ParseExpression(this.iteration.Value); } if (GetActorType(this.actorType.Value) == ActorType.Resolve) { evaluator.ParseExpression(this.actorString.Value); } } catch (WorkflowActivityLibraryException ex) { this.controller.ValidationError = ex.Message; return false; } if (this.applyAuthorizationPolicy.Value && GetActorType(this.actorType.Value) == ActorType.Service) { this.controller.ValidationError = ActivitySettings.RequestActorValidationError; return false; } } // Loop through all active update listings and make sure they are valid foreach (DefinitionListing update in this.updates.DefinitionListings.Where(update => update.Active)) { if (update.Definition == null) { // If a value is missing for source or target, the definition // will be null and the listing fails validation this.controller.ValidationError = ActivitySettings.UpdateDefinitionValidationError; return false; } // Attempt to parse the source expression and target lookup or variable // Fail validation if an exception is thrown for either try { evaluator.ParseExpression(update.Definition.Left); ParameterType targetType = ParameterType.Lookup; try { targetType = ExpressionEvaluator.DetermineParameterType(update.Definition.Right); } catch (WorkflowActivityLibraryException) { } // Target variables are valid // Target lookups require further evaluation to determine if they represent a valid target if (targetType != ParameterType.Variable) { LookupEvaluator lookup = new LookupEvaluator(update.Definition.Right); if (!lookup.IsValidTarget) { this.controller.ValidationError = string.Format(CultureInfo.CurrentUICulture, ActivitySettings.TargetLookupValidationError, update.Definition.Right); return false; } } } catch (WorkflowActivityLibraryException ex) { this.controller.ValidationError = ex.Message; return false; } } // Verify that no [//Query/...] or [//Value/...] expressions exist // if the query resources or iteration options are not enabled, respectively bool containsQueryExpressions = false; bool containsValueExpressions = false; foreach (LookupEvaluator lookup in evaluator.LookupCache.Keys.Select(key => new LookupEvaluator(key))) { if (lookup.Parameter == LookupParameter.Queries) { containsQueryExpressions = true; } if (lookup.Parameter == LookupParameter.Value) { containsValueExpressions = true; } } if (!this.queryResources.Value && containsQueryExpressions) { this.controller.ValidationError = ActivitySettings.QueryResourcesValidationError; return false; } if (string.IsNullOrEmpty(this.iteration.Value) && containsValueExpressions) { this.controller.ValidationError = ActivitySettings.IterationValidationError; return false; } // If no errors were found, clear any validation error and return true this.controller.ValidationError = string.Empty; return true; } catch (Exception e) { Logger.Instance.ReportError(e); throw; } finally { Logger.Instance.WriteMethodExit(); } }
/// <summary> /// Validates the inputs. Returns true if all of the UI controls contain valid values. Otherwise, returns false. /// </summary> /// <returns>true if all of the UI controls contain valid values. Otherwise, false.</returns> public override bool ValidateInputs() { Logger.Instance.WriteMethodEntry(); try { // Use the controller to validate standard activity controls // and return false if a problem was identified if (!this.controller.ValidateInputs()) { return false; } ExpressionEvaluator evaluator = new ExpressionEvaluator(); // Verify that the resource type is valid if (!Regex.Match(this.resourceType.Value, RegexPattern).Success) { this.controller.ValidationError = string.Format(CultureInfo.CurrentUICulture, ActivitySettings.ResourceTypeValidationError, this.resourceType.Value); return false; } if (this.advanced.Value) { if (this.queryResources.Value) { // Loop through all active query listings and make sure they are valid foreach (DefinitionListing query in this.queries.DefinitionListings) { if (query.Active) { // If a value is missing for key or query, the definition // will be null and the listing fails validation if (query.Definition == null) { this.controller.ValidationError = ActivitySettings.QueryDefinitionValidationError; return false; } // Make sure that the specified query key is properly formatted if (!Regex.Match(query.Definition.Left, RegexPattern).Success) { this.controller.ValidationError = string.Format(CultureInfo.CurrentUICulture, ActivitySettings.QueryDefintionLeftValidationError, query.Definition.Left); return false; } // Make sure that the specified XPath filter is properly formatted if (!ExpressionEvaluator.IsXPath(query.Definition.Right)) { this.controller.ValidationError = string.Format(CultureInfo.CurrentUICulture, ActivitySettings.QueryDefintionRightValidationError, query.Definition.Left); return false; } } } } try { if (!string.IsNullOrEmpty(this.activityExecutionCondition.Value)) { evaluator.ParseExpression(this.activityExecutionCondition.Value); // Verify that the activity execution condition resolves to a Boolean value if (!evaluator.IsBooleanExpression(this.activityExecutionCondition.Value)) { this.controller.ValidationError = ActivitySettings.ActivityExecutionConditionValidationError; return false; } } if (!string.IsNullOrEmpty(this.iteration.Value)) { evaluator.ParseExpression(this.iteration.Value); } if (GetActorType(this.actorType.Value) == ActorType.Resolve) { evaluator.ParseExpression(this.actorString.Value); } // Verify that the supplied conflict filter is a valid XPath query, if necessary if (this.checkForConflict.Value && !ExpressionEvaluator.IsXPath(this.conflictFilter.Value)) { this.controller.ValidationError = ActivitySettings.ConflictResourceSearchFilterValidationError; return false; } // If necessary, parse the created resource ID target lookup to ensure its validity if (!string.IsNullOrEmpty(this.createdResourceIdTarget.Value)) { LookupEvaluator createdTargetLookup = new LookupEvaluator(this.createdResourceIdTarget.Value); if (!createdTargetLookup.IsValidTarget) { this.controller.ValidationError = string.Format(CultureInfo.CurrentUICulture, ActivitySettings.TargetLookupValidationError, this.createdResourceIdTarget.Value); return false; } } // If necessary, parse the conflicting resource ID target lookup to ensure its validity if (this.checkForConflict.Value && !string.IsNullOrEmpty(this.conflictingResourceIdTarget.Value)) { LookupEvaluator conflictingTargetLookup = new LookupEvaluator(this.conflictingResourceIdTarget.Value); if (!conflictingTargetLookup.IsValidTarget) { this.controller.ValidationError = string.Format(CultureInfo.CurrentUICulture, ActivitySettings.TargetLookupValidationError, this.conflictingResourceIdTarget.Value); return false; } } } catch (WorkflowActivityLibraryException ex) { // If an exception was thrown while attempting to parse lookups, report the error this.controller.ValidationError = ex.Message; return false; } if (this.applyAuthorizationPolicy.Value && GetActorType(this.actorType.Value) == ActorType.Service) { this.controller.ValidationError = ActivitySettings.RequestActorValidationError; return false; } } // Loop through all active definition listings and make sure they are valid foreach (DefinitionListing listing in this.attributes.DefinitionListings) { if (!listing.Active) { continue; } if (listing.Definition == null) { // If a value is missing for source or target, the definition // will be null and the listing fails validation // Because the activity allows for the creation of a resource without any attributes, // we need to check if this is the only active listing for the form and, if so, // verify that all fields have been left blank before failing validation int countActive = this.attributes.DefinitionListings.Count(l => l.Active); if (countActive != 1 || !string.IsNullOrEmpty(listing.State.Left) || !string.IsNullOrEmpty(listing.State.Right)) { this.controller.ValidationError = ActivitySettings.AttributeDefinitionValidationError; return false; } } else { // Attempt to parse the source expression and fail validation // if an exception is thrown by the expression evaluator try { evaluator.ParseExpression(listing.Definition.Left); } catch (WorkflowActivityLibraryException ex) { this.controller.ValidationError = ex.Message; return false; } ParameterType targetType = ParameterType.String; try { targetType = ExpressionEvaluator.DetermineParameterType(listing.Definition.Right, true); } catch (WorkflowActivityLibraryException) { } // Target variables are valid // For anything else, make sure that the target attribute matches the regular // expression for FIM attributes if (targetType != ParameterType.Variable) { if (!Regex.Match(listing.Definition.Right, RegexPattern).Success) { this.controller.ValidationError = string.Format(CultureInfo.CurrentUICulture, ActivitySettings.TargetValidationError, listing.Definition.Right); return false; } } } } // Verify that no [//Query/...] or [//Value/...] expressions exist // if the query resources or iteration options are not enabled, respectively bool containsQueryExpressions = false; bool containsValueExpressions = false; foreach (LookupEvaluator lookup in evaluator.LookupCache.Keys.Select(key => new LookupEvaluator(key))) { if (lookup.Parameter == LookupParameter.Queries) { containsQueryExpressions = true; } if (lookup.Parameter == LookupParameter.Value) { containsValueExpressions = true; } } if (!this.queryResources.Value && containsQueryExpressions) { this.controller.ValidationError = ActivitySettings.QueryResourcesValidationError; return false; } if (string.IsNullOrEmpty(this.iteration.Value) && containsValueExpressions) { this.controller.ValidationError = ActivitySettings.IterationValidationError; return false; } // If no errors were found, clear any validation error and return true this.controller.ValidationError = string.Empty; return true; } catch (Exception e) { Logger.Instance.ReportError(e); throw; } finally { Logger.Instance.WriteMethodExit(); } }
/// <summary> /// Initializes a new instance of the <see cref="DeleteResources"/> class. /// </summary> public DeleteResources() { Logger.Instance.WriteMethodEntry(EventIdentifier.DeleteResourcesConstructor); try { this.InitializeComponent(); if (this.Targets == null) { this.Targets = new List<Guid>(); } if (this.ActivityExpressionEvaluator == null) { this.ActivityExpressionEvaluator = new ExpressionEvaluator(); } if (this.ValueExpressions == null) { this.ValueExpressions = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase); } } finally { Logger.Instance.WriteMethodExit(EventIdentifier.DeleteResourcesConstructor); } }
/// <summary> /// Initializes a new instance of the <see cref="GenerateUniqueValue"/> class. /// </summary> public GenerateUniqueValue() { Logger.Instance.WriteMethodEntry(EventIdentifier.GenerateUniqueValueConstructor); try { this.InitializeComponent(); if (this.ActivityExpressionEvaluator == null) { this.ActivityExpressionEvaluator = new ExpressionEvaluator(); } if (this.FoundIds == null) { this.FoundIds = new List<Guid>(); } if (this.FoundResources == null) { this.FoundResources = new List<ResourceType>(); } if (this.LdapQueries == null) { this.LdapQueries = new List<Definition>(); } if (!int.TryParse(ConfigurationManager.AppSettings["GenerateUniqueValueActivity_MaxLoopCount"], out this.maxLoopCount)) { this.maxLoopCount = 512; } } finally { Logger.Instance.WriteMethodExit(EventIdentifier.GenerateUniqueValueConstructor); } }
/// <summary> /// Validates the inputs. Returns true if all of the UI controls contain valid values. Otherwise, returns false. /// </summary> /// <returns>true if all of the UI controls contain valid values. Otherwise, false.</returns> public override bool ValidateInputs() { Logger.Instance.WriteMethodEntry(); try { // Use the controller to validate standard activity controls // and return false if a problem was identified if (!this.controller.ValidateInputs()) { return false; } if (string.IsNullOrEmpty(this.approvers.Value)) { this.controller.ValidationError = ActivitySettings.RequestApprovalApproversFieldValidationError; return false; } // If standard activity controls are valid, // validate any other advanced configurations ExpressionEvaluator evaluator = new ExpressionEvaluator(); try { if (!string.IsNullOrEmpty(this.activityExecutionCondition.Value)) { evaluator.ParseExpression(this.activityExecutionCondition.Value); // Verify that the activity execution condition resolves to a Boolean value if (!evaluator.IsBooleanExpression(this.activityExecutionCondition.Value)) { this.controller.ValidationError = ActivitySettings.ActivityExecutionConditionValidationError; return false; } } ParseApprovers(this.approvers.Value); if (ExpressionEvaluator.IsExpression(this.threshold.Value)) { evaluator.ParseExpression(this.threshold.Value); } else { int thresholdNumber; if (!int.TryParse(this.threshold.Value, out thresholdNumber)) { this.controller.ValidationError = ActivitySettings.RequestApprovalThresholdFieldValidationError; return false; } } if (ExpressionEvaluator.IsExpression(this.duration.Value)) { evaluator.ParseExpression(this.duration.Value); } else { TimeSpan parsedTimeSpan; if (!TimeSpan.TryParse(this.duration.Value, out parsedTimeSpan)) { this.controller.ValidationError = ActivitySettings.RequestApprovalDurationFieldValidationError; return false; } } ParseApprovers(this.escalation.Value); if (!string.IsNullOrEmpty(this.escalation.Value) && string.IsNullOrEmpty(this.approvalEscalationEmailTemplate.Value)) { this.controller.ValidationError = ActivitySettings.RequestApprovalEscalationEmailTemplateFieldValidationError; return false; } ParseEmailTemplate(this.approvalEmailTemplate.Value); ParseEmailTemplate(this.approvalEscalationEmailTemplate.Value); ParseEmailTemplate(this.approvalCompleteEmailTemplate.Value); ParseEmailTemplate(this.approvalDeniedEmailTemplate.Value); ParseEmailTemplate(this.approvalTimeoutEmailTemplate.Value); } catch (WorkflowActivityLibraryException ex) { this.controller.ValidationError = ex.Message; return false; } // If no errors were found, clear any validation error and return true this.controller.ValidationError = string.Empty; return true; } catch (Exception e) { Logger.Instance.ReportError(e); throw; } finally { Logger.Instance.WriteMethodExit(); } }
/// <summary> /// Initializes a new instance of the <see cref="FindRequestConflict"/> class. /// </summary> public FindRequestConflict() { Logger.Instance.WriteMethodEntry(EventIdentifier.FindRequestConflictConstructor); try { this.InitializeComponent(); this.ServiceActor = WellKnownGuids.FIMServiceAccount; if (this.ComparedRequestLookups == null) { this.ComparedRequestLookups = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase); } if (this.ExpressionEvaluator == null) { this.ExpressionEvaluator = new ExpressionEvaluator(); } } finally { Logger.Instance.WriteMethodExit(EventIdentifier.FindRequestConflictConstructor); } }
/// <summary> /// Parses Recipient /// </summary> /// <param name="recipient">The XPath search filter or lookup expression for recipient email address</param> private static void ParseApprovers(string recipient) { Logger.Instance.WriteMethodEntry(); ExpressionEvaluator evaluator = new ExpressionEvaluator(); try { if (ExpressionEvaluator.IsExpression(recipient)) { evaluator.ParseExpression(recipient); } else if (ExpressionEvaluator.IsXPath(recipient) || ExpressionEvaluator.IsEmailAddress(recipient)) { // nothing to check } else if (!string.IsNullOrEmpty(recipient)) { throw new WorkflowActivityLibraryException(ActivitySettings.RequestApprovalApproversFieldValidationError); } } finally { Logger.Instance.WriteMethodExit(); } }
/// <summary> /// Initializes a new instance of the <see cref="ResolveLookupString"/> class. /// </summary> public ResolveLookupString() { Logger.Instance.WriteMethodEntry(EventIdentifier.ResolveLookupStringConstructor); try { this.InitializeComponent(); if (this.ActivityExpressionEvaluator == null) { this.ActivityExpressionEvaluator = new ExpressionEvaluator(); } } finally { Logger.Instance.WriteMethodExit(EventIdentifier.ResolveLookupStringConstructor); } }
/// <summary> /// Validates the inputs. Returns true if all of the UI controls contain valid values. Otherwise, returns false. /// </summary> /// <returns>true if all of the UI controls contain valid values. Otherwise, false.</returns> public override bool ValidateInputs() { Logger.Instance.WriteMethodEntry(); try { // Use the controller to validate standard activity controls // and return false if a problem was identified if (!this.controller.ValidateInputs()) { return false; } // If standard activity controls are valid, // validate any other advanced configurations ExpressionEvaluator evaluator = new ExpressionEvaluator(); try { if (ExpressionEvaluator.IsExpression(this.timeoutDuration.Value)) { evaluator.ParseExpression(this.timeoutDuration.Value); } else { TimeSpan parsedTimeSpan; if (!TimeSpan.TryParse(this.timeoutDuration.Value, out parsedTimeSpan)) { this.controller.ValidationError = ActivitySettings.AddDelayTimeoutDurationHelpText; return false; } } } catch (WorkflowActivityLibraryException ex) { this.controller.ValidationError = ex.Message; return false; } try { if (!string.IsNullOrEmpty(this.activityExecutionCondition.Value)) { evaluator.ParseExpression(this.activityExecutionCondition.Value); // Verify that the activity execution condition resolves to a Boolean value if (!evaluator.IsBooleanExpression(this.activityExecutionCondition.Value)) { this.controller.ValidationError = ActivitySettings.ActivityExecutionConditionValidationError; return false; } } } catch (WorkflowActivityLibraryException ex) { this.controller.ValidationError = ex.Message; return false; } // If no errors were found, clear any validation error and return true this.controller.ValidationError = string.Empty; return true; } catch (Exception e) { Logger.Instance.ReportError(e); throw; } finally { Logger.Instance.WriteMethodExit(); } }
/// <summary> /// Validates the inputs. Returns true if all of the UI controls contain valid values. Otherwise, returns false. /// </summary> /// <returns>true if all of the UI controls contain valid values. Otherwise, false.</returns> public override bool ValidateInputs() { Logger.Instance.WriteMethodEntry(); try { // Use the controller to validate standard activity controls // and return false if a problem was identified if (!this.controller.ValidateInputs()) { return false; } if (string.IsNullOrEmpty(this.to.Value)) { this.controller.ValidationError = ActivitySettings.SendEmailNotificationRecipientFieldValidationError; return false; } // If standard activity controls are valid, // validate any other advanced configurations ExpressionEvaluator evaluator = new ExpressionEvaluator(); try { ParseEmailTemplate(this.emailTemplate.Value); if (this.advanced.Value) { if (!string.IsNullOrEmpty(this.activityExecutionCondition.Value)) { evaluator.ParseExpression(this.activityExecutionCondition.Value); // Verify that the activity execution condition resolves to a Boolean value if (!evaluator.IsBooleanExpression(this.activityExecutionCondition.Value)) { this.controller.ValidationError = ActivitySettings.ActivityExecutionConditionValidationError; return false; } } ParseRecipient(this.cc.Value); ParseRecipient(this.bcc.Value); } else { ParseRecipient(this.to.Value); } } catch (WorkflowActivityLibraryException ex) { this.controller.ValidationError = ex.Message; return false; } // If no errors were found, clear any validation error and return true this.controller.ValidationError = string.Empty; return true; } catch (Exception e) { Logger.Instance.ReportError(e); throw; } finally { Logger.Instance.WriteMethodExit(); } }