[HttpPost]
public JsonResult ScriptExpressions(string expL
,string expW,string expH,string expP,string expD
, string L, string W, string H, string P)
{
ExpResult result = new ExpResult();
try
{
MSScriptControl.ScriptControl sc = new MSScriptControl.ScriptControl();
sc.Language = "JavaScript";
StringBuilder sb = new StringBuilder();
sb.AppendFormat("var L={0},W={1},H={2},P={3};", string.IsNullOrWhiteSpace(L) ? "0" : L, string.IsNullOrWhiteSpace(W) ? "0" : W, string.IsNullOrWhiteSpace(H) ? "0" : H, string.IsNullOrWhiteSpace(P) ? "0" : P);
sc.ExecuteStatement(sb.ToString());
if (!string.IsNullOrWhiteSpace(expL))
result.L = sc.Eval(expL);//长
else
result.L = 0;
if (!string.IsNullOrWhiteSpace(expW))
result.W = sc.Eval(expW);//宽
else
result.W = 0;
if (!string.IsNullOrWhiteSpace(expH))
result.H = sc.Eval(expH);//高
else
result.H = 0;
if (!string.IsNullOrWhiteSpace(expP))
result.P = sc.Eval(expP);//外箱单价
else
result.P = 0;
if (!string.IsNullOrWhiteSpace(expD))
result.D = sc.Eval(expD);//刀μ?卡¨单μ¥价?
else
result.D = 0;
result.flag = true;
return Json(result);
}
catch
{
result.flag = false;
return Json(result);
}
}
}
public class ExpResult
{
public double L { get; set; }
public double W { get; set; }
public double H { get; set; }
public double P { get; set; }
public double D { get; set; }
public bool flag { get; set; }
}