GetComputeMattressExcutor.cs 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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.Helper;
  10. using JLHHJSvr.LJException;
  11. using JLHHJSvr.Tools;
  12. using LJLib.DAL.SQL;
  13. using LJLib.Net.SPI.Server;
  14. namespace JLHHJSvr.Excutor
  15. {
  16. internal sealed class GetComputeMattressExcutor : ExcutorBase<GetComputeMattressRequest, GetComputeMattressResponse>
  17. {
  18. protected override void ExcuteInternal(GetComputeMattressRequest request, object state, GetComputeMattressResponse rslt)
  19. {
  20. var tokendata = BllHelper.GetToken(request.token);
  21. if (tokendata == null)
  22. {
  23. rslt.ErrMsg = "会话已经中断,请重新登录";
  24. return;
  25. }
  26. if (request.mattress == null)
  27. {
  28. rslt.ErrMsg = "缺少主表信息";
  29. return;
  30. }
  31. using (var con = new SqlConnection(GlobalVar.ConnectionString))
  32. using (var cmd = con.CreateCommand())
  33. {
  34. con.Open();
  35. // 初始化属性
  36. AutoInit.AutoInitS(cmd, request.mattress);
  37. if (request.mattress.copy_id != null && request.mattress.copy_id > 0)
  38. {
  39. request.mattress.mattressid = 0;
  40. request.mattress.mattresscode = string.Empty;
  41. foreach (var mx in request.mattressMx)
  42. {
  43. mx.mattressid = 0;
  44. mx.mattressmxid = 0;
  45. }
  46. }
  47. foreach (var mx in request.mattressMx)
  48. {
  49. AutoInit.AutoInitS(cmd, mx);
  50. }
  51. using (cmd.Transaction = con.BeginTransaction())
  52. {
  53. var helper = HelperBase.GetHelper<MattressHelper>(cmd, new HelperBase.Context() { tokendata = tokendata });
  54. if (request.check_original == 1)
  55. {
  56. helper.CalCulateFormula(request.mattress, request.mattressMx, false, false);
  57. rslt.replace_origin = helper.Replacements;
  58. rslt.formulas_origin = helper.FormulaReplacements;
  59. }
  60. try
  61. {
  62. helper.CalCulateFormula(request.mattress, request.mattressMx, false);
  63. rslt.replace = helper.Replacements;
  64. rslt.formulas = helper.FormulaReplacements;
  65. }
  66. catch (Exception e)
  67. {
  68. rslt.message = e.Message;
  69. }
  70. //rslt.mattress = request.mattress;
  71. }
  72. }
  73. }
  74. }
  75. }