SaveMattressInterfaceExcutor.cs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 (tokendata == null)
  27. {
  28. rslt.ErrMsg = "会话已经中断,请重新登录";
  29. return;
  30. }
  31. if (request.mattress == null)
  32. {
  33. rslt.ErrMsg = "缺少主表信息";
  34. return;
  35. }
  36. if (request.interfaceList == null || !request.interfaceList.Any())
  37. {
  38. rslt.ErrMsg = "缺少产品配置明细";
  39. return;
  40. }
  41. if (request.qdList == null || !request.qdList.Any())
  42. {
  43. rslt.ErrMsg = "缺少产品清单明细";
  44. return;
  45. }
  46. using (var con = GlobalVar.ConnectionString.NewSqlConnection())
  47. using (var cmd = con.CreateCommand())
  48. {
  49. con.Open();
  50. // 初始化属性
  51. AutoInit.AutoInitS(cmd, request.mattress);
  52. foreach (var mx in request.interfaceList)
  53. {
  54. AutoInit.AutoInitS(cmd, mx);
  55. }
  56. foreach (var mx in request.qdList)
  57. {
  58. AutoInit.AutoInitS(cmd, mx);
  59. }
  60. var interfaceHelper = HelperBase.GetHelper<InterfaceHelper>(cmd, new HelperBase.Context() { tokendata = tokendata });
  61. using (cmd.Transaction = con.BeginTransaction())
  62. {
  63. try
  64. {
  65. interfaceHelper.SaveMattressInterface(request.mattress, request.interfaceList, request.qdList);
  66. cmd.Transaction.Commit();
  67. }
  68. catch (Exception e)
  69. {
  70. cmd.Transaction.Rollback();
  71. rslt.ErrMsg = e.ToString();
  72. }
  73. }
  74. }
  75. }
  76. }
  77. }