B
Bill Richards
I have the following sequence activity within a Sequential Workflow
// delegate for OnLoadFilters event
public delegate void LoadFiltersEventHandler();
public partial class DynamicFilteringActivity : SequenceActivity
{
public event LoadFiltersEventHandler OnLoadFilters;
protected override ActivityExecutionStatus
Execute(ActivityExecutionContext executionContext)
{
if(null != OnLoadFilters)
{
LogWriter.Trace("DynamicFilteringActivity::Loading
filters");
OnLoadFilters();
}
return (base.Execute(executionContext));
}
}
When this Activity is run, as you can see it simply raises the OnLoadFilters
event, which is registered with the SequentialWorkflowActivity thus
// in SequentialWorkflowActivity's designer.cs file
this.FilteringSequence.OnLoadFilters += new
e3.net.interfacing.activities.LoadFiltersEventHandler(this.OnLoadFilters_ExecuteCode);
// in SequentialWorkflowActivity's .cs file
private void OnLoadFilters_ExecuteCode()
{
// code ellided for the sake of berevity.
// suffice it to say however, that DynamicFilterLoader, takes a
few parameters and does the actual
// business of adding the Activities to the Workflow
DynamicFilterLoader.LoadFilters(ref workflowChanges,
MessageSystem.MessageType, messagePath);
try { ApplyWorkflowChanges(workflowChanges); }
catch(InvalidOperationException ex)
{
// log error
LogWriter.Exception(ex);
throw;
}
catch(WorkflowValidationFailedException wvfe)
{
LogWriter.Exception(wvfe);
var sb = new StringBuilder();
foreach(ValidationError error in wvfe.Errors)
sb.AppendLine(error.ErrorText);
LogWriter.Trace(sb.ToString());
throw;
}
}
One of these "Filters" which is loaded at runtime, for example is
FilterGender, whose constructors are defined as follows:
[System.Diagnostics.DebuggerStepThrough]
public FilterGender() { InitializeComponent(); }
[System.Diagnostics.DebuggerStepThrough]
public FilterGender(string gender, MessageResponses response) :
base(response)
{
Genders = new List<string>();
Genders.AddRange(gender.Split(new[] { ',' },
StringSplitOptions.RemoveEmptyEntries));
LogWriter.FilterRelatedTracing(string.Format("FilterGender::FilterGender(\"{0}\",
{1}) constructed ... ", gender, response));
}
So far so good, when the workflow is run, the approriate logic is used to
determine whether or not our dynamic filters are required and the
appropriate filter is indeed added to the workflow, this much is evident in
the fact that our Trace file contains the expected trace
"FilterGender::FilterGender(\"{0}\", {1}) constructed ... ", also when the
DebuggerStepThrough attribute is commented out and we run the workflow in
debug mode, we can set a breakpoint in the constructor.
The problem is however, that although no exceptions are raised when the call
to ApplyWorkflowChanges(workflowChanges); is made, the Execute method of
the dynamically loaded filter is never called.
If there is not enough information here let me know and I will provide more.
Thanks in advance.
// delegate for OnLoadFilters event
public delegate void LoadFiltersEventHandler();
public partial class DynamicFilteringActivity : SequenceActivity
{
public event LoadFiltersEventHandler OnLoadFilters;
protected override ActivityExecutionStatus
Execute(ActivityExecutionContext executionContext)
{
if(null != OnLoadFilters)
{
LogWriter.Trace("DynamicFilteringActivity::Loading
filters");
OnLoadFilters();
}
return (base.Execute(executionContext));
}
}
When this Activity is run, as you can see it simply raises the OnLoadFilters
event, which is registered with the SequentialWorkflowActivity thus
// in SequentialWorkflowActivity's designer.cs file
this.FilteringSequence.OnLoadFilters += new
e3.net.interfacing.activities.LoadFiltersEventHandler(this.OnLoadFilters_ExecuteCode);
// in SequentialWorkflowActivity's .cs file
private void OnLoadFilters_ExecuteCode()
{
// code ellided for the sake of berevity.
// suffice it to say however, that DynamicFilterLoader, takes a
few parameters and does the actual
// business of adding the Activities to the Workflow
DynamicFilterLoader.LoadFilters(ref workflowChanges,
MessageSystem.MessageType, messagePath);
try { ApplyWorkflowChanges(workflowChanges); }
catch(InvalidOperationException ex)
{
// log error
LogWriter.Exception(ex);
throw;
}
catch(WorkflowValidationFailedException wvfe)
{
LogWriter.Exception(wvfe);
var sb = new StringBuilder();
foreach(ValidationError error in wvfe.Errors)
sb.AppendLine(error.ErrorText);
LogWriter.Trace(sb.ToString());
throw;
}
}
One of these "Filters" which is loaded at runtime, for example is
FilterGender, whose constructors are defined as follows:
[System.Diagnostics.DebuggerStepThrough]
public FilterGender() { InitializeComponent(); }
[System.Diagnostics.DebuggerStepThrough]
public FilterGender(string gender, MessageResponses response) :
base(response)
{
Genders = new List<string>();
Genders.AddRange(gender.Split(new[] { ',' },
StringSplitOptions.RemoveEmptyEntries));
LogWriter.FilterRelatedTracing(string.Format("FilterGender::FilterGender(\"{0}\",
{1}) constructed ... ", gender, response));
}
So far so good, when the workflow is run, the approriate logic is used to
determine whether or not our dynamic filters are required and the
appropriate filter is indeed added to the workflow, this much is evident in
the fact that our Trace file contains the expected trace
"FilterGender::FilterGender(\"{0}\", {1}) constructed ... ", also when the
DebuggerStepThrough attribute is commented out and we run the workflow in
debug mode, we can set a breakpoint in the constructor.
The problem is however, that although no exceptions are raised when the call
to ApplyWorkflowChanges(workflowChanges); is made, the Execute method of
the dynamically loaded filter is never called.
If there is not enough information here let me know and I will provide more.
Thanks in advance.