Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 25th, 2012  |  syntax: None  |  size: 2.08 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Workflow does not execute properly, but no exception is thrown
  2. ThreadPool.QueueUserWorkItem(new WaitCallback((context) =>
  3. {
  4.  
  5.     bool noArguments = false;
  6.  
  7.     var serviceManager = this.WorkflowDesigner.Context.Services;
  8.  
  9.     Dictionary<string, object> retval = new Dictionary<string, object>();
  10.     var modelService = serviceManager.GetService<ModelService>();
  11.     var rootModelItem = modelService.Root;
  12.  
  13.     var properties = rootModelItem.Properties["Properties"];
  14.     if (properties == null) noArguments = true;
  15.  
  16.     var propertiesCollection = properties.Collection;
  17.     if (propertiesCollection == null) noArguments = true;
  18.     if (propertiesCollection.Count == 0) noArguments = true;
  19.  
  20.     foreach (var p in propertiesCollection)
  21.     {
  22.         var d = p.GetCurrentValue() as DynamicActivityProperty;
  23.         if (d != null)
  24.         {
  25.             var name = d.Name;
  26.             dynamic inArgument = d.Value;
  27.  
  28.             try
  29.             {
  30.                 var val = inArgument.Expression.Value;
  31.                 retval.Add(name, val);
  32.             }
  33.             catch (Exception er)
  34.             {
  35.                 MessageBox.Show("Variable: " + d.Name + " Value is Empty", "Variable Error",MessageBoxButton.OK,MessageBoxImage.Error);
  36.             }
  37.         }
  38.  
  39.     }
  40.  
  41.     //Invoking the Workflow Instance with Input Arguments
  42.     if (noArguments)
  43.     {
  44.         instance.Invoke();
  45.     }
  46.     else
  47.     {
  48.         //this line below does raise any error but it does not run the process.
  49.         //instance.Invoke(retval, new TimeSpan(1, 0, 0));  
  50.  
  51. //this line below works as long as in the workflow designer the argument value is left blank
  52.         instance.Invoke(new Dictionary<string, object> { { "decisionVar", "hello" } }, new TimeSpan(1, 0, 0));
  53.     }
  54.  
  55.  
  56.     //This is to remove the final debug adornment
  57.     this.Dispatcher.Invoke(DispatcherPriority.Render
  58.         , (Action)(() =>
  59.     {
  60.         this.WorkflowDesigner.DebugManagerView.CurrentLocation = new SourceLocation(this.WorkFlowFile,1,1,1,10);
  61.         //this.WorkflowDesigner.DebugManagerView.CurrentLocation = new SourceLocation("Workflow.xaml",1,1,1,10);
  62.     }));
  63.  
  64. }));