Adjusting to use Tracer for logging
parent
dbb7e00e09
commit
a9f3e46bfc
|
@ -1,326 +1,331 @@
|
||||||
// January 15, 2013 | Soren Granfeldt
|
// january 15, 2013 | Soren Granfeldt
|
||||||
// - initial version
|
// - initial version
|
||||||
// January 17, 2013 | Soren Granfeldt
|
// january 17, 2013 | Soren Granfeldt
|
||||||
// - changed activity name from CodeActivity to CodeRunActivity
|
// - changed activity name from CodeActivity to CodeRunActivity
|
||||||
// due to clashes with built-in naming convention
|
// due to clashes with built-in naming convention
|
||||||
// January 18, 2013 | Soren Granfeldt
|
// january 18, 2013 | Soren Granfeldt
|
||||||
// - changed update to use helper update activity
|
// - changed update to use helper update activity
|
||||||
// December 16, 2015 | soren granfeldt
|
// december 16, 2015 | soren granfeldt
|
||||||
// - changed logging to tuse tracer
|
// - changed logging to use tracer
|
||||||
|
// february 16, 2015 | soren granfeldt
|
||||||
|
// - added additional logging information
|
||||||
|
|
||||||
|
using Microsoft.ResourceManagement.WebServices.WSResourceManagement;
|
||||||
|
using Microsoft.ResourceManagement.Workflow.Activities;
|
||||||
using System;
|
using System;
|
||||||
using System.CodeDom.Compiler;
|
using System.CodeDom.Compiler;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.ComponentModel.Design;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
using System.Workflow.Activities;
|
using System.Workflow.Activities;
|
||||||
using System.Workflow.Activities.Rules;
|
|
||||||
using System.Workflow.ComponentModel;
|
using System.Workflow.ComponentModel;
|
||||||
using System.Workflow.ComponentModel.Compiler;
|
|
||||||
using System.Workflow.ComponentModel.Design;
|
|
||||||
using System.Workflow.ComponentModel.Serialization;
|
|
||||||
using System.Workflow.Runtime;
|
|
||||||
using Microsoft.ResourceManagement.WebServices.WSResourceManagement;
|
|
||||||
using Microsoft.ResourceManagement.Workflow.Activities;
|
|
||||||
|
|
||||||
namespace Granfeldt.FIM.ActivityLibrary
|
namespace Granfeldt.FIM.ActivityLibrary
|
||||||
{
|
{
|
||||||
public partial class CodeRunActivity : SequenceActivity
|
public partial class CodeRunActivity : SequenceActivity
|
||||||
{
|
{
|
||||||
|
|
||||||
#region Properties
|
#region Properties
|
||||||
|
|
||||||
public static DependencyProperty TargetResourceProperty = DependencyProperty.Register("TargetResource", typeof(Microsoft.ResourceManagement.WebServices.WSResourceManagement.ResourceType), typeof(Granfeldt.FIM.ActivityLibrary.CodeRunActivity));
|
public static DependencyProperty TargetResourceProperty = DependencyProperty.Register("TargetResource", typeof(Microsoft.ResourceManagement.WebServices.WSResourceManagement.ResourceType), typeof(Granfeldt.FIM.ActivityLibrary.CodeRunActivity));
|
||||||
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
|
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
|
||||||
[BrowsableAttribute(true)]
|
[BrowsableAttribute(true)]
|
||||||
[CategoryAttribute("Parameters")]
|
[CategoryAttribute("Parameters")]
|
||||||
public Microsoft.ResourceManagement.WebServices.WSResourceManagement.ResourceType TargetResource
|
public Microsoft.ResourceManagement.WebServices.WSResourceManagement.ResourceType TargetResource
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return ((ResourceType)(base.GetValue(Granfeldt.FIM.ActivityLibrary.CodeRunActivity.TargetResourceProperty)));
|
return ((ResourceType)(base.GetValue(Granfeldt.FIM.ActivityLibrary.CodeRunActivity.TargetResourceProperty)));
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
base.SetValue(Granfeldt.FIM.ActivityLibrary.CodeRunActivity.TargetResourceProperty, value);
|
base.SetValue(Granfeldt.FIM.ActivityLibrary.CodeRunActivity.TargetResourceProperty, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The title of the current instance of the workflow
|
||||||
|
/// </summary>
|
||||||
|
public static DependencyProperty TitleProperty = DependencyProperty.Register("Title", typeof(string), typeof(CodeRunActivity));
|
||||||
|
[Description("Title")]
|
||||||
|
[Category("Title Category")]
|
||||||
|
[Browsable(true)]
|
||||||
|
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
|
||||||
|
public string Title
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return ((string)(base.GetValue(CodeRunActivity.TitleProperty)));
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
base.SetValue(CodeRunActivity.TitleProperty, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
public static DependencyProperty ReferencesProperty = DependencyProperty.Register("References", typeof(string[]), typeof(CodeRunActivity));
|
||||||
/// The title of the current instance of the workflow
|
[Description("References")]
|
||||||
/// </summary>
|
[Category("References Category")]
|
||||||
public static DependencyProperty TitleProperty = DependencyProperty.Register("Title", typeof(string), typeof(CodeRunActivity));
|
[Browsable(true)]
|
||||||
[Description("Title")]
|
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
|
||||||
[Category("Title Category")]
|
public string[] References
|
||||||
[Browsable(true)]
|
{
|
||||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
|
get
|
||||||
public string Title
|
{
|
||||||
{
|
return ((string[])(base.GetValue(CodeRunActivity.ReferencesProperty)));
|
||||||
get
|
}
|
||||||
{
|
set
|
||||||
return ((string)(base.GetValue(CodeRunActivity.TitleProperty)));
|
{
|
||||||
}
|
base.SetValue(CodeRunActivity.ReferencesProperty, value);
|
||||||
set
|
}
|
||||||
{
|
}
|
||||||
base.SetValue(CodeRunActivity.TitleProperty, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static DependencyProperty ReferencesProperty = DependencyProperty.Register("References", typeof(string[]), typeof(CodeRunActivity));
|
public static DependencyProperty ParametersProperty = DependencyProperty.Register("Parameters", typeof(string[]), typeof(CodeRunActivity));
|
||||||
[Description("References")]
|
[Description("Parameters")]
|
||||||
[Category("References Category")]
|
[Category("Parameters Category")]
|
||||||
[Browsable(true)]
|
[Browsable(true)]
|
||||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
|
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
|
||||||
public string[] References
|
public string[] Parameters
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return ((string[])(base.GetValue(CodeRunActivity.ReferencesProperty)));
|
return ((string[])(base.GetValue(CodeRunActivity.ParametersProperty)));
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
base.SetValue(CodeRunActivity.ReferencesProperty, value);
|
base.SetValue(CodeRunActivity.ParametersProperty, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DependencyProperty ParametersProperty = DependencyProperty.Register("Parameters", typeof(string[]), typeof(CodeRunActivity));
|
public static DependencyProperty ResolvedParameterExpressionProperty = DependencyProperty.Register("ResolvedParameterExpression", typeof(System.String), typeof(Granfeldt.FIM.ActivityLibrary.CodeRunActivity));
|
||||||
[Description("Parameters")]
|
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
|
||||||
[Category("Parameters Category")]
|
[BrowsableAttribute(true)]
|
||||||
[Browsable(true)]
|
[CategoryAttribute("Misc")]
|
||||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
|
public String ResolvedParameterExpression
|
||||||
public string[] Parameters
|
{
|
||||||
{
|
get
|
||||||
get
|
{
|
||||||
{
|
return ((string)(base.GetValue(Granfeldt.FIM.ActivityLibrary.CodeRunActivity.ResolvedParameterExpressionProperty)));
|
||||||
return ((string[])(base.GetValue(CodeRunActivity.ParametersProperty)));
|
}
|
||||||
}
|
set
|
||||||
set
|
{
|
||||||
{
|
base.SetValue(Granfeldt.FIM.ActivityLibrary.CodeRunActivity.ResolvedParameterExpressionProperty, value);
|
||||||
base.SetValue(CodeRunActivity.ParametersProperty, value);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static DependencyProperty ResolvedParameterExpressionProperty = DependencyProperty.Register("ResolvedParameterExpression", typeof(System.String), typeof(Granfeldt.FIM.ActivityLibrary.CodeRunActivity));
|
public static DependencyProperty CodeProperty = DependencyProperty.Register("Code", typeof(string), typeof(CodeRunActivity));
|
||||||
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
|
[Description("Code")]
|
||||||
[BrowsableAttribute(true)]
|
[Category("Code Category")]
|
||||||
[CategoryAttribute("Misc")]
|
[Browsable(true)]
|
||||||
public String ResolvedParameterExpression
|
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
|
||||||
{
|
public string Code
|
||||||
get
|
{
|
||||||
{
|
get
|
||||||
return ((string)(base.GetValue(Granfeldt.FIM.ActivityLibrary.CodeRunActivity.ResolvedParameterExpressionProperty)));
|
{
|
||||||
}
|
return ((string)(base.GetValue(CodeRunActivity.CodeProperty)));
|
||||||
set
|
}
|
||||||
{
|
set
|
||||||
base.SetValue(Granfeldt.FIM.ActivityLibrary.CodeRunActivity.ResolvedParameterExpressionProperty, value);
|
{
|
||||||
}
|
base.SetValue(CodeRunActivity.CodeProperty, value);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static DependencyProperty CodeProperty = DependencyProperty.Register("Code", typeof(string), typeof(CodeRunActivity));
|
public static DependencyProperty DestinationProperty = DependencyProperty.Register("Destination", typeof(string), typeof(CodeRunActivity));
|
||||||
[Description("Code")]
|
[Description("Destination")]
|
||||||
[Category("Code Category")]
|
[Category("Destination Category")]
|
||||||
[Browsable(true)]
|
[Browsable(true)]
|
||||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
|
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
|
||||||
public string Code
|
public string Destination
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return ((string)(base.GetValue(CodeRunActivity.CodeProperty)));
|
return ((string)(base.GetValue(CodeRunActivity.DestinationProperty)));
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
base.SetValue(CodeRunActivity.CodeProperty, value);
|
base.SetValue(CodeRunActivity.DestinationProperty, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DependencyProperty DestinationProperty = DependencyProperty.Register("Destination", typeof(string), typeof(CodeRunActivity));
|
#endregion
|
||||||
[Description("Destination")]
|
|
||||||
[Category("Destination Category")]
|
|
||||||
[Browsable(true)]
|
|
||||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
|
|
||||||
public string Destination
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return ((string)(base.GetValue(CodeRunActivity.DestinationProperty)));
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
base.SetValue(CodeRunActivity.DestinationProperty, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
/// <summary>
|
||||||
|
/// Contains in-memory compiled code
|
||||||
|
/// </summary>
|
||||||
|
private static object compiled = null;
|
||||||
|
/// <summary>
|
||||||
|
/// List of unresolved parameters
|
||||||
|
/// </summary>
|
||||||
|
List<string> UnresolvedParameters = null;
|
||||||
|
/// <summary>
|
||||||
|
/// List of resolved parameters. These are passed to the default code method
|
||||||
|
/// </summary>
|
||||||
|
List<object> ResolvedParameters = new List<object>();
|
||||||
|
/// <summary>
|
||||||
|
/// Reference to parent workflow
|
||||||
|
/// </summary>
|
||||||
|
SequentialWorkflow containingWorkflow = null;
|
||||||
|
string destinationObject = null;
|
||||||
|
string destinationAttribute = null;
|
||||||
|
|
||||||
/// <summary>
|
public CodeRunActivity()
|
||||||
/// Contains in-memory compiled code
|
{
|
||||||
/// </summary>
|
Tracer.IndentLevel = 0;
|
||||||
private static object compiled = null;
|
InitializeComponent();
|
||||||
/// <summary>
|
}
|
||||||
/// List of unresolved parameters
|
|
||||||
/// </summary>
|
|
||||||
List<string> UnresolvedParameters = null;
|
|
||||||
/// <summary>
|
|
||||||
/// List of resolved parameters. These are passed to the default code method
|
|
||||||
/// </summary>
|
|
||||||
List<object> ResolvedParameters = new List<object>();
|
|
||||||
/// <summary>
|
|
||||||
/// Reference to parent workflow
|
|
||||||
/// </summary>
|
|
||||||
SequentialWorkflow containingWorkflow = null;
|
|
||||||
string destinationObject = null;
|
|
||||||
string destinationAttribute = null;
|
|
||||||
|
|
||||||
public CodeRunActivity()
|
/// <summary>
|
||||||
{
|
/// Has returned value from code function
|
||||||
InitializeComponent();
|
/// </summary>
|
||||||
}
|
object codeReturnValue = null;
|
||||||
|
|
||||||
/// <summary>
|
private void MoreParametersToResolve_Condition(object sender, ConditionalEventArgs e)
|
||||||
/// Has returned value from code function
|
{
|
||||||
/// </summary>
|
Tracer.Enter("moreparameterstoresolve_condition");
|
||||||
object codeReturnValue = null;
|
// we need to convert the string array to a list to
|
||||||
|
// be able to remove values
|
||||||
|
if (UnresolvedParameters == null)
|
||||||
|
{
|
||||||
|
UnresolvedParameters = this.Parameters.ToList();
|
||||||
|
Tracer.TraceInformation("resolving-parameters");
|
||||||
|
}
|
||||||
|
e.Result = false;
|
||||||
|
if (UnresolvedParameters.Count > 0)
|
||||||
|
{
|
||||||
|
this.ResolveParameterValue.GrammarExpression = UnresolvedParameters[0];
|
||||||
|
Tracer.TraceInformation("resolving {0}", UnresolvedParameters[0]);
|
||||||
|
UnresolvedParameters.RemoveAt(0);
|
||||||
|
e.Result = true;
|
||||||
|
}
|
||||||
|
Tracer.Exit("moreparameterstoresolve_condition");
|
||||||
|
}
|
||||||
|
|
||||||
private void MoreParametersToResolve_Condition(object sender, ConditionalEventArgs e)
|
private void SaveResolvedValue_ExecuteCode(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Tracer.Enter("Activity initialized");
|
string result = HttpUtility.HtmlDecode(this.ResolveParameterValue.ResolvedExpression);
|
||||||
// we need to convert the string array to a list to
|
ResolvedParameters.Add(result);
|
||||||
// be able to remove values
|
Tracer.TraceInformation("resolved-to {0}", result);
|
||||||
if (UnresolvedParameters == null)
|
}
|
||||||
{
|
|
||||||
UnresolvedParameters = this.Parameters.ToList();
|
|
||||||
Tracer.TraceInformation("Resolving parameters");
|
|
||||||
}
|
|
||||||
e.Result = false;
|
|
||||||
if (UnresolvedParameters.Count > 0)
|
|
||||||
{
|
|
||||||
this.ResolveParameterValue.GrammarExpression = UnresolvedParameters[0];
|
|
||||||
Tracer.TraceInformation("Resolving {0}", UnresolvedParameters[0]);
|
|
||||||
UnresolvedParameters.RemoveAt(0);
|
|
||||||
e.Result = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SaveResolvedValue_ExecuteCode(object sender, EventArgs e)
|
private void NonExistingGrammarException_ExecuteCode(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
ResolvedParameters.Add(HttpUtility.HtmlDecode(this.ResolveParameterValue.ResolvedExpression));
|
|
||||||
Tracer.TraceInformation("Resolved to {0}", HttpUtility.HtmlDecode(this.ResolveParameterValue.ResolvedExpression));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void NonExistingGrammarException_ExecuteCode(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
// if we get here, the resolve has failed. If the value that we're
|
// if we get here, the resolve has failed. If the value that we're
|
||||||
// trying to resolve doesn't exist, we also get here. We
|
// trying to resolve doesn't exist, we also get here. We
|
||||||
// assume that there is no value and set value to null
|
// assume that there is no value and set value to null
|
||||||
Tracer.TraceError("Missing value or invalid XPath reference (returning [null]) {0}", this.ResolveParameterValue.GrammarExpression);
|
Tracer.TraceWarning("missing-value-or-invalid-xpath-reference-or-grammer: {0}, return-value: (null)", this.ResolveParameterValue.GrammarExpression);
|
||||||
ResolvedParameters.Add(null);
|
ResolvedParameters.Add(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CompileCode_ExecuteCode(object sender, EventArgs e)
|
private void CompileCode_ExecuteCode(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
CodeDomProvider provider = CodeDomProvider.CreateProvider("CSharp");
|
Tracer.Enter("compilecode_executecode");
|
||||||
CompilerParameters compilerParameters = new CompilerParameters();
|
CodeDomProvider provider = CodeDomProvider.CreateProvider("CSharp");
|
||||||
|
CompilerParameters compilerParameters = new CompilerParameters();
|
||||||
|
|
||||||
// DLL must exist in C:\Windows\Microsoft.NET\Framework64\v2.0.50727
|
// DLL must exist in C:\Windows\Microsoft.NET\Framework64\v2.0.50727
|
||||||
foreach (string dll in this.References)
|
foreach (string dll in this.References)
|
||||||
{
|
{
|
||||||
compilerParameters.ReferencedAssemblies.Add(dll);
|
Tracer.TraceInformation("adding-reference-dll {0}", dll);
|
||||||
}
|
compilerParameters.ReferencedAssemblies.Add(dll);
|
||||||
if (compilerParameters.ReferencedAssemblies.Contains("System.dll"))
|
}
|
||||||
{
|
if (!compilerParameters.ReferencedAssemblies.Contains("System.dll"))
|
||||||
compilerParameters.ReferencedAssemblies.Add("System.dll");
|
{
|
||||||
}
|
Tracer.TraceInformation("adding-default-reference-dll System.dll");
|
||||||
compilerParameters.GenerateExecutable = false;
|
compilerParameters.ReferencedAssemblies.Add("System.dll");
|
||||||
compilerParameters.GenerateInMemory = true;
|
}
|
||||||
compilerParameters.IncludeDebugInformation = false;
|
compilerParameters.GenerateExecutable = false;
|
||||||
|
compilerParameters.GenerateInMemory = true;
|
||||||
|
compilerParameters.IncludeDebugInformation = false;
|
||||||
|
|
||||||
CompilerResults cr = provider.CompileAssemblyFromSource(compilerParameters, HttpUtility.HtmlDecode(this.Code));
|
CompilerResults cr = provider.CompileAssemblyFromSource(compilerParameters, HttpUtility.HtmlDecode(this.Code));
|
||||||
if (cr.Errors.HasErrors)
|
|
||||||
{
|
|
||||||
StringBuilder compileErrors = new StringBuilder();
|
|
||||||
foreach (CompilerError ce in cr.Errors)
|
|
||||||
{
|
|
||||||
compileErrors.AppendFormat("Compile Error: {0} in Ln {2} Col {3}-{1}\r\n", ce.ErrorNumber, ce.ErrorText, ce.Line, ce.Column);
|
|
||||||
}
|
|
||||||
Tracer.TraceError("Couldn't compile {0}" + compileErrors);
|
|
||||||
}
|
|
||||||
Assembly assembly = cr.CompiledAssembly;
|
|
||||||
compiled = assembly.CreateInstance("FIMDynamicClass");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ExecuteCode_ExecuteCode(object sender, EventArgs e)
|
if (cr.Errors.HasErrors)
|
||||||
{
|
{
|
||||||
if (compiled == null)
|
Tracer.TraceError("code-had-compile-errors");
|
||||||
{
|
StringBuilder compileErrors = new StringBuilder();
|
||||||
|
foreach (CompilerError ce in cr.Errors)
|
||||||
|
{
|
||||||
|
compileErrors.AppendFormat("compile-error: {0} in Ln {2} Col {3}-{1}\r\n", ce.ErrorNumber, ce.ErrorText, ce.Line, ce.Column);
|
||||||
|
}
|
||||||
|
Tracer.TraceError("could-not-compile {0}", compileErrors);
|
||||||
|
}
|
||||||
|
Assembly assembly = cr.CompiledAssembly;
|
||||||
|
compiled = assembly.CreateInstance("FIMDynamicClass");
|
||||||
|
Tracer.Exit("compilecode_executecode");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ExecuteCode_ExecuteCode(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Tracer.Enter("executecode_executecode");
|
||||||
|
if (compiled == null)
|
||||||
|
{
|
||||||
Tracer.TraceError("Code must contain a class named FIMDynamicClass and that class must contain a method called FIMDynamicFunction");
|
Tracer.TraceError("Code must contain a class named FIMDynamicClass and that class must contain a method called FIMDynamicFunction");
|
||||||
}
|
}
|
||||||
Tracer.TraceInformation("Parameter count {0}", ResolvedParameters.Count);
|
Tracer.TraceInformation("parameter-count {0}", ResolvedParameters.Count);
|
||||||
foreach (object param in ResolvedParameters)
|
foreach (object param in ResolvedParameters)
|
||||||
{
|
{
|
||||||
Tracer.TraceInformation("Adding parameter {0}", param);
|
Tracer.TraceInformation("adding-parameter {0}", param == null ? "(null)" : param);
|
||||||
}
|
}
|
||||||
MethodInfo mi = compiled.GetType().GetMethod("FIMDynamicFunction");
|
MethodInfo mi = compiled.GetType().GetMethod("FIMDynamicFunction");
|
||||||
Tracer.TraceInformation("Executing code");
|
Tracer.TraceInformation("executing-code");
|
||||||
codeReturnValue = mi.Invoke(compiled, ResolvedParameters.ToArray());
|
codeReturnValue = mi.Invoke(compiled, ResolvedParameters.ToArray());
|
||||||
Tracer.TraceInformation("Code executed");
|
Tracer.TraceInformation("code-executed");
|
||||||
Tracer.TraceInformation("Code return value {0}", codeReturnValue);
|
Tracer.TraceInformation("code-return-value {0}", codeReturnValue);
|
||||||
}
|
Tracer.Exit("executecode_executecode");
|
||||||
|
}
|
||||||
|
|
||||||
private void ShouldUpdateTarget_Condition(object sender, ConditionalEventArgs e)
|
private void ShouldUpdateTarget_Condition(object sender, ConditionalEventArgs e)
|
||||||
{
|
{
|
||||||
// try to get parent workflow.
|
// try to get parent workflow.
|
||||||
if (!SequentialWorkflow.TryGetContainingWorkflow(this, out containingWorkflow))
|
if (!SequentialWorkflow.TryGetContainingWorkflow(this, out containingWorkflow))
|
||||||
{
|
{
|
||||||
string errorMessage = "Could not get parent workflow";
|
string errorMessage = "could-not-get-parent-workflow";
|
||||||
Tracer.TraceError(errorMessage);
|
Tracer.TraceError(errorMessage);
|
||||||
throw new InvalidOperationException(errorMessage);
|
throw new InvalidOperationException(errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
StringUtilities.ExtractWorkflowExpression(this.Destination, out destinationObject, out destinationAttribute);
|
StringUtilities.ExtractWorkflowExpression(this.Destination, out destinationObject, out destinationAttribute);
|
||||||
if (!string.IsNullOrEmpty(destinationAttribute))
|
if (!string.IsNullOrEmpty(destinationAttribute))
|
||||||
{
|
{
|
||||||
if (destinationObject.Equals("WorkflowData", StringComparison.OrdinalIgnoreCase))
|
if (destinationObject.Equals("WorkflowData", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
e.Result = false;
|
e.Result = false;
|
||||||
if (containingWorkflow != null)
|
if (containingWorkflow != null)
|
||||||
{
|
{
|
||||||
containingWorkflow.WorkflowDictionary.Add(destinationAttribute, codeReturnValue);
|
containingWorkflow.WorkflowDictionary.Add(destinationAttribute, codeReturnValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (destinationObject.Equals("Target", StringComparison.OrdinalIgnoreCase))
|
else if (destinationObject.Equals("Target", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
e.Result = true;
|
e.Result = true;
|
||||||
UpdateTargetIfNeeded.ActorId = WellKnownGuids.FIMServiceAccount;
|
UpdateTargetIfNeeded.ActorId = WellKnownGuids.FIMServiceAccount;
|
||||||
UpdateTargetIfNeeded.AttributeName = destinationAttribute;
|
UpdateTargetIfNeeded.AttributeName = destinationAttribute;
|
||||||
UpdateTargetIfNeeded.NewValue = codeReturnValue;
|
UpdateTargetIfNeeded.NewValue = codeReturnValue;
|
||||||
UpdateTargetIfNeeded.TargetId = containingWorkflow.TargetId;
|
UpdateTargetIfNeeded.TargetId = containingWorkflow.TargetId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Tracer.TraceError("Could not resolved destination. Please specify as [//Target/Attribute] or [//WorkflowData/Parameter]");
|
Tracer.TraceError("could-not-resolve-destination. Please-specify as [//Target/Attribute] or [//WorkflowData/Parameter]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CatchArgumentException_ExecuteCode(object sender, EventArgs e)
|
private void CatchArgumentException_ExecuteCode(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
// if we get here, the resolve has failed. If the value that we're
|
// if we get here, the resolve has failed. If the value that we're
|
||||||
// trying to resolve doesn't exist, we also get here. We
|
// trying to resolve doesn't exist, we also get here. We
|
||||||
// assume that there is no value and set source value to null
|
// assume that there is no value and set source value to null
|
||||||
// which effectively results in a 'Delete' operation on
|
// which effectively results in a 'Delete' operation on
|
||||||
// the target attribute value (if present)
|
// the target attribute value (if present)
|
||||||
Tracer.TraceError("Error: Argument Exception");
|
Tracer.TraceError("argument-exception");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExitGracefully_ExecuteCode(object sender, EventArgs e)
|
private void ExitGracefully_ExecuteCode(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Tracer.TraceInformation("Activity exited");
|
Tracer.TraceInformation("activity-exited");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,19 +36,19 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Microsoft.IdentityManagement.Activities, Version=4.1.2273.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
<Reference Include="Microsoft.IdentityManagement.Activities, Version=4.1.2273.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>FIMDLLs\Microsoft.IdentityManagement.Activities.dll</HintPath>
|
<HintPath>ReferenceDLLs\4.1.2273\Microsoft.IdentityManagement.Activities.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Microsoft.IdentityManagement.WebUI.Controls, Version=4.1.2273.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
<Reference Include="Microsoft.IdentityManagement.WebUI.Controls, Version=4.1.2273.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>FIMDLLs\Microsoft.IdentityManagement.WebUI.Controls.dll</HintPath>
|
<HintPath>ReferenceDLLs\4.1.2273\Microsoft.IdentityManagement.WebUI.Controls.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Microsoft.IdentityManagement.WFExtensionInterfaces, Version=4.1.2273.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
<Reference Include="Microsoft.IdentityManagement.WFExtensionInterfaces, Version=4.1.2273.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>FIMDLLs\Microsoft.IdentityManagement.WFExtensionInterfaces.dll</HintPath>
|
<HintPath>ReferenceDLLs\4.1.2273\Microsoft.IdentityManagement.WFExtensionInterfaces.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Microsoft.ResourceManagement, Version=4.1.2273.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
<Reference Include="Microsoft.ResourceManagement, Version=4.1.2273.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>FIMDLLs\Microsoft.ResourceManagement.dll</HintPath>
|
<HintPath>ReferenceDLLs\4.1.2273\Microsoft.ResourceManagement.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.Drawing" />
|
<Reference Include="System.Drawing" />
|
||||||
<Reference Include="System.Workflow.Activities" />
|
<Reference Include="System.Workflow.Activities" />
|
||||||
|
|
|
@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("Goverco")]
|
[assembly: AssemblyCompany("Goverco")]
|
||||||
[assembly: AssemblyProduct("Granfeldt.FIM.ActivityLibrary")]
|
[assembly: AssemblyProduct("Granfeldt.FIM.ActivityLibrary")]
|
||||||
[assembly: AssemblyCopyright("Copyright © Goverco 2013-2015")]
|
[assembly: AssemblyCopyright("Copyright © Goverco 2013-2016")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
@ -30,4 +30,4 @@ using System.Runtime.InteropServices;
|
||||||
//NOTE: When updating the namespaces in the project please add new or update existing the XmlnsDefinitionAttribute
|
//NOTE: When updating the namespaces in the project please add new or update existing the XmlnsDefinitionAttribute
|
||||||
//You can add additional attributes in order to map any additional namespaces you have in the project
|
//You can add additional attributes in order to map any additional namespaces you have in the project
|
||||||
//[assembly: System.Workflow.ComponentModel.Serialization.XmlnsDefinition("http://schemas.com/Granfeldt.FIM.ActivityLibrary", "Granfeldt.FIM.ActivityLibrary")]
|
//[assembly: System.Workflow.ComponentModel.Serialization.XmlnsDefinition("http://schemas.com/Granfeldt.FIM.ActivityLibrary", "Granfeldt.FIM.ActivityLibrary")]
|
||||||
[assembly: AssemblyFileVersion("1.6.0.1612")]
|
[assembly: AssemblyFileVersion("1.6.0.1894")]
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Granfeldt.FIM.ActivityLibrary
|
namespace Granfeldt.FIM.ActivityLibrary
|
||||||
{
|
{
|
||||||
|
@ -10,7 +9,7 @@ namespace Granfeldt.FIM.ActivityLibrary
|
||||||
const string SwitchName = "WFL";
|
const string SwitchName = "WFL";
|
||||||
const string SourceName = "WFL";
|
const string SourceName = "WFL";
|
||||||
public static TraceSource Trace = new TraceSource(SourceName, SourceLevels.All);
|
public static TraceSource Trace = new TraceSource(SourceName, SourceLevels.All);
|
||||||
static string IndentText = "";
|
static string IndentText = "";
|
||||||
|
|
||||||
public static int IndentLevel
|
public static int IndentLevel
|
||||||
{
|
{
|
||||||
|
@ -35,13 +34,9 @@ namespace Granfeldt.FIM.ActivityLibrary
|
||||||
{
|
{
|
||||||
TraceInformation("enter {0}", entryPoint);
|
TraceInformation("enter {0}", entryPoint);
|
||||||
Indent();
|
Indent();
|
||||||
//Process currentProc = Process.GetCurrentProcess();
|
|
||||||
//Tracer.TraceInformation("memory-usage {0:n0}Kb, private memomry {1:n0}Kb", GC.GetTotalMemory(true) / 1024, currentProc.PrivateMemorySize64 / 1024);
|
|
||||||
}
|
}
|
||||||
public static void Exit(string entryPoint)
|
public static void Exit(string entryPoint)
|
||||||
{
|
{
|
||||||
//Process currentProc = Process.GetCurrentProcess();
|
|
||||||
//Tracer.TraceInformation("memory-usage {0:n0}Kb, private memory {1:n0}Kb", GC.GetTotalMemory(true) / 1024, currentProc.PrivateMemorySize64 / 1024);
|
|
||||||
Unindent();
|
Unindent();
|
||||||
TraceInformation("exit {0}", entryPoint);
|
TraceInformation("exit {0}", entryPoint);
|
||||||
}
|
}
|
||||||
|
@ -57,6 +52,10 @@ namespace Granfeldt.FIM.ActivityLibrary
|
||||||
{
|
{
|
||||||
Trace.TraceEvent(TraceEventType.Error, id, IndentText + message, param);
|
Trace.TraceEvent(TraceEventType.Error, id, IndentText + message, param);
|
||||||
}
|
}
|
||||||
|
public static void TraceError(string message)
|
||||||
|
{
|
||||||
|
Trace.TraceEvent(TraceEventType.Error, message.GetHashCode(), message);
|
||||||
|
}
|
||||||
public static void TraceError(string message, Exception ex)
|
public static void TraceError(string message, Exception ex)
|
||||||
{
|
{
|
||||||
Trace.TraceEvent(TraceEventType.Error, ex.GetHashCode(), IndentText + "{0}, {1}", message, ex.Message);
|
Trace.TraceEvent(TraceEventType.Error, ex.GetHashCode(), IndentText + "{0}, {1}", message, ex.Message);
|
||||||
|
|
Loading…
Reference in New Issue