示例#1
0
        public static Penalization Build(IPerformance announced, IPerformance realized, IRules rules)
        {
            double announcedValue = rules.PrimaryComponent.Get(announced) ?? 0;
            double realizedValue  = rules.PrimaryComponent.Get(realized) ?? 0;

            if (announcedValue <= realizedValue)
            {
                return(null);
            }
            var penalization = new Penalization
            {
                IsShortPerformance = true,
                ShortReason        = "",
                PenalizationId     = "Short",
                Reason             = "Short performance",
                Performance        = new Performance(),
                CardResult         = CardResult.Yellow
            };
            var penalty = rules.ShortCalculation.Evaluate(new CalculationVariables(null, announced, realized));

            if (penalty != null)
            {
                penalty = Math.Round(penalty.Value, 4);
            }
            rules.PenalizationsTarget.Modify(penalization.Performance, penalty);
            return(penalization);
        }
示例#2
0
        public Penalization BuildPenalization(double input, Performance result)
        {
            Penalization penalization = new Penalization
            {
                PenalizationId     = id,
                Reason             = reason,
                ShortReason        = shortReason,
                IsShortPerformance = false,
                RuleInput          = HasInput ? input : (double?)null,
                Performance        = new Performance(),
                CardResult         = cardResult
            };

            if (calculation != null)
            {
                component.Modify(penalization.Performance, calculation.Evaluate(new CalculationVariables(input, null, result)));
            }
            return(penalization);
        }
示例#3
0
        public Penalization BuildPenalization(double input, Performance result)
        {
            var          hasInput     = inputName != null;
            Penalization penalization = new Penalization
            {
                PenalizationId = id,
                Reason         = reason,
                ShortReason    = shortReason,
                RuleInput      = inputName == null ? null : (double?)input,
                Performance    = new Performance(),
                CardResult     = cardResult
            };

            if (PenaltyCalculation != null)
            {
                penalization.Performance.Points = penaltyCalculation.Evaluate(new CalculationVariables(input, null, result));
            }
            if (inputName != null && fatalInput != null && input >= fatalInput.Value)
            {
                penalization.CardResult = CardResult.Red;
            }

            return(penalization);
        }