Welcome

首页 / 软件开发 / .NET编程技术 / WF从入门到精通(第十七章):关联及本地主机通信(下)

WF从入门到精通(第十七章):关联及本地主机通信(下)2010-06-03 cnblogs GuoYong.Che7.在类的构造器的下面,添加下面的读取关联数据的方法:

public string Read()
{
return _dataConnector.RetrieveTruckInfo(InstanceID, TruckID);
}

8.最后添加事件实现的代码:

事件实现的代码

public void RaiseTruckLeavingEvent(Int32 truckID,
Int32 startingX,
Int32 startingY)
{
if (_workflowRuntime == null)
_workflowRuntime = new WorkflowRuntime();
// Loads persisted workflow instances.
_workflowRuntime.GetWorkflow(_instanceID);
if (TruckLeaving != null)
{
TruckLeaving(this, new TruckActivityEventArgs(_instanceID,
truckID,
startingX,
startingY));
} // if
}
public void RaiseRouteUpdatedEvent(Int32 truckID,
Int32 X,
Int32 Y)
{
if (_workflowRuntime == null)
_workflowRuntime = new WorkflowRuntime();
// Loads persisted workflow instances.
_workflowRuntime.GetWorkflow(_instanceID);
if (RouteUpdated != null)
{
RouteUpdated(this, new TruckActivityEventArgs(_instanceID,
truckID,
X, Y));
} // if
}
public void RaiseTruckArrivedEvent(Int32 truckID)
{
if (_workflowRuntime == null)
_workflowRuntime = new WorkflowRuntime();
// Loads persisted workflow instances.
_workflowRuntime.GetWorkflow(_instanceID);
if (TruckArrived != null)
{
TruckArrived(this, new TruckActivityEventArgs(_instanceID,
truckID));
} // if
}