/// <summary> /// get main task case count(just main but not Include the goto case) /// </summary> /// <param name="startNode">start Node</param> /// <returns>count</returns> public static int GetCount(CaseCell startNode) { int nowCount = 0; List <CaseLoopCountInfo> nowLoops = new List <CaseLoopCountInfo>(); while (startNode != null) { if (startNode.CaseType == CaseType.Case) { nowCount++; } else if (startNode.CaseType == CaseType.Repeat) { if (startNode.IsHasChild) { myCaseLaodInfo tempProjectLoadInfo = MyCaseScriptAnalysisEngine.GetCaseLoadInfo(startNode.CaseXmlNode); nowLoops.Add(new CaseLoopCountInfo(startNode.ChildCells[0], tempProjectLoadInfo.times)); } } else if (startNode.CaseType == CaseType.Project) { if (startNode.IsHasChild) { startNode = startNode.ChildCells[0]; } continue; } startNode = startNode.NextCell; } while (nowLoops.Count != 0) { startNode = nowLoops[nowLoops.Count - 1].LoopNode; int tempRate = nowLoops[nowLoops.Count - 1].CaseRate; nowLoops.Remove(nowLoops[nowLoops.Count - 1]); while (startNode != null) { if (startNode.CaseType == CaseType.Case) { nowCount += tempRate; } else if (startNode.CaseType == CaseType.Repeat) { if (startNode.IsHasChild) { myCaseLaodInfo tempProjectLoadInfo = MyCaseScriptAnalysisEngine.GetCaseLoadInfo(startNode.CaseXmlNode); nowLoops.Add(new CaseLoopCountInfo(startNode.ChildCells[0], tempProjectLoadInfo.times * tempRate)); } } startNode = startNode.NextCell; } } return(nowCount); }
/// <summary> /// i will get the next myTreeTagInfo in my queue /// </summary> /// <returns>the CaseCell you want</returns> public CaseCell nextCase() { if (nowCaseNode == null) //起始节点 { nowCaseNode = startCaseNode; if (nowCaseNode.CaseType == CaseType.Repeat) { if (nowCaseNode.IsHasChild) { myCaseLaodInfo tempProjectLoadInfo = MyCaseScriptAnalysisEngine.GetCaseLoadInfo(nowCaseNode.CaseXmlNode); AddCaseLoop(nowCaseNode.ChildCells[0], tempProjectLoadInfo.times); } return(nextCase()); } else if (nowCaseNode.CaseType == CaseType.Case) { queueNowCount++; return(nowCaseNode); } else if (nowCaseNode.CaseType == CaseType.Project) { if (nowCaseNode.IsHasChild) { startCaseNode = nowCaseNode.ChildCells[0]; nowCaseNode = null; return(nextCase()); } return(null); //空Project } else { return(null); //当前设计不会有这种情况 } } else { if (myCaseLoopList.Count > 0) { int tempNowListIndex = myCaseLoopList.Count - 1; CaseCell tempNextLoopTreeNode = myCaseLoopList[tempNowListIndex].nextCase(); if (tempNextLoopTreeNode == null) { DelCaseLoop(myCaseLoopList[tempNowListIndex]); return(nextCase()); } else { if (tempNextLoopTreeNode.CaseType == CaseType.Repeat) { if (tempNextLoopTreeNode.IsHasChild) { myCaseLaodInfo tempProjectLoadInfo = MyCaseScriptAnalysisEngine.GetCaseLoadInfo(tempNextLoopTreeNode.CaseXmlNode); AddCaseLoop(tempNextLoopTreeNode.ChildCells[0], tempProjectLoadInfo.times); } return(nextCase()); } else if (tempNextLoopTreeNode.CaseType == CaseType.Case) { queueNowCount++; return(tempNextLoopTreeNode); } else { return(null); //当前设计不会有这种情况 } } } else { if (nowCaseNode.NextCell == null) { return(null); //当前 【Queue】 结束 } else { nowCaseNode = nowCaseNode.NextCell; if (nowCaseNode.CaseType == CaseType.Repeat) { if (nowCaseNode.IsHasChild) { myCaseLaodInfo tempProjectLoadInfo = MyCaseScriptAnalysisEngine.GetCaseLoadInfo(nowCaseNode.CaseXmlNode); AddCaseLoop(nowCaseNode.ChildCells[0], tempProjectLoadInfo.times); } return(nextCase()); } else if (nowCaseNode.CaseType == CaseType.Case) { queueNowCount++; return(nowCaseNode); } else { return(null); //当前设计不会有这种情况 } } } } }