public decimal CalculateExpressionValue(string expression, int decimalDigit)
{
decimal value = 0m;
if (string.IsNullOrEmpty(expression))
{
return value;
}
object va = 0;
try
{
MSScriptControl.ScriptControl sc = new MSScriptControl.ScriptControl();
sc.Language = "JavaScript";
va = sc.Eval(expression);
sc.Reset();
value = Convert.ToDecimal(va);
value = Decimal.Round(value, decimalDigit);
}
catch (Exception ex)
{
return 0m;
}
return value;
}
--------node.js eveal-----------
nodeJS的eval函数 封装API,可以满足高并发请求