SaveMattressInterfaceExcutor.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data.SqlClient;
  4. using System.Diagnostics;
  5. using System.Linq;
  6. using System.Text;
  7. using DirectService.Tools;
  8. using JLHHJSvr.BLL;
  9. using JLHHJSvr.Com;
  10. using JLHHJSvr.Com.Model;
  11. using JLHHJSvr.Helper;
  12. using JLHHJSvr.LJException;
  13. using JLHHJSvr.LJFramework.Tools;
  14. using JLHHJSvr.Tools;
  15. using LJLib.DAL.SQL;
  16. using LJLib.Net.SPI.Server;
  17. using LJLib.SQLEX;
  18. namespace JLHHJSvr.Excutor
  19. {
  20. internal sealed class SaveMattressInterfaceExcutor : ExcutorBase<SaveMattressInterfaceRequest, SaveMattressInterfaceResponse>
  21. {
  22. Dictionary<string, object> replacements = new Dictionary<string, object>();
  23. protected override void ExcuteInternal(SaveMattressInterfaceRequest request, object state, SaveMattressInterfaceResponse rslt)
  24. {
  25. var tokendata = BllHelper.GetToken(request.token);
  26. if (request.mattress == null)
  27. {
  28. rslt.ErrMsg = "缺少主表信息";
  29. return;
  30. }
  31. if (request.interfaceList == null || !request.interfaceList.Any())
  32. {
  33. rslt.ErrMsg = "缺少产品配置明细";
  34. return;
  35. }
  36. if (request.qdList == null || !request.qdList.Any())
  37. {
  38. rslt.ErrMsg = "缺少产品清单明细";
  39. return;
  40. }
  41. using (var con = GlobalVar.ConnectionString.NewSqlConnection())
  42. using (var cmd = con.CreateCommand())
  43. {
  44. con.Open();
  45. // 初始化属性
  46. AutoInit.AutoInitS(cmd, request.mattress);
  47. foreach (var mx in request.interfaceList)
  48. {
  49. AutoInit.AutoInitS(cmd, mx);
  50. }
  51. foreach (var mx in request.qdList)
  52. {
  53. AutoInit.AutoInitS(cmd, mx);
  54. }
  55. var interfaceHelper = HelperBase.GetHelper<InterfaceHelper>(cmd, new HelperBase.Context() { tokendata = tokendata });
  56. using (cmd.Transaction = con.BeginTransaction())
  57. {
  58. try
  59. {
  60. interfaceHelper.SaveMattressInterface(request.mattress, request.interfaceList, request.qdList);
  61. cmd.Transaction.Commit();
  62. }
  63. catch (Exception e)
  64. {
  65. cmd.Transaction?.Rollback();
  66. rslt.ErrMsg = e.Message;
  67. }
  68. }
  69. }
  70. }
  71. }
  72. }