• wf HandlExternalEvent传递参数到自定义属性中


    如果在Workflow中定义了一个属性,如何才能在工作流创建后对这个属性进行修改呢?
    今天折腾了一天,也不见有什么效果,只搞懂了一半,先写出来,没有领悟到的等以后想通了再写。
    在创建工作流的时候,可以用CreateWorkflow(typeof(wf),Dictionary<string,object>)这样的方式将参数值传入工作流。但是如果工作流已经创建,宿主程序又如何把值传入工作流呢?
    需要用到ExternalDataEventArgs这个东东,需要自己继承一个这样的类
    [Serializable]
        
    public class BillExternalDataEventArgs : ExternalDataEventArgs {
            
    private Decimal _mycash;
            
    public Decimal Cash {
                
    get return _mycash; }
                
    set { _mycash = value; }
            }

            
    public BillExternalDataEventArgs(Guid instanceId,Decimal decCash) : base(instanceId) {
                _mycash 
    = decCash;
            }

        }
    然后在把对应的接口进行相应的调整
        [ExternalDataExchange]
        
    public interface IBillWorkFlow
        
    {
            Decimal GetCash(Decimal decCash);
            
    event EventHandler<BillExternalDataEventArgs> BillSubmit;
            
    event EventHandler<BillExternalDataEventArgs> BillOk;
        }

    [Serializable]
        
    public class MyBillWorkFlow : IBillWorkFlow {
            
    public MyBillWorkFlow() {
                System.Diagnostics.Debug.WriteLine(
    "MyBillWorkFlow Init");
            }


            Dictionary
    <string, EventHandler<BillExternalDataEventArgs>> _EventList = new Dictionary<string, EventHandler<BillExternalDataEventArgs>>();

            
    public void RaisEvent(string strName,Guid guidInstanceId,Decimal decCash) {
                
    if (_EventList[strName] != null)
                
    {
                    
    try
                    
    {
                        EventHandler
    <BillExternalDataEventArgs> evehandler = _EventList[strName];
                        BillExternalDataEventArgs ede 
    = new BillExternalDataEventArgs(guidInstanceId,decCash);
                        evehandler(
    this, ede);
                    }

                    
    catch 
                    
                    }

                }

            }


            
    public Decimal GetCash(Decimal decCash)
            

                
    return decCash;
            }


            
    public event EventHandler<BillExternalDataEventArgs> BillSubmit
            
    {
                add 
    {
                    System.Diagnostics.Debug.WriteLine(
    "add BillSubmit event");
                    _EventList.Add(
    "BillSubmit", value); 
                }

                remove 
    { _EventList.Remove("BillSubmit"); }
            }


            
    public event EventHandler<BillExternalDataEventArgs> BillOk
            
    {
                add 
    { _EventList.Add("BillOk", value); }
                remove 
    { _EventList.Remove("BillOk"); }
            }

        }

    然后在工作流中定义
    public Billdayone.BillExternalDataEventArgs _cash = default(Billdayone.BillExternalDataEventArgs);

    这个_cash就是宿主与工作流之间传递的重要属性。

    只需要调用
    RaisEvent(string strName,Guid guidInstanceId,Decimal decCash)//Decimal decCash就是宿主向工作流传递的参数,将传递给_cash.Cash
    这样就完成了宿主向工作流传递参数。

    但是我还没有弄明白怎么能够得到工作流中的属性值。还在学习中。。。还不知道怎么办?。。。
  • 相关阅读:
    [硬件]_ELVE_VS2015下opencv3.3的配置问题
    [Linux]_ELVE_ssh登录远程阿里服务器
    [python]_ELVE_pip2和pip3如何共存
    U盘无法打开提示格式化?如何进行恢复
    [转]pycharm的一些快捷键
    文件上传Django
    ansible编译安装--操作系统环境Redhat6.4
    django的models字段介绍
    paramiko模块
    mysql安装等操作
  • 原文地址:https://www.cnblogs.com/poplau/p/1237783.html
Copyright © 2020-2023  润新知