GetFormulaComputeExcutor.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data.SqlClient;
  4. using System.Linq;
  5. using System.Text;
  6. using JLHHJSvr.BLL;
  7. using JLHHJSvr.Com;
  8. using JLHHJSvr.Com.Model;
  9. using JLHHJSvr.DBA.DBModle;
  10. using JLHHJSvr.LJFramework.Tools;
  11. using LJLib.DAL.SQL;
  12. using LJLib.Net.SPI.Server;
  13. namespace JLHHJSvr.Excutor
  14. {
  15. internal sealed class GetFormulaComputeExcutor : ExcutorBase<GetFormulaComputeRequest, GetFormulaComputeResponse>
  16. {
  17. protected override void ExcuteInternal(GetFormulaComputeRequest request, object state, GetFormulaComputeResponse rslt)
  18. {
  19. var tokendata = BllHelper.GetToken(request.token);
  20. if (tokendata == null)
  21. {
  22. rslt.ErrMsg = "会话已经中断,请重新登录";
  23. return;
  24. }
  25. using (var con = new SqlConnection(GlobalVar.ConnectionString))
  26. using (var cmd = con.CreateCommand())
  27. {
  28. con.Open();
  29. rslt.values = new List<decimal>();
  30. try {
  31. foreach(var iformula in request.formulas)
  32. {
  33. var res = LJExprParser.Parse(iformula);
  34. rslt.values.Add(res.Result.DecimalValue);
  35. }
  36. }
  37. catch (Exception ex)
  38. {
  39. rslt.ErrMsg = ex.ToString();
  40. }
  41. }
  42. }
  43. }
  44. }