技术开发 频道

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


【IT168技术文档】

  需要用到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就是宿主与工作流之间传递的重要属性。
0
相关文章