public void ThreadProc(Object stateInfo) { if (flowItem_ != null) { flowItem_.BeginTime = DateTime.Now; Log.Debug("Item[" + flowItem_.Id + "] " + flowItem_.Item.Property.Name + " start"); List <Method> methodList = flowItem_.Item.MethodList; Tuple <int, int> firstLast = GetLoopFirstLast(methodList); if (firstLast.Item1 == -1 || firstLast.Item2 == -1 || firstLast.Item1 >= firstLast.Item2 || flowItem_.Item.Property.Loop < 2) { //不需要循环 foreach (Method method in methodList) { if (!method.Disable) { string retValue; ExecuteCmd(method.Name, method.Action, ReplaceSymbol(method.Param), out retValue); if (!string.IsNullOrEmpty(method.Compare) && !string.IsNullOrEmpty(retValue)) { UpdateSpecValue(retValue, method.Compare, flowItem_.SpecValueList); } } } } else { bool loopExit = false; for (int i = 0; i < flowItem_.Item.Property.Loop && !loopExit; i++) { for (int j = 0; j < methodList.Count; j++) { Method method = methodList[j]; if (i == 0) { if (loopExit) { if (method.Depend) { continue; } } else { if (j > firstLast.Item2) { continue; } } } else if (i != flowItem_.Item.Property.Loop - 1) { if (loopExit) { if (j <= firstLast.Item2) { continue; } } else { if (!method.Depend && !method.Bedepend) { continue; } } } else { if (loopExit) { if (j <= firstLast.Item2) { continue; } } else { if (!method.Depend && !method.Bedepend && j <= firstLast.Item2) { continue; } } } if (!method.Disable) { string retValue; ExecuteCmd(method.Name, method.Action, ReplaceSymbol(method.Param), out retValue); if (!string.IsNullOrEmpty(method.Compare) && !string.IsNullOrEmpty(retValue)) { UpdateSpecValue(retValue, method.Compare, flowItem_.SpecValueList); } if (method.Bedepend && flowItem_.IsPass()) { loopExit = true; } } } } } flowItem_.EndTime = DateTime.Now; flowItem_.Duration = (long)(flowItem_.EndTime - flowItem_.BeginTime).TotalMilliseconds; Log.Debug("Item[" + flowItem_.Id + "] " + flowItem_.Item.Property.Name + " finish"); if (ExecuteFinish != null) { ExecuteFinish(this, new ExecuteFinishEventArgs(flowItem_)); } } }
/// <summary> /// 是否需要跳过测试 /// 如果跳过测试指令,则直接将实测值赋值为Skip,测试结果赋值为失败 /// </summary> /// <returns></returns> public bool IsSkip() { if (!String.IsNullOrEmpty(Item.Property.Condition)) { string condition = Item.Property.Condition.Replace(" ", String.Empty); string expression = String.Empty; string operand = String.Empty; bool not = false; foreach (char c in condition) { if (c == '+' || c == '-' || c == '(' || c == ')') { if (!String.IsNullOrEmpty(operand)) { int id = Int32.Parse(operand); FlowItem flowItem = FlowControl.Instance.GetFlowItem(id); bool pass = false; if (flowItem != null && flowItem.IsPass()) { pass = true; } if (not) { pass = !pass; } expression += pass ? Boolean.TrueString : Boolean.FalseString; operand = String.Empty; not = false; } expression += c; } else if (c == '!') { not = true; } else { operand += c; } } if (!String.IsNullOrEmpty(operand)) { int id = Int32.Parse(operand); FlowItem flowItem = FlowControl.Instance.GetFlowItem(id); bool pass = false; if (flowItem != null && flowItem.IsPass()) { pass = true; } if (not) { pass = !pass; } expression += pass ? Boolean.TrueString : Boolean.FalseString; operand = String.Empty; not = false; } return(!Utils.IsTrue(expression)); } return(false); }