
Untitled
By: a guest on
Apr 25th, 2012 | syntax:
None | size: 2.08 KB | hits: 12 | expires: Never
Workflow does not execute properly, but no exception is thrown
ThreadPool.QueueUserWorkItem(new WaitCallback((context) =>
{
bool noArguments = false;
var serviceManager = this.WorkflowDesigner.Context.Services;
Dictionary<string, object> retval = new Dictionary<string, object>();
var modelService = serviceManager.GetService<ModelService>();
var rootModelItem = modelService.Root;
var properties = rootModelItem.Properties["Properties"];
if (properties == null) noArguments = true;
var propertiesCollection = properties.Collection;
if (propertiesCollection == null) noArguments = true;
if (propertiesCollection.Count == 0) noArguments = true;
foreach (var p in propertiesCollection)
{
var d = p.GetCurrentValue() as DynamicActivityProperty;
if (d != null)
{
var name = d.Name;
dynamic inArgument = d.Value;
try
{
var val = inArgument.Expression.Value;
retval.Add(name, val);
}
catch (Exception er)
{
MessageBox.Show("Variable: " + d.Name + " Value is Empty", "Variable Error",MessageBoxButton.OK,MessageBoxImage.Error);
}
}
}
//Invoking the Workflow Instance with Input Arguments
if (noArguments)
{
instance.Invoke();
}
else
{
//this line below does raise any error but it does not run the process.
//instance.Invoke(retval, new TimeSpan(1, 0, 0));
//this line below works as long as in the workflow designer the argument value is left blank
instance.Invoke(new Dictionary<string, object> { { "decisionVar", "hello" } }, new TimeSpan(1, 0, 0));
}
//This is to remove the final debug adornment
this.Dispatcher.Invoke(DispatcherPriority.Render
, (Action)(() =>
{
this.WorkflowDesigner.DebugManagerView.CurrentLocation = new SourceLocation(this.WorkFlowFile,1,1,1,10);
//this.WorkflowDesigner.DebugManagerView.CurrentLocation = new SourceLocation("Workflow.xaml",1,1,1,10);
}));
}));