Я работаю с примерами проектов Microsoft wf: WF_WCF_Samples \ WF \ Application \ VisualWorkflowTracking \ CS В этом примере проекта выполняется моделирование wf4.
Рабочий процесс имеет входной аргумент bool.
В настоящее времяУ меня две проблемы.
Первая проблема:
Если я ввожу значение в аргумент (конструктор рабочего процесса), я не получаю никаких исключений, когда код выполняется, но моделирование не выполняется.
Я изменил код и попытался получить набор аргументов.Затем я добавляю их в словарь, который затем передается в метод Invoke.Этот подход не дает мне никакой ошибки, но он не запускает процесс.Я думаю, что значение аргумента не передается в словарь должным образом.Ниже приведен код:
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);
}));
}));