using OpenTap;
|
using OpenTap.Addin.Util;
|
using System;
|
|
namespace AddInPlugin
|
{
|
[Display("ElseIf", Group:"流程控制", Order: 0)]
|
[AllowAnyChild]
|
public class ElseIfConditionStep : ConditionBase
|
{
|
public ElseIfConditionStep() : base()
|
{
|
Rules.Add(() =>
|
{
|
var previous = this.GetPreviousStep();
|
return previous is ConditionBase && previous.Enabled == this.Enabled;
|
}, "必须在If/ElseIf之后且同时启用/未启用", Name);
|
}
|
|
public override void PrePlanRun()
|
{
|
|
}
|
|
protected override void RunDetail()
|
{
|
try
|
{
|
var previous = this.GetPreviousStep();
|
if (!(previous is ConditionBase cb))
|
{
|
throw new Exception("Error Stucture");
|
}
|
if (cb.ConditionResult == true)
|
{
|
/// 条件命中了,ElseIf就不执行,只把自己的条件改为命中
|
this.ConditionResult = true;
|
UpgradeVerdict(Verdict.NotSet);
|
return;
|
}
|
|
ConditionResult = (bool)PlanRun.Resolve(this, Condition);
|
|
if (ConditionResult == true)
|
{
|
RunChildSteps();
|
UpgradeVerdict(Verdict.Pass);
|
}
|
else
|
{
|
UpgradeVerdict(Verdict.NotSet);
|
}
|
}
|
catch (Exception ex)
|
{
|
Log.Error("ElseIf Run error. {0}", ex);
|
ConditionResult = null;
|
UpgradeVerdict(Verdict.Error);
|
}
|
}
|
|
public override void PostPlanRun()
|
{
|
}
|
}
|
}
|