完成相关数据服务.docx





《完成相关数据服务.docx》由会员分享,可在线阅读,更多相关《完成相关数据服务.docx(11页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、完成相关数据服务(correlot6d data service)1 .在TruckService工程中,你会找到一个名称为WorkflowTruckTrackingDatoService.cs的源文件。你需要翻开它准备进行编辑。2 .第一件事是添加该服务执行它的任务时所需要的私有字段。在WorkflowTruckTrackingDataService类的左大括号的后面添加下面这些代码:private static WorkflowRuntime _workflowRuntime = null;private static ExternalDataExchangeService _dataEx
2、changeService = null;private static TruckServiceDataConnector _dataConnector = null;private static object _syncRoot = new object();3 .在这些私有字段的下面是该服务将触发的事件。这些事件被触发的结果就是工作流实例将调用一个CHExternolMethod 7制(你可在TruckServiceDotaConnector类中看至匕):public event EventHandler TruckLeaving;public event EventHandler Rou
3、teUpdated;public event EventHandler TruckArrived;4 .接下来添加两个字段以及对应的属性,你需要它们去对相关的服务实例进行识别:private Guid _instanceID = Guid.Empty;public Guid InstancelDget return JnstancelD; set _instanceID = value; lock (.syncRoot)/ If were just starting, save a copy of the workflow runtime reference if (_workflowRunt
4、ime = null)(workflowRuntime = workflowRuntime;/ if/ If were just starting, plug in ExternalDataExchange serviceif (_dataExchangeService = null) _dataExchangeService = new ExternalDataExchangeService();_workflowRuntime.AddService(_dataExchangeService);/ if/ Check to see if we have already added this
5、data exchange serviceTruckServiceDataConnector dataConnector =(TruckServiceDataConnector) workflowRuntime.GetService(typeof(TruckServiceDataCo nnector);if (dataConnector = null) _dataConnector = new TruckServiceDataConnector();_dataExchangeService.AddService(_dataConnector);)/ if elsedataConnector =
6、 dataConnector; / else / Pull the service instance we registered with the connection object returnWorkflowTruckTrackingDataService.GetRegisteredWorkflowDataService(instanceID,truckID); / lockpublic static WorkflowTruckTrackingDataServiceGetRegisteredWorkflowDataService(Guid instancelD, Int32 truckID
7、)lock (_syncRoot)WorkflowTruckTrackingDataService workflowDataService =TruckServiceDataConnector.GetRegisteredWorkflowDataService(instanceID, truckID);if (workflowDataService = null) workflowDataService = newWorkflowTruckTrackingDataService(instanceID, truckID);TruckServiceDataConnector.RegisterData
8、Service(workflowDataService);/ ifreturn workflowDataService; / lockprivate WorkflowTruckTrackingDataService(Guid instancelD, Int32truckID)this. instancelD = instancelD;this. truckID = truckID;WorkflowTruckTrackingDataService()/ Clean upworkflowRuntime = null;_dataExchangeService = null;dataConnector
9、 = null;)public string Read()return _dataConnector.RetrieveTruckInfo(InstanceID,TruckID);public void RaiseTruckLeavingEvent(Int32 truckID, Int32 starting/, Int32 startingY)if (_workflowRuntime = null)_workflowRuntime = new WorkflowRuntime();_workflowRuntime.GetWorkflow(_instanceID); / loads persiste
10、d workflow instancesif (TruckLeaving != null)TruckLeaving(this, new TruckActivityEventArgs(_instanceID, truckID, starting/, startingY);/ ifpublic void RaiseRouteUpdatedEvent(Int32 truckID, Int32 X, Int32 Y)if (_workflowRuntime = null)_workflowRuntime = new WorkflowRuntime();_workflowRuntime.GetWorkf
11、low(_instanceID); / loads persisted workflow instancesif (Routellpdated != null)Routellpdated(this, new TruckActivityEventArgs(_instanceID, truckID, X,/ ifpublic void RaiseTruckArrivedEvent(Int32 truckID)if (_workflowRuntime = null)_workflowRuntime = new WorkflowRuntime();_workflowRuntime.GetWorkflo
12、w(_instanceID); / loads persisted workflowinstancesif (TruckArrived != null)TruckArrived(this, new TruckActivityEventArgs(_instanceIDz truckID);/ ifprivate Int32 _truckID = -1;public Int32 TruckIDget return _truckID; 5现在我们需要添加两个静态方法:一个是在工作流运行时中注册该服务并对它进行配置,另一个是去对已经注册的服务实例进行检索:CreoteDataService 静态方法和
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 完成 相关 数据 服务

限制150内