Ejemplo n.º 1
0
        public EquationValidationResult ValidateEquation(ValidateEquationModel model, BridgeCareContext db)
        {
            CalculateEvaluate calcEval = new CalculateEvaluate();

            if (model.IsPiecewise)
            {
                return(checkPiecewise(model.Equation));
            }

            try
            {
                string equation = model.Equation.Trim();
                equation = checkAttributes(equation, model.IsFunction, db);

                if (model.IsFunction)
                {
                    calcEval.BuildFunctionClass(equation, "double", null);
                }
                else
                {
                    calcEval.BuildTemporaryClass(equation, true);
                }

                calcEval.CompileAssembly();
            }
            catch (Exception e)
            {
                return(new EquationValidationResult(false, e.Message));
            }

            return(new EquationValidationResult(true, "Success"));
        }
Ejemplo n.º 2
0
        public void ValidateEquation(ValidateEquationModel model, BridgeCareContext db)
        {
            CalculateEvaluate calcEval = new CalculateEvaluate();

            if (model.IsPiecewise)
            {
                checkPiecewise(model.Equation);
            }
            else
            {
                string equation = model.Equation.Trim();
                equation = checkAttributes(equation, model.IsFunction, db);

                if (model.IsFunction)
                {
                    calcEval.BuildFunctionClass(equation, "double", null);
                }
                else
                {
                    calcEval.BuildTemporaryClass(equation, true);
                }

                calcEval.CompileAssembly();
            }
        }
Ejemplo n.º 3
0
 public IHttpActionResult ValidateEquation(ValidateEquationModel model)
 {
     repo.ValidateEquation(model, db);
     return(Ok());
 }