SaveSoftBedFormulaExcutor.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System;
  2. using DirectService.Tools;
  3. using JLHHJSvr.BLL;
  4. using JLHHJSvr.Com;
  5. using JLHHJSvr.Helper;
  6. using LJLib.DAL.SQL;
  7. using LJLib.Net.SPI.Server;
  8. using LJLib.SQLEX;
  9. namespace JLHHJSvr.Excutor
  10. {
  11. internal sealed class SaveSoftBedFormulaExcutor : ExcutorBase<SaveSoftBedFormulaRequest, SaveSoftBedFormulaResponse>
  12. {
  13. protected override void ExcuteInternal(SaveSoftBedFormulaRequest request, object state, SaveSoftBedFormulaResponse rslt)
  14. {
  15. var tokendata = BllHelper.GetToken(request.token);
  16. if (request.formula == null)
  17. {
  18. rslt.ErrMsg = "未提交软床公式定义信息";
  19. return;
  20. }
  21. if (string.IsNullOrEmpty(request.formula.formulaname))
  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. var baseHelper = HelperBase.GetHelper<BasicInfoHelper>(cmd, new HelperBase.Context() { tokendata = tokendata });
  31. var _formula = ObjectHelper.DeepCopy(request.formula);
  32. using (cmd.Transaction = con.BeginTransaction())
  33. {
  34. try
  35. {
  36. baseHelper.SaveSoftBedFormula(_formula);
  37. cmd.Transaction.Commit();
  38. }
  39. catch (Exception e)
  40. {
  41. rslt.ErrMsg = e.Message;
  42. cmd.Transaction?.Rollback();
  43. }
  44. }
  45. }
  46. }
  47. }
  48. }