首页 新闻 搜索 专区 学院

wf的flowswitch无法赋值

0
悬赏园豆:50 [已关闭问题] 关闭于 2013-05-15 10:44

  我用silverlight在界面上画的一个流程,用代码写出来的图,但是走到了flowswitch之后,就停了,然后查询表,发现连实例都没有,之前的两步都是可以走的,不知道是出了什么问题,初步怀疑是flowswitch的判断条件有问题。下面是代码:

  xaml模板:

<?xml version="1.0" encoding="utf-16"?><Activity x:Class="{x:Null}" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:swc="clr-namespace:ShareDesigner.Web.Class;assembly=ShareDesigner.Web" xmlns:swm="clr-namespace:ShareDesigner.Web.Models;assembly=ShareDesigner.Web" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"><x:Members><x:Property Name="Entity" Type="InOutArgument(x:Object)" /><x:Property Name="NextWay" Type="InOutArgument(x:String)" /></x:Members><Flowchart DisplayName="新建流程" StartNode="{x:Reference __ReferenceID5}"><FlowStep x:Name="__ReferenceID5"><swc:StartActivity ActivityId="e20e9c45-d50b-4187-b9a4-3dec49c4e8ff" DisplayName="" /><FlowStep.Next><FlowStep x:Name="__ReferenceID1"><swc:ActiveActivity ActivityId="2e80a993-f15c-4ce5-b637-c3be10a4942d"><swc:ActiveActivity.Entity><InOutArgument x:TypeArguments="x:Object" /></swc:ActiveActivity.Entity><swc:ActiveActivity.NextWay><InOutArgument x:TypeArguments="x:String" /></swc:ActiveActivity.NextWay><swc:ActiveActivity.Property><swm:WFActivityProperty desc="{x:Null}" name="{x:Null}" after_type="1" allow_mail="True" allow_note="False" allow_track="False" approve_type="1" approver="" can_change="False" can_collect="False" can_stop="False" parallel_rule="0" rec_no="0" tmp_no="0" track_no="0" /></swc:ActiveActivity.Property></swc:ActiveActivity><FlowStep.Next><FlowSwitch x:TypeArguments="x:String" x:Name="__ReferenceID4" Expression="[NextWay]"><FlowStep x:Key="996d501c-700a-4705-8b24-dfd74a66ff7e" x:Name="__ReferenceID2"><swc:ActiveActivity ActivityId="996d501c-700a-4705-8b24-dfd74a66ff7e"><swc:ActiveActivity.Entity><InOutArgument x:TypeArguments="x:Object" /></swc:ActiveActivity.Entity><swc:ActiveActivity.NextWay><InOutArgument x:TypeArguments="x:String" /></swc:ActiveActivity.NextWay><swc:ActiveActivity.Property><swm:WFActivityProperty desc="{x:Null}" name="{x:Null}" after_type="1" allow_mail="True" allow_note="False" allow_track="False" approve_type="1" approver="" can_change="False" can_collect="False" can_stop="False" parallel_rule="0" rec_no="0" tmp_no="0" track_no="0" /></swc:ActiveActivity.Property></swc:ActiveActivity><FlowStep.Next><FlowStep x:Name="__ReferenceID0"><swc:EndActivity ActivityId="28f3c402-bc57-482d-b31d-a2d91fda1d05" /></FlowStep></FlowStep.Next></FlowStep><FlowStep x:Key="d43b7a1a-bca6-4db1-868d-5a6fee275ada" x:Name="__ReferenceID3"><swc:ActiveActivity ActivityId="d43b7a1a-bca6-4db1-868d-5a6fee275ada"><swc:ActiveActivity.Entity><InOutArgument x:TypeArguments="x:Object" /></swc:ActiveActivity.Entity><swc:ActiveActivity.NextWay><InOutArgument x:TypeArguments="x:String" /></swc:ActiveActivity.NextWay><swc:ActiveActivity.Property><swm:WFActivityProperty desc="{x:Null}" name="{x:Null}" after_type="1" allow_mail="True" allow_note="False" allow_track="False" approve_type="1" approver="" can_change="False" can_collect="False" can_stop="False" parallel_rule="0" rec_no="0" tmp_no="0" track_no="0" /></swc:ActiveActivity.Property></swc:ActiveActivity><FlowStep.Next><x:Reference>__ReferenceID0</x:Reference></FlowStep.Next></FlowStep></FlowSwitch></FlowStep.Next></FlowStep></FlowStep.Next></FlowStep><x:Reference>__ReferenceID1</x:Reference><x:Reference>__ReferenceID2</x:Reference><x:Reference>__ReferenceID3</x:Reference><x:Reference>__ReferenceID4</x:Reference><x:Reference>__ReferenceID0</x:Reference></Flowchart></Activity>
View Code

     下面是运行的代码:

StringReader stringReader = new StringReader(xaml);
                Activity wf = ActivityXamlServices.Load(stringReader);
                var param = new Dictionary<string, object>();
param.Add("NextWay", "996d501c-700a-4705-8b24-dfd74a66ff7e");
                var wfApp = new WorkflowApplication(wf,param);
                wfApp.InstanceStore = instanceStore;
                wfApp.PersistableIdle = (o) => PersistableIdleAction.Unload;
                wfApp.OnUnhandledException = (o) =>
                    {
                        DBHelper.ExecuteCommand("insert into SysException(Id,Message)values(NEWID(),'" + o.UnhandledException.Message + "')");
                        return UnhandledExceptionAction.Terminate;
                    };
                wfApp.Run();
View Code

 

     然后是恢复标签的运行代码,执行到这里就不走了,数据库的实例都没有了。

    

wfApp.Load(instanceId);
wfApp.ResumeBookmark("BookMark", "996d501c-700a-4705-8b24-dfd74a66ff7e");
View Code

    

    我在构造flowswitch的时候,添加了两条路径,根据一个参数“NextWay”来做判断,这个“NextWay”我是想在恢复bookmark的时候,传入的,然后flowswitch根据我传入的这个活动id,选择要走的活动,但。。。跑到这里就死了。。。

  

岑玉海的主页 岑玉海 | 菜鸟二级 | 园豆:204
提问于:2013-05-15 01:38
< >
分享
所有回答(1)
0

发现问题了,最后 public  InOutArgument<string> NextWay = new VisualBasicReffence<string>(){ExpressionText= "NextWay"};

创建一下关联,和活动的属性关联上即可。

岑玉海 | 园豆:204 (菜鸟二级) | 2013-05-15 10:44
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册