/// <summary> /// 查看一条脚本流实例 /// </summary> /// <param name="ScriptId">脚本流ID</param> /// <param name="ExampleId">脚本流实例ID</param> /// <returns></returns> public ActionResult SelectScriptExample(long?ScriptId = null, long?ExampleId = null) { var model = new InitExampleScript(); if (ScriptId != null || ExampleId != null) { model = _scriptService.GetSignExampleScript(ScriptId, ExampleId); } return(View("Easyman.FwWeb.Views.Script.SelectScriptExample", model)); }
/// <summary> /// 根据脚本流实例ID 获取一条脚本流实例 /// </summary> /// <param name="ScriptId">脚本流ID</param> /// <param name="ExampleId">脚本流实例ID</param> /// <returns></returns> public InitExampleScript GetSignExampleScript(long?ScriptId = null, long?ExampleId = null) { #region 脚本流实例 ExampleScriptCase es = new ExampleScriptCase(); if (ScriptId != null)//根据脚本流ID 查询 { var temp = _scriptCase.FirstOrDefault(x => x.ScriptId == ScriptId.Value); es = temp.MapTo <ExampleScriptCase>(); } else if (ExampleId != null)//根据脚本流实例ID 查询 { var temp = _scriptCase.FirstOrDefault(x => x.Id == ExampleId.Value); es = temp.MapTo <ExampleScriptCase>(); } if (es.UserId != null && es.UserId != 0) { es.USER_ID_STR = _userRepository.Get(es.UserId.Value).UserName; } es.SCRIPT_ID_STR = _script.Get(es.ScriptId.Value).Name; #endregion #region 查询脚本流实例所有节点的位置 List <NodePositionForCase> npfc = new List <NodePositionForCase>(); if (ScriptId != null)//根据脚本流ID 查询 { npfc = _nodePositionForCase.GetAllList(x => x.ScriptId == ScriptId.Value); } else if (ExampleId != null)//根据脚本流实例ID 查询 { npfc = _nodePositionForCase.GetAllList(x => x.ScriptCaseId == ExampleId.Value); } #endregion #region 查询脚本实例连接线SQL List <ConnectLineForCase> clfc = new List <ConnectLineForCase>(); if (ScriptId != null)//根据脚本流ID 查询 { clfc = _connectLineForCase.GetAllList(x => x.ScriptId == ScriptId.Value); } else if (ExampleId != null)//根据脚本流实例ID 查询 { clfc = _connectLineForCase.GetAllList(x => x.ScriptCaseId == ExampleId.Value); } #endregion #region 脚本流实例节点SQL List <ScriptNodeForCaseDto> node_list = _scriptNodeForCase.GetAllList(x => x.ScriptCaseId == ExampleId.Value).MapTo <List <ScriptNodeForCaseDto> >(); for (int i = 0; i < node_list.Count; i++) { var scriptCaseId = node_list[i].SCRIPT_CASE_ID; var scriptNodeId = node_list[i].SCRIPT_NODE_ID; var temp = _scriptNodeCase.FirstOrDefault(x => x.ScriptCaseId == scriptCaseId && x.ScriptNodeId == scriptNodeId); if (temp == null) { node_list[i].RUN_STATUS_STR = "未执行"; node_list[i].RETURN_CODE_STR = ""; continue; } switch (temp.RunStatus) { case 0: node_list[i].RUN_STATUS_STR = "停止"; break; case 1: node_list[i].RUN_STATUS_STR = "等待"; break; case 2: node_list[i].RUN_STATUS_STR = "执行中"; break; default: node_list[i].RUN_STATUS_STR = "未执行"; break; } switch (temp.ReturnCode) { case 0: node_list[i].RETURN_CODE_STR = "失败"; break; case 1: node_list[i].RETURN_CODE_STR = "成功"; break; case 2: node_list[i].RETURN_CODE_STR = "预警"; break; default: node_list[i].RETURN_CODE_STR = ""; break; } node_list[i].LOG_NODE_ID = temp.Id; node_list[i].NODE_NAME = node_list[i].NAME; } #endregion try { InitExampleScript Res = new InitExampleScript(); Res = es.MapTo <InitExampleScript>(); #region 脚本实例节点位置 Res.NodePositionJson = JsonConvert.SerializeObject(npfc); #endregion #region 连接线 Res.ConnectLineJson = JsonConvert.SerializeObject(clfc); #endregion #region 脚本流实例节点 Res.ScriptNodeCaseJson = JsonConvert.SerializeObject(node_list); #endregion return(Res); } catch (Exception ex) { return(new InitExampleScript()); } }