using AddInPlugin.Util; using OpenTap; using System; namespace AddInPlugin { [Display("Continue", Group: "流程控制", Order: 0)] [AllowAnyChild] public class ContinueStep : TestStep { private string condition; [Display("条件")] public string Condition { get => condition; set { condition = value; OnPropertyChanged(nameof(Condition)); } } private int timeout = 0; [Display("延时")] public int Timeout { get => timeout; set { timeout = value; OnPropertyChanged(nameof(Timeout)); } } public ContinueStep() : base() { Rules.Add(() => GetParent() != null, "必须在CanContinue中", Name); } public override void Run() { try { bool needBreak = false; if (string.IsNullOrEmpty(Condition)) { needBreak = true; } else if (PlanRun.Resolve(this, Condition)) { needBreak = true; } if (needBreak) { var target = this.GetParent(); if (target == null) { throw new Exception("Structure Error"); } TapThread.Sleep(Timeout); target.IsContinued = true; UpgradeVerdict(Verdict.NotSet); } } catch (Exception ex) { Log.Error("For Run error. {0}", ex); UpgradeVerdict(Verdict.Error); } } public override void PostPlanRun() { base.PostPlanRun(); } } }