/// <summary> /// 获取List<CaseRunner>中的更新信息 /// </summary> /// <param name="runnerList">CaseRunner 列表</param> /// <param name="isUpdataAll">T表示全部更新,F标识局部更新</param> /// <returns>更新信息</returns> private RemoteRunnerInfo GetRunnerInfo(List <CaseRunner> runnerList, bool isUpdataAll) { RemoteRunnerInfo remoteRunnerInfo = new RemoteRunnerInfo(); if (runnerList == null) { return(null); } foreach (CaseRunner tempRunner in runnerList) { if (tempRunner.IsNeedUpdata || isUpdataAll) { tempRunner.IsNeedUpdata = false; RunnerState tempRunnerState = new RunnerState(); if (tempRunner.RunerActuator.NowExecutionResultList != null) { if (tempRunner.RunerActuator.NowExecutionResultList.Count > 0) { MyExecutionDeviceResult tempResult = tempRunner.RunerActuator.NowExecutionResultList[tempRunner.RunerActuator.NowExecutionResultList.Count - 1]; tempRunnerState.RunnerID = runnerList.IndexOf(tempRunner); tempRunnerState.RunnerName = tempRunner.RunnerName; tempRunnerState.NowCell = tempResult.caseId.ToString(); tempRunnerState.CellResult = tempResult.result.ToString(); tempRunnerState.State = tempRunner.RunnerState.ToString(); tempRunnerState.Time = tempResult.spanTime; tempRunnerState.RunDetails = tempResult.backContent; tempRunnerState.RunnerProgress = tempRunner.RunerActuator.RunProgress; remoteRunnerInfo.AddRunnerState(tempRunnerState); } else if (isUpdataAll)//对于空NowExecutionResultList来说,如果要求全部更新则要求构造一个初始的数据体 { tempRunnerState.RunnerID = runnerList.IndexOf(tempRunner); tempRunnerState.RunnerName = tempRunner.RunnerName; tempRunnerState.NowCell = ""; tempRunnerState.CellResult = ""; tempRunnerState.State = tempRunner.RunnerState.ToString(); tempRunnerState.Time = ""; tempRunnerState.RunDetails = ""; tempRunnerState.RunnerProgress = tempRunner.RunerActuator.RunProgress; remoteRunnerInfo.AddRunnerState(tempRunnerState); } else { tempRunnerState.RunnerID = runnerList.IndexOf(tempRunner); tempRunnerState.RunnerName = tempRunner.RunnerName; tempRunnerState.State = tempRunner.RunnerState.ToString(); tempRunnerState.RunnerProgress = tempRunner.RunerActuator.RunProgress; remoteRunnerInfo.AddRunnerState(tempRunnerState); } } } } return(remoteRunnerInfo); }
void MessageTransferChannel_OnRunnerInfoCallback(RemoteRunnerInfo remoteRunnerInfo) { if (myOperationContext != null) { try { (myOperationContext.GetCallbackChannel <IExecuteServiceCallBack>()).ReportState(remoteRunnerInfo); } catch { myOperationContext = null; System.Windows.Forms.MessageBox.Show("Test"); } } }
/// <summary> /// 触发更新CaseRunner状态双工回调 /// </summary> /// <param name="caseRunnerList">CaseRunner 列表</param> /// <param name="isAll">是否全部更新</param> private void SendStateInfo(List <CaseRunner> caseRunnerList, bool isAll) { if (BaseHostState != CommunicationState.Opened) { return; } if (caseRunnerList.Count > 0) { RemoteRunnerInfo remoteRunnerInfo = GetRunnerInfo(caseRunnerList, isAll); if (remoteRunnerInfo.RunnerStateList != null) { if (remoteRunnerInfo.RunnerStateList.Count > 0) { if (MessageTransferChannel.OnRunnerInfoCallback != null) { MessageTransferChannel.OnRunnerInfoCallback(remoteRunnerInfo); } } } } }