public IInstruction GetLastValidInstruction() { if (Instructions == null || !Instructions.Any()) { return(null); } return(Instructions.LastOrDefault(i => !i.IsAborted)); }
private void CheckInput() { if (Instructions.Any()) { T first = Instructions.First(); _firstIdx = Adapter.Index[first]; long maxIdx = _firstIdx + Instructions.Count; for (int i = 0; i < Instructions.Count; i++) { T instr = Instructions[i]; Debug.Assert(i == Adapter.Index[instr] - _firstIdx); Debug.Assert(Adapter.Preds[instr].All(pred => InRange(Adapter.Index[pred.Task], _firstIdx, maxIdx))); Debug.Assert(Adapter.Succs[instr].All(succ => InRange(Adapter.Index[succ.Task], _firstIdx, maxIdx))); } } }
public void SetInspection(Inspection inspection, User user) { if (Status == QualityControlStatus.Closed) { throw new Exception("Current status does not allow to add more instructions."); } if (Instructions.Any(i => i.Status == InstructionStatus.Pending)) { throw new Exception("All instructions should be performed before final inspection."); } Status = QualityControlStatus.Closed; Inspection = inspection; SetTraceabilityValues(user); }