Skip to content

Commit

Permalink
Merge pull request #3 from microsoft/master
Browse files Browse the repository at this point in the history
Merging with Microsoft/MIMWAL
  • Loading branch information
NileshGhodekar authored Nov 25, 2019
2 parents bf55958 + 4998e11 commit b170d76
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Scripts/EncryptData.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
NOTE: Edit the Version and PublicKeyToken of the WAL AssemblyName to match the one that you have deployed in GAC.
Also edit the $encryptionCertThumbprint of cert to be used for certificate based encryption.
Finding Assembly verion and PublicKeyToken
gacutil.exe -l | findstr WorkflowActivityLibrary
Creatinig a self signed certificate for MIMWAL (You can use a legacy CSP such as Microsoft Strong Cryptographic Provider as shown in the example below)
$cert = New-SelfSignedCertificate -DnsName "MIMWAL" -CertStoreLocation "cert:\LocalMachine\My" -Provider "Microsoft Strong Cryptographic Provider"
$cert.Thumbprint
As of version v2.18.1110.0, only FIMService account needs read access to the private key of the MIMWAL certificate created above.
#>

$Error.Clear()
Expand Down
25 changes: 25 additions & 0 deletions src/WorkflowActivityLibrary/Common/EventIdentifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1288,6 +1288,16 @@ public static class EventIdentifier
/// </summary>
public const int ExpressionFunctionMod = 11686;

/// <summary>
/// The event identifier for ExpressionFunction IndexByValue events
/// </summary>
public const int ExpressionFunctionIndexByValue = 11687;

/// <summary>
/// The event identifier for ExpressionFunction CR events
/// </summary>
public const int ExpressionFunctionCr = 11688;

/// <summary>
/// The event identifier for LookupEvaluator Constructor events
/// </summary>
Expand Down Expand Up @@ -2748,6 +2758,11 @@ public static class EventIdentifier
/// </summary>
public const int ExpressionFunctionCrlfInvalidFunctionParameterCountError = 41658;

/// <summary>
/// The event identifier for ExpressionFunction CR events
/// </summary>
public const int ExpressionFunctionCrInvalidFunctionParameterCountError = 41658;

/// <summary>
/// The event identifier for ExpressionFunction EscapeDNComponent events
/// </summary>
Expand Down Expand Up @@ -3178,6 +3193,16 @@ public static class EventIdentifier
/// </summary>
public const int ExpressionFunctionModInvalidSecondFunctionParameterTypeError = 41686;

/// <summary>
/// The event identifier for ExpressionFunction ValueByIndex events
/// </summary>
public const int ExpressionFunctionIndexByValueInvalidFunctionParameterCountError = 41687;

/// <summary>
/// The event identifier for ExpressionFunction IndexByValue events
/// </summary>
public const int ExpressionFunctionIndexByValueNullFunctionParameterError = 41645;

/// <summary>
/// The event identifier for LookupEvaluator Constructor events
/// </summary>
Expand Down
106 changes: 106 additions & 0 deletions src/WorkflowActivityLibrary/Common/ExpressionFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ public object Run()
case "CREATESQLPARAMETER2":
return this.CreateSqlParameter2();

case "CR":
return this.CR();

case "CRLF":
return this.CRLF();

Expand Down Expand Up @@ -222,6 +225,9 @@ public object Run()
case "IIF":
return this.IIF();

case "INDEXBYVALUE":
return this.IndexByValue();

case "INSERTVALUES":
return this.InsertValues();

Expand Down Expand Up @@ -2691,6 +2697,70 @@ private object IIF()
}
}

/// <summary>
/// This function is used to retrieve the index for a specific value within the input list.
/// Function Syntax: IndexByValue(values:[list or object], value:object)
/// </summary>
/// <returns>The index of the specified value in the input list. If the value is not found in the list, null is returned.</returns>
private object IndexByValue()
{
Logger.Instance.WriteMethodEntry(EventIdentifier.ExpressionFunctionIndexByValue, "Evaluation Mode: '{0}'.", this.mode);

try
{
if (this.parameters.Count != 2)
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionIndexByValueInvalidFunctionParameterCountError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidFunctionParameterCountError, this.function, 2, this.parameters.Count));
}

// default value if no results are found
int result = -1;

if (this.mode != EvaluationMode.Parse)
{
if (this.parameters[0] != null && this.parameters[1] != null)
{
Type paramType = this.parameters[0].GetType();
if (paramType.IsGenericType && paramType.GetGenericTypeDefinition() == typeof(List<>))
{
Logger.Instance.WriteVerbose(EventIdentifier.ExpressionFunctionIndexByValue, "IndexByValue('{0}', '{1}') First parameter is a list. Enumerating list items.", this.parameters[0], this.parameters[1]);

int index = 0;
foreach (object item in (IEnumerable)this.parameters[0])
{
if (item is string && this.parameters[1] is string)
{
if (item.ToString().Equals(this.parameters[1].ToString(), StringComparison.InvariantCultureIgnoreCase))
{
Logger.Instance.WriteVerbose(EventIdentifier.ExpressionFunctionIndexByValue, "IndexByValue('{0}', '{1}') Matched string item '{2}' to second param '{3}'. Result: {4}.", this.parameters[0], this.parameters[1], item.ToString(), this.parameters[1].ToString(), index);
result = index;
break;
}
}
else if (item.Equals(this.parameters[1]))
{
Logger.Instance.WriteVerbose(EventIdentifier.ExpressionFunctionIndexByValue, "IndexByValue('{0}', '{1}') Matched object item '{2}' to second param '{3}'. Result: {4}.", this.parameters[0], this.parameters[1], item.ToString(), this.parameters[1].ToString(), index);
result = index;
break;
}

index += 1;
}
}

}

Logger.Instance.WriteVerbose(EventIdentifier.ExpressionFunctionIndexByValue, "IndexByValue('{0}', '{1}') returned '{2}'.", this.parameters[0], this.parameters[1], result);
}

return result;
}
finally
{
Logger.Instance.WriteMethodExit(EventIdentifier.ExpressionFunctionIndexByValue, "Evaluation Mode: '{0}'.", this.mode);
}
}

/// <summary>
/// This function is used to create a new InsertedValues collection which contains all values from the specified list.
/// This InsertedValues collection will be used by the activity so that it can generate update request parameters accordingly.
Expand Down Expand Up @@ -4830,6 +4900,42 @@ private string ConvertToString()
}
}

/// <summary>
/// This function is used to generate a Carriage Return.
/// Function Syntax: CR()
/// </summary>
/// <returns>A CR is the output.</returns>
private string CR()
{
Logger.Instance.WriteMethodEntry(EventIdentifier.ExpressionFunctionCr, "Evaluation Mode: '{0}'.", this.mode);

try
{
if (this.parameters.Count != 0)
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionCrInvalidFunctionParameterCountError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidFunctionParameterCountError, this.function, 0, this.parameters.Count));
}

string result;

if (this.mode != EvaluationMode.Parse)
{
result = "\n";
Logger.Instance.WriteVerbose(EventIdentifier.ExpressionFunctionCr, "CR() returned '{0}'.", result);
}
else
{
result = null;
}

return result;
}
finally
{
Logger.Instance.WriteMethodExit(EventIdentifier.ExpressionFunctionCr, "Evaluation Mode: '{0}'.", this.mode);
}
}

/// <summary>
/// This function is used to generate a Carriage Return/Line Feed.
/// Function Syntax: CRLF()
Expand Down

0 comments on commit b170d76

Please sign in to comment.