GetFormulaComputeExcutor.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. using LJLib.SQLEX;
  14. namespace JLHHJSvr.Excutor
  15. {
  16. internal sealed class GetFormulaComputeExcutor : ExcutorBase<GetFormulaComputeRequest, GetFormulaComputeResponse>
  17. {
  18. protected override void ExcuteInternal(GetFormulaComputeRequest request, object state, GetFormulaComputeResponse rslt)
  19. {
  20. var tokendata = BllHelper.GetToken(request.token);
  21. if (tokendata == null)
  22. {
  23. rslt.ErrMsg = "会话已经中断,请重新登录";
  24. return;
  25. }
  26. using (var con = GlobalVar.ConnectionString.NewSqlConnection())
  27. using (var cmd = con.CreateCommand())
  28. {
  29. con.Open();
  30. rslt.values = new List<decimal>();
  31. try {
  32. foreach(var iformula in request.formulas)
  33. {
  34. var res = LJExprParser.Parse(iformula);
  35. rslt.values.Add(res.Result.DecimalValue);
  36. }
  37. }
  38. catch (Exception ex)
  39. {
  40. rslt.ErrMsg = ex.ToString();
  41. }
  42. }
  43. }
  44. }
  45. }